1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include "pstsdk_cpp.h" #include "TrackerExceptions.h" #include <thread> #include <iostream> class MyListener : public PSTech::pstsdk::Listener { virtual void OnTrackerData(PSTech::pstsdk::TrackerData& td) { for(const auto& target : td.targetlist) { std::cout << target.name.c_str() << std::endl; } } } listener; int main(int argc, char *argv[]) { try { PSTech::pstsdk::Tracker pst; pst.AddTrackerListener(&listener); pst.Start(); std::this_thread::sleep_for(std::chrono::seconds(10)); } catch (PSTech::TrackerException &e) {} PSTech::pstsdk::Tracker::Shutdown(); return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | using System; using System.Threading; using PSTech.Pstsdk; public class Minimal { static void OnTrackerData(TrackerData data, ErrorStatus status) { foreach(TargetPose pose in data.TargetPoseList) { Console.WriteLine(pose.Target.Name); } } static void Main(string[] args) { try { Tracker tracker = new Tracker(); tracker.AddTrackerListener(OnTrackerData); tracker.StartTracker(); Thread.Sleep(10000); } catch (Exception e) {} finally { Tracker.Shutdown(); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include "pstsdk_c.h" #include <stdio.h> #include <Windows.h> void CheckErrorCode(EPstErrorStatus status) { if (status != PST_ERROR_STATUS_OK) { pst_sdk_shutdown(); exit(status); } } void OnTrackerData(const PstTrackerData* tracker_data, EPstErrorStatus status) { for(int d = 0; d < tracker_data->number_of_targets; ++d) { printf("%s\n", tracker_data->targetlist[d].target.name); } } int main(int argc, char* argv[]) { PstTracker ctracker; CheckErrorCode(pst_tracker_init(&ctracker)); CheckErrorCode(pst_tracker_add_tracker_listener(&ctracker, OnTrackerData)); CheckErrorCode(pst_tracker_start(&ctracker)); Sleep(10000); pst_tracker_destroy(&ctracker); return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import context import time import sys import pstech.pstsdk.tracker as pst import pstech.pstsdk.errors as psterrors def callback_function(tracker_data, status_message: int): for data in tracker_data: def main(): if(len(sys.argv) < 2): print("Please specify a full path to a camera configuration file") exit(0) try: with pst.Tracker("", "","", sys.argv[1]) as tracker: tracker.add_tracker_listener(callback_function) tracker.start() time.sleep(10) except psterrors.TrackerError as err: print(err.message) if __name__ == "__main__": main() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> var settings = { "async": true, "crossDomain": true, "url": "http://localhost:7278/PSTapi/Start", "method": "POST", "headers": { "Accept": "*/*", } } $.ajax(settings).done(function (response) { console.log(response); }); var source = new EventSource('http://localhost:7278/PSTapi/StartTrackerDataStream'); source.onmessage = function(event) { var data = event.data; console.log(data); }; </script> </head> </html> |