QTrk
qtrk_c_api.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "dllmacros.h"
4 
7  LT_OnlyCOM = 0,
8  LT_XCor1D = 1,
9  LT_QI = 2,
11 
20 
21  LT_LocalizeZ = 16,
24  LT_FourierLUT = 256,
26 
27  LT_Force32Bit = 0xffffffff
28 };
29 
30 typedef int LocMode_t; // LocalizationModeEnum
31 
34 {
35  QTrkU8 = 0,
36  QTrkU16 = 1,
37  QTrkFloat = 2
38 };
39 
40 
41 #pragma pack(push, 1)
42 
52  }
54  frame (frame), timestamp(timestamp), zlutIndex(zlutIndex)
55  {}
58  int zlutIndex;
60 };
61 
70  vector2f pos2D() { return vector2f(pos.x,pos.y); }
73  float imageMean;
74 };
75 
82 struct QTrkSettings {
84  width = height = 100;
85  numThreads = -1;
86  xc1_profileLength = 128;
87  xc1_profileWidth = 32;
88  xc1_iterations = 2;
89  zlut_minradius = 1.0f;
90  zlut_angular_coverage = 0.7f;
91  zlut_radial_coverage = 3.0f;
92  zlut_roi_coverage = 1.0f;
93  qi_iterations = 5;
94  qi_minradius = 1;
95  qi_angular_coverage = 0.7f;
96  qi_radial_coverage = 3.0f;
97  qi_roi_coverage = 1.0f;
98  qi_angstep_factor = 1.0f;
99  cuda_device = -2;
100  com_bgcorrection = 0.0f;
101  gauss2D_iterations = 6;
102  gauss2D_sigma = 4;
103  downsample = 0;
104  //testRun = false; // CHANGED! Comment/remove when compiling for labview
105  }
106  int width;
107  int height;
108 
115 
116 #define QTrkCUDA_UseList -3
117 #define QTrkCUDA_UseAll -2
118 #define QTrkCUDA_UseBest -1
119 
132 
134 
139 
141  float qi_minradius;
145 
158 
162 
165 
167 
174  bool testRun;
175 };
176 
179 {
180  int x,y;
181 };
182 
190 {
192  QTrkComputedConfig(const QTrkSettings& base) { *((QTrkSettings*)this)=base; Update(); }
193  void Update();
194  void WriteToLog();
195  void WriteToFile();
196 
197  // Computed from QTrkSettings
201 
204  float qi_maxradius;
205 };
206 
207 #pragma pack(pop)
208 
209 class QueuedTracker;
210 
227 
233 
240 
251 CDLL_EXPORT void DLL_CALLCONV QTrkScheduleLocalization(QueuedTracker* qtrk, void* data, int pitch, QTRK_PixelDataType pdt, const LocalizationJob *jobInfo);
253 CDLL_EXPORT void DLL_CALLCONV QTrkFlush(QueuedTracker* qtrk); // stop waiting for more jobs to do, and just process the current batch
254 
255 // Schedule an entire frame at once, allowing for further optimizations
256 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);
257 
258 // data can be zero to allocate ZLUT data. zcmp has to have 'zlut_radialsteps' elements
259 CDLL_EXPORT void DLL_CALLCONV QTrkSetRadialZLUT(QueuedTracker* qtrk, float* data, int count, int planes, float* zcmp=0);
261 CDLL_EXPORT void DLL_CALLCONV QTrkGetRadialZLUTSize(QueuedTracker* qtrk, int* count, int* planes, int* radialsteps);
262 
263 CDLL_EXPORT void DLL_CALLCONV QTrkBuildLUT(QueuedTracker* qtrk, void* data, int pitch, QTRK_PixelDataType pdt, bool imageLUT, int plane);
265 
267 CDLL_EXPORT int DLL_CALLCONV QTrkFetchResults(QueuedTracker* qtrk, LocalizationResult* results, int maxResults);
268 
269 CDLL_EXPORT int DLL_CALLCONV QTrkGetQueueLength(QueuedTracker* qtrk, int *maxQueueLen);
271 
272 CDLL_EXPORT void DLL_CALLCONV QTrkGetProfileReport(QueuedTracker* qtrk, char *dst, int maxStrLen);
273 CDLL_EXPORT void DLL_CALLCONV QTrkGetWarnings(QueuedTracker* qtrk, char *dst, int maxStrLen);
274 
276 
int gauss2D_iterations
Number of times to run the 2D gaussian algorithm.
Definition: qtrk_c_api.h:163
float zlut_minradius
Distance in pixels from the bead center from which to start sampling profiles. Default 1...
Definition: qtrk_c_api.h:135
Ignore the first four pixels of a frame. Some cameras save timestamps rather than image data in the f...
Definition: qtrk_c_api.h:23
CDLL_EXPORT void DLL_CALLCONV QTrkGetComputedConfig(QueuedTracker *qtrk, QTrkComputedConfig *cfg)
Definition: qtrk_c_api.cpp:107
64 bit float
Definition: qtrk_c_api.h:37
vector3f initialPos
Optional (Not used)
Definition: qtrk_c_api.h:59
float qi_minradius
Distance in pixels from the bead center from which to start sampling profiles. Default 1...
Definition: qtrk_c_api.h:141
int width
Width of regions of interest to be handled. Typically equals height (square ROI). ...
Definition: qtrk_c_api.h:106
16 bit unsigned int
Definition: qtrk_c_api.h:36
int downsample
Image downsampling factor. Applied before anything else. 0 = original, 1 = 1x (W=W/2,H=H/2).
Definition: qtrk_c_api.h:166
Struct used to define the top-left corner position of an ROI within a frame. ROI is [ x ...
Definition: qtrk_c_api.h:178
int zlutIndex
Bead number of this ROI. Used to get the right ZLUT from memory.
Definition: qtrk_c_api.h:58
unsigned int uint
Definition: std_incl.h:127
bool testRun
Flag to run a test run.
Definition: qtrk_c_api.h:174
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
int height
Height of regions of interest to be handled. Typically equals width (square ROI). ...
Definition: qtrk_c_api.h:107
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
vector2< float > vector2f
Definition: std_incl.h:39
Structure for the settings used by the algorithms implemented in QueuedTracker.
Definition: qtrk_c_api.h:82
8 bit unsigned int
Definition: qtrk_c_api.h:35
int zlut_radialsteps
Number of radial steps to sample on.
Definition: qtrk_c_api.h:198
LocalizationJob(uint frame, uint timestamp, uint zlutPlane, uint zlutIndex)
Definition: qtrk_c_api.h:53
float imageMean
Average pixel value of the ROI.
Definition: qtrk_c_api.h:73
uint timestamp
Time stamp of the frame.
Definition: qtrk_c_api.h:57
uint frame
Frame number this ROI belongs to.
Definition: qtrk_c_api.h:56
int LocMode_t
Definition: qtrk_c_api.h:30
LocalizeModeEnum
Flags for selecting localization type.
Definition: qtrk_c_api.h:6
COM+XCor1D.
Definition: qtrk_c_api.h:8
CDLL_EXPORT int DLL_CALLCONV QTrkGetResultCount(QueuedTracker *qtrk)
Definition: qtrk_c_api.cpp:75
vector2f pos2D()
Final 2D position found.
Definition: qtrk_c_api.h:70
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
Make a fourier based lookup table.
Definition: qtrk_c_api.h:24
vector3f pos
Final 3D position found. If no z localization was performed, the value of z will be 0...
Definition: qtrk_c_api.h:69
Enable z localization.
Definition: qtrk_c_api.h:21
float com_bgcorrection
Background correction factor for COM. Defines the number of standard deviations data needs to be away...
Definition: qtrk_c_api.h:133
float qi_maxradius
Max radius in pixels of the sampling circle.
Definition: qtrk_c_api.h:204
Normalize found radial profiles.
Definition: qtrk_c_api.h:22
#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
LocalizationJob job
Job metadata. See LocalizationJob.
Definition: qtrk_c_api.h:68
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
float zlut_roi_coverage
Factor of the ROI to include in sampling. Between 0 and 1, default 1. Maxradius = ROI/2*roi_coverage...
Definition: qtrk_c_api.h:138
CDLL_EXPORT void DLL_CALLCONV QTrkFreeInstance(QueuedTracker *qtrk)
Free a QueuedTracker instance.
Definition: qtrk_c_api.cpp:10
int cuda_device
CUDA only. Flag for device selection.
Definition: qtrk_c_api.h:131
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
float qi_radial_coverage
Sampling points per radial pixel. Default 3.0.
Definition: qtrk_c_api.h:142
Structure for derived settings computed from base settings in QTrkSettings.
Definition: qtrk_c_api.h:189
float zlut_angular_coverage
Factor of the sampling perimeter to cover with angular sampling steps. Between 0 and 1...
Definition: qtrk_c_api.h:137
QTrkComputedConfig(const QTrkSettings &base)
Definition: qtrk_c_api.h:192
int qi_radialsteps
Number of radial steps to sample on.
Definition: qtrk_c_api.h:202
vector2f firstGuess
(x,y) position found by the COM localization. Used as initial position for the subsequent algorithms...
Definition: qtrk_c_api.h:71
void WriteToLog(const char *str)
Definition: utils.cpp:88
COM+QI.
Definition: qtrk_c_api.h:9
2D Gaussian localization
Definition: qtrk_c_api.h:10
float qi_roi_coverage
Factor of the ROI to include in sampling. Between 0 and 1, default 1. Maxradius = ROI/2*roi_coverage...
Definition: qtrk_c_api.h:144
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
int qi_angstepspq
Number of angular steps to sample on per quadrant.
Definition: qtrk_c_api.h:203
Use only COM.
Definition: qtrk_c_api.h:7
int qi_iterations
Number of times to run the QI algorithm, sampling around the last found position. ...
Definition: qtrk_c_api.h:140
int xc1_iterations
Number of times to run the cross correlation algorithm.
Definition: qtrk_c_api.h:161
Enable ZLUT align.
Definition: qtrk_c_api.h:19
float qi_angstep_factor
Factor to reduce angular steps on lower iterations. Default 1.0 (no effect).
Definition: qtrk_c_api.h:157
#define DLL_CALLCONV
Definition: dllmacros.h:3
CDLL_EXPORT void DLL_CALLCONV QTrkSetRadialZLUT(QueuedTracker *qtrk, float *data, int count, int planes, float *zcmp=0)
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
int xc1_profileWidth
Profile width for the cross correlation.
Definition: qtrk_c_api.h:160
float gauss2D_sigma
Standard deviation to use in the 2D gaussian algorithm.
Definition: qtrk_c_api.h:164
uint error
Flag (boolean) indicating whether the ROI boundary was hit during localization. A 1 indicates a hit...
Definition: qtrk_c_api.h:72
Abstract tracker interface, implemented by QueuedCUDATracker and QueuedCPUTracker.
Definition: QueuedTracker.h:86
int numThreads
Number of threads/streams to use. Defaults differ between CPU and GPU implementations.
Definition: qtrk_c_api.h:114
float zlut_radial_coverage
Sampling points per radial pixel. Default 3.0.
Definition: qtrk_c_api.h:136
float qi_angular_coverage
Factor of the sampling perimeter to cover with angular sampling steps. Between 0 and 1...
Definition: qtrk_c_api.h:143
Structure for region of interest metadata.
Definition: qtrk_c_api.h:49
int xc1_profileLength
Profile length for the cross correlation.
Definition: qtrk_c_api.h:159
int zlut_angularsteps
Number of angular steps to sample on.
Definition: qtrk_c_api.h:199
float zlut_maxradius
Max radius in pixels of the sampling circle.
Definition: qtrk_c_api.h:200
Do a ZLUT lookup with adjusted weights, for testing purposes.
Definition: qtrk_c_api.h:25
CDLL_EXPORT void DLL_CALLCONV QTrkGetRadialZLUT(QueuedTracker *qtrk, float *dst)
Definition: qtrk_c_api.cpp:53