QTrk
qtrk_c_api.cpp
Go to the documentation of this file.
1 #include "std_incl.h"
2 #include "QueuedTracker.h"
3 
4 
6 {
7  return CreateQueuedTracker(*cfg);
8 }
9 
11 {
12  delete qtrk;
13 }
14 
15 
16 // C API, mainly intended to allow binding to .NET
18 {
19  qtrk->SetLocalizationMode(locType);
20 }
21 
22 // Frame and timestamp are ignored by tracking code itself, but usable for the calling code
23 // Pitch: Distance in bytes between two successive rows of pixels (e.g. address of (0,0) - address of (0,1) )
24 // ZlutIndex: Which ZLUT to use for ComputeZ/BuildZLUT
26 {
27  qtrk->ScheduleLocalization(data,pitch,pdt,jobInfo);
28 }
29 
31 {
32  qtrk->ClearResults();
33 }
34 
36 {
37  qtrk->Flush();
38 }
39 
40 // Schedule an entire frame at once, allowing for further optimizations
41 CDLL_EXPORT int DLL_CALLCONV QTrkScheduleFrame(QueuedTracker* qtrk, void *imgptr, int pitch, int width, int height, ROIPosition *positions, int numROI, QTRK_PixelDataType pdt, const LocalizationJob *jobInfo)
42 {
43  return qtrk->ScheduleFrame(imgptr, pitch, width, height, positions, numROI, pdt, jobInfo);
44 }
45 
46 
47 // data can be zero to allocate ZLUT data. zcmp has to have 'zlut_radialsteps' elements
48 CDLL_EXPORT void DLL_CALLCONV QTrkSetRadialZLUT(QueuedTracker* qtrk, float* data, int count, int planes, float* zcmp)
49 {
50  qtrk->SetRadialZLUT(data, count, planes /*, zcmp*/);
51 }
52 
54 {
55  qtrk->GetRadialZLUT(dst);
56 }
57 
58 CDLL_EXPORT void DLL_CALLCONV QTrkGetRadialZLUTSize(QueuedTracker* qtrk, int* count, int* planes, int* radialsteps)
59 {
60  qtrk->GetRadialZLUTSize(*count, *planes, *radialsteps);
61 }
62 
63 
64 CDLL_EXPORT void DLL_CALLCONV QTrkBuildLUT(QueuedTracker* qtrk, void* data, int pitch, QTRK_PixelDataType pdt, bool imageLUT, int plane)
65 {
66  qtrk->BuildLUT(data, pitch, pdt, /*imageLUT,*/ plane);
67 }
68 
70 {
71  qtrk->FinalizeLUT();
72 }
73 
74 
76 {
77  return qtrk->GetResultCount();
78 }
79 
81 {
82  return qtrk->FetchResults(results, maxResults);
83 }
84 
85 
87 {
88  return qtrk->GetQueueLength(maxQueueLen);
89 }
90 
92 {
93  return qtrk->IsIdle();
94 }
95 
96 CDLL_EXPORT void DLL_CALLCONV QTrkGetProfileReport(QueuedTracker* qtrk, char *dst, int maxStrLen)
97 {
98  strncpy(dst, qtrk->GetProfileReport().c_str(), maxStrLen);
99 }
100 
101 CDLL_EXPORT void DLL_CALLCONV QTrkGetWarnings(QueuedTracker* qtrk, char *dst, int maxStrLen)
102 {
103  strncpy(dst, qtrk->GetWarnings().c_str(), maxStrLen);
104 }
105 
106 
108 {
109  *cfg = qtrk->cfg;
110 }
virtual int GetResultCount()=0
Get the number of finished localization jobs (=results) available in memory.
virtual int ScheduleFrame(void *imgptr, int pitch, int width, int height, ROIPosition *positions, int numROI, QTRK_PixelDataType pdt, const LocalizationJob *jobInfo)
Schedule an entire frame at once, allowing for further optimizations.
virtual void BuildLUT(void *data, int pitch, QTRK_PixelDataType pdt, int plane, vector2f *known_pos=0)=0
Add a new lookup table plane.
CDLL_EXPORT void DLL_CALLCONV QTrkGetComputedConfig(QueuedTracker *qtrk, QTrkComputedConfig *cfg)
Definition: qtrk_c_api.cpp:107
virtual void GetRadialZLUTSize(int &count, int &planes, int &radialsteps)=0
Get the dimensions of the radial lookup table data.
virtual void Flush()=0
Stop waiting for more jobs to do, and just process the current batch.
Struct used to define the top-left corner position of an ROI within a frame. ROI is [ x ...
Definition: qtrk_c_api.h:178
QueuedTracker * CreateQueuedTracker(const QTrkComputedConfig &cc)
Helper function to create a QueuedTracker instance.
virtual void GetRadialZLUT(float *dst)=0
Get the radial lookup tables used for z tracking.
Structure for job results.
Definition: qtrk_c_api.h:67
CDLL_EXPORT void DLL_CALLCONV QTrkFinalizeLUT(QueuedTracker *qtrk)
Definition: qtrk_c_api.cpp:69
CDLL_EXPORT int DLL_CALLCONV QTrkFetchResults(QueuedTracker *qtrk, LocalizationResult *results, int maxResults)
Definition: qtrk_c_api.cpp:80
CDLL_EXPORT void DLL_CALLCONV QTrkClearResults(QueuedTracker *qtrk)
Definition: qtrk_c_api.cpp:30
CDLL_EXPORT QueuedTracker *DLL_CALLCONV QTrkCreateInstance(QTrkSettings *cfg)
Create a QueuedTracker instance and return a pointer to it.
Definition: qtrk_c_api.cpp:5
CDLL_EXPORT void DLL_CALLCONV QTrkSetLocalizationMode(QueuedTracker *qtrk, LocMode_t locType)
Select which algorithm is to be used.
Definition: qtrk_c_api.cpp:17
Structure for the settings used by the algorithms implemented in QueuedTracker.
Definition: qtrk_c_api.h:82
virtual void FinalizeLUT()=0
Finalize the lookup tables in memory.
virtual void SetLocalizationMode(LocMode_t locType)=0
Select which algorithm is to be used.
int LocMode_t
Definition: qtrk_c_api.h:30
virtual void SetRadialZLUT(float *data, int count, int planes)=0
Set the radial lookup tables to be used for z tracking.
virtual std::string GetWarnings()
Get a report of encountered errors.
CDLL_EXPORT int DLL_CALLCONV QTrkGetResultCount(QueuedTracker *qtrk)
Definition: qtrk_c_api.cpp:75
CDLL_EXPORT void DLL_CALLCONV QTrkFlush(QueuedTracker *qtrk)
Definition: qtrk_c_api.cpp:35
CDLL_EXPORT void DLL_CALLCONV QTrkGetWarnings(QueuedTracker *qtrk, char *dst, int maxStrLen)
Definition: qtrk_c_api.cpp:101
virtual bool IsIdle()=0
Test to see if the tracker is idle.
virtual int GetQueueLength(int *maxQueueLen=0)=0
Get the lengths of the queue of jobs to be handled.
#define CDLL_EXPORT
Definition: dllmacros.h:9
CDLL_EXPORT int DLL_CALLCONV QTrkScheduleFrame(QueuedTracker *qtrk, void *imgptr, int pitch, int width, int height, ROIPosition *positions, int numROI, QTRK_PixelDataType pdt, const LocalizationJob *jobInfo)
Definition: qtrk_c_api.cpp:41
virtual void ScheduleLocalization(void *data, int pitch, QTRK_PixelDataType pdt, const LocalizationJob *jobInfo)=0
Add a job to the queue to be processed. A job entails running the required algorithms on a single reg...
QTrkComputedConfig cfg
The settings used by this instance of QueuedTracker.
CDLL_EXPORT int DLL_CALLCONV QTrkGetQueueLength(QueuedTracker *qtrk, int *maxQueueLen)
Definition: qtrk_c_api.cpp:86
CDLL_EXPORT void DLL_CALLCONV QTrkGetProfileReport(QueuedTracker *qtrk, char *dst, int maxStrLen)
Definition: qtrk_c_api.cpp:96
QTRK_PixelDataType
Flags indicating the data type of image data.
Definition: qtrk_c_api.h:33
virtual std::string GetProfileReport()
Get the output of performance profiling.
CDLL_EXPORT void DLL_CALLCONV QTrkFreeInstance(QueuedTracker *qtrk)
Free a QueuedTracker instance.
Definition: qtrk_c_api.cpp:10
CDLL_EXPORT void DLL_CALLCONV QTrkBuildLUT(QueuedTracker *qtrk, void *data, int pitch, QTRK_PixelDataType pdt, bool imageLUT, int plane)
Definition: qtrk_c_api.cpp:64
Structure for derived settings computed from base settings in QTrkSettings.
Definition: qtrk_c_api.h:189
CDLL_EXPORT void DLL_CALLCONV QTrkScheduleLocalization(QueuedTracker *qtrk, void *data, int pitch, QTRK_PixelDataType pdt, const LocalizationJob *jobInfo)
Add a job to the queue to be processed. A job entails running the required algorithms on a single reg...
Definition: qtrk_c_api.cpp:25
#define DLL_CALLCONV
Definition: dllmacros.h:3
CDLL_EXPORT void DLL_CALLCONV QTrkSetRadialZLUT(QueuedTracker *qtrk, float *data, int count, int planes, float *zcmp)
Definition: qtrk_c_api.cpp:48
CDLL_EXPORT void DLL_CALLCONV QTrkGetRadialZLUTSize(QueuedTracker *qtrk, int *count, int *planes, int *radialsteps)
Definition: qtrk_c_api.cpp:58
CDLL_EXPORT bool DLL_CALLCONV QTrkIsIdle(QueuedTracker *qtrk)
Definition: qtrk_c_api.cpp:91
virtual int FetchResults(LocalizationResult *results, int maxResults)=0
Fetch available results.
virtual void ClearResults()=0
Clear results.
Abstract tracker interface, implemented by QueuedCUDATracker and QueuedCPUTracker.
Definition: QueuedTracker.h:86
Structure for region of interest metadata.
Definition: qtrk_c_api.h:49
CDLL_EXPORT void DLL_CALLCONV QTrkGetRadialZLUT(QueuedTracker *qtrk, float *dst)
Definition: qtrk_c_api.cpp:53