QTrk
Functions
CPU Tracker

CPUTracker exclusive debug functions. More...

Functions

CDLL_EXPORT CPUTracker *DLL_CALLCONV create_tracker (uint w, uint h, uint xcorw)
 
CDLL_EXPORT void DLL_CALLCONV destroy_tracker (CPUTracker *tracker)
 
CDLL_EXPORT void DLL_CALLCONV compute_com (CPUTracker *tracker, float *out)
 
CDLL_EXPORT int DLL_CALLCONV compute_xcor (CPUTracker *tracker, vector2f *position, int iterations, int profileWidth)
 
CDLL_EXPORT int DLL_CALLCONV compute_qi (CPUTracker *tracker, vector2f *position, int iterations, int radialSteps, int angularStepsPerQ, float minRadius, float maxRadius, LVArray< float > **radialweights)
 
CDLL_EXPORT void DLL_CALLCONV set_image_from_memory (CPUTracker *tracker, LVArray2D< uchar > **pData, ErrorCluster *error)
 
CDLL_EXPORT void DLL_CALLCONV set_image_u8 (CPUTracker *tracker, LVArray2D< uchar > **pData, ErrorCluster *error)
 
CDLL_EXPORT void DLL_CALLCONV set_image_u16 (CPUTracker *tracker, LVArray2D< ushort > **pData, ErrorCluster *error)
 
CDLL_EXPORT void DLL_CALLCONV set_image_float (CPUTracker *tracker, LVArray2D< float > **pData, ErrorCluster *error)
 
CDLL_EXPORT float DLL_CALLCONV compute_z (CPUTracker *tracker, float *center, int angularSteps, int zlut_index, uint *error, LVArray< float > **profile, int *bestIndex, LVArray< float > **errorCurve)
 
CDLL_EXPORT void DLL_CALLCONV get_debug_img_as_array (CPUTracker *tracker, LVArray2D< float > **pdbgImg)
 
CDLL_EXPORT void DLL_CALLCONV compute_crp (CPUTracker *tracker, LVArray< float > **result, int radialSteps, float *radii, float *center, uint *boundaryHit, LVArray2D< float > **crpmap)
 
CDLL_EXPORT float DLL_CALLCONV compute_asymmetry (CPUTracker *tracker, LVArray< float > **result, int radialSteps, float *radii, float *center, uint *boundaryHit)
 
CDLL_EXPORT void DLL_CALLCONV compute_radial_profile (CPUTracker *tracker, LVArray< float > **result, int angularSteps, float *radii, float *center, uint *boundaryHit)
 
CDLL_EXPORT void DLL_CALLCONV set_ZLUT (CPUTracker *tracker, LVArray3D< float > **pZlut, float *radii, int angular_steps, bool useCorrelation, LVArray< float > **radialweights, bool normalize)
 
CDLL_EXPORT void DLL_CALLCONV get_ZLUT (CPUTracker *tracker, int zlutIndex, LVArray2D< float > **dst)
 
CDLL_EXPORT void DLL_CALLCONV generate_test_image (LVArray2D< float > **img, float xp, float yp, float size, float photoncount)
 
CDLL_EXPORT void DLL_CALLCONV generate_image_from_lut (LVArray2D< float > **image, LVArray2D< float > **lut, float *LUTradii, vector3f *position, float pixel_max, int useSplineInterp, int samplesPerPixel)
 

Detailed Description

CPUTracker exclusive debug functions.

Function Documentation

§ compute_asymmetry()

CDLL_EXPORT float DLL_CALLCONV compute_asymmetry ( CPUTracker tracker,
LVArray< float > **  result,
int  radialSteps,
float *  radii,
float *  center,
uint boundaryHit 
)

Definition at line 147 of file lv_cputrack_api.cpp.

148 {
149  LVArray<float>* dst = *result;
150  bool bhit = false;
151  float asym = tracker->ComputeAsymmetry(*(vector2f*)center, radialSteps, dst->dimSize, radii[0], radii[1], dst->elem);
152  if (boundaryHit) *boundaryHit = bhit ? 1 : 0;
153  return asym;
154 }
int32_t dimSize
Definition: labview.h:34
T elem[1]
Definition: labview.h:35
LabVIEW Array template.
Definition: labview.h:33
float ComputeAsymmetry(vector2f center, int radialSteps, int angularSteps, float minRadius, float maxRadius, float *dstAngProf=0)
Find a measure for the asymmetry of the ROI.

§ compute_com()

CDLL_EXPORT void DLL_CALLCONV compute_com ( CPUTracker tracker,
float *  out 
)

Definition at line 41 of file lv_cputrack_api.cpp.

42 {
43  vector2f com = tracker->ComputeMeanAndCOM();
44  out[0] = com.x;
45  out[1] = com.y;
46 }
vector2f ComputeMeanAndCOM(float bgcorrection=0.0f)
Calculate the center of mass of the image.

§ compute_crp()

CDLL_EXPORT void DLL_CALLCONV compute_crp ( CPUTracker tracker,
LVArray< float > **  result,
int  radialSteps,
float *  radii,
float *  center,
uint boundaryHit,
LVArray2D< float > **  crpmap 
)

Definition at line 143 of file lv_cputrack_api.cpp.

144 {
145 }

§ compute_qi()

CDLL_EXPORT int DLL_CALLCONV compute_qi ( CPUTracker tracker,
vector2f position,
int  iterations,
int  radialSteps,
int  angularStepsPerQ,
float  minRadius,
float  maxRadius,
LVArray< float > **  radialweights 
)

Definition at line 56 of file lv_cputrack_api.cpp.

57 {
58  bool boundaryHit;
59 
60  float* rw = 0;
61  if (radialweights && (*radialweights)->dimSize == radialSteps)
62  rw = (*radialweights)->elem;
63 
64  *position = tracker->ComputeQI(*position, iterations, radialSteps, angularStepsPerQ, 1, minRadius,maxRadius, boundaryHit, rw);
65  return boundaryHit ? 1 : 0;
66 }
int32_t dimSize
Definition: labview.h:34
vector2f ComputeQI(vector2f initial, int iterations, int radialSteps, int angularStepsPerQuadrant, float angStepIterationFactor, float minRadius, float maxRadius, bool &boundaryHit, float *radialweights=0)
Execute the quadrant interpolation algorithm.

§ compute_radial_profile()

CDLL_EXPORT void DLL_CALLCONV compute_radial_profile ( CPUTracker tracker,
LVArray< float > **  result,
int  angularSteps,
float *  radii,
float *  center,
uint boundaryHit 
)

Definition at line 156 of file lv_cputrack_api.cpp.

157 {
158  LVArray<float>* dst = *result;
159  bool bhit = false;
160  tracker->ComputeRadialProfile(&dst->elem[0], dst->dimSize, angularSteps, radii[0], radii[1], *(vector2f*)center, false, &bhit);
161 
162  if (boundaryHit) *boundaryHit = bhit ? 1 : 0;
163 }
void ComputeRadialProfile(float *dst, int radialSteps, int angularSteps, float minradius, float maxradius, vector2f center, bool crp, bool *boundaryHit=0, bool normalize=true)
Wrapper to compute a radial profile.
int32_t dimSize
Definition: labview.h:34
T elem[1]
Definition: labview.h:35
LabVIEW Array template.
Definition: labview.h:33

§ compute_xcor()

CDLL_EXPORT int DLL_CALLCONV compute_xcor ( CPUTracker tracker,
vector2f position,
int  iterations,
int  profileWidth 
)

Definition at line 48 of file lv_cputrack_api.cpp.

49 {
50  bool boundaryHit;
51  *position = tracker->ComputeXCorInterpolated(*position, iterations, profileWidth, boundaryHit);
52 
53  return boundaryHit ? 1 : 0;
54 }
vector2f ComputeXCorInterpolated(vector2f initial, int iterations, int profileWidth, bool &boundaryHit)
Compute the cross correlation offsets and resulting position.

§ compute_z()

CDLL_EXPORT float DLL_CALLCONV compute_z ( CPUTracker tracker,
float *  center,
int  angularSteps,
int  zlut_index,
uint error,
LVArray< float > **  profile,
int *  bestIndex,
LVArray< float > **  errorCurve 
)

Definition at line 108 of file lv_cputrack_api.cpp.

109 {
110  bool boundaryHit=false;
111  if (profile)
112  ResizeLVArray(profile, tracker->zlut_res);
113 
114  if (errorCurve) {
115  ResizeLVArray(errorCurve, tracker->zlut_planes);
116  }
117 
118  int maxPos;
119  float* prof = profile ? (*profile)->elem : ALLOCA_ARRAY(float, tracker->zlut_res);
120  tracker->ComputeRadialProfile(prof,tracker->zlut_res,angularSteps, tracker->zlut_minradius, tracker->zlut_maxradius,*(vector2f*) center, false, &boundaryHit, true);
121  float z= tracker->LUTProfileCompare(prof, zlut_index, errorCurve ? (*errorCurve)->elem : 0, CPUTracker::LUTProfMaxQuadraticFit, 0, &maxPos);
122 
123  if (bestIndex) *bestIndex=maxPos;
124 
125  if (error)
126  *error = boundaryHit?1:0;
127  return z;
128 }
void ComputeRadialProfile(float *dst, int radialSteps, int angularSteps, float minradius, float maxradius, vector2f center, bool crp, bool *boundaryHit=0, bool normalize=true)
Wrapper to compute a radial profile.
float zlut_maxradius
Maximum radius in pixels of the ZLUT profile sampling circle.
Definition: cpu_tracker.h:67
float zlut_minradius
Minimum radius in pixels to start sampling for a ZLUT profile.
Definition: cpu_tracker.h:66
int zlut_planes
Number of planes per ZLUT.
Definition: cpu_tracker.h:63
int zlut_res
ZLUT resolution = number of radial steps in a plane.
Definition: cpu_tracker.h:64
void ResizeLVArray(LVArrayND< T, N > **&d, int *dims)
Definition: labview.h:118
float LUTProfileCompare(float *profile, int zlutIndex, float *cmpProf, LUTProfileMaxComputeMode maxPosMethod, float *fitcurve=0, int *maxPos=0, int frameNum=0)
Compare a profile to a LUT and calculate the optimum Z value for it.
T elem[1]
Definition: labview.h:35
#define ALLOCA_ARRAY(T, N)
Definition: std_incl.h:153
Default. Use a 7-point quadratic fit around the error curve&#39;s maximum.
Definition: cpu_tracker.h:379

§ create_tracker()

CDLL_EXPORT CPUTracker* DLL_CALLCONV create_tracker ( uint  w,
uint  h,
uint  xcorw 
)

Definition at line 17 of file lv_cputrack_api.cpp.

18 {
19  try {
20  Sleep(300);
21  return new CPUTracker(w,h,xcorw);
22  }
23  catch(const std::exception& e)
24  {
25  dbgout("Exception: " + std::string(e.what()) + "\n");
26  return 0;
27  }
28 }
void dbgout(const std::string &s)
Definition: utils.cpp:143
Class with all CPU algorithm implementations.
Definition: cpu_tracker.h:38

§ destroy_tracker()

CDLL_EXPORT void DLL_CALLCONV destroy_tracker ( CPUTracker tracker)

Definition at line 30 of file lv_cputrack_api.cpp.

31 {
32  try {
33  delete tracker;
34  }
35  catch(const std::exception& e)
36  {
37  dbgout("Exception: " + std::string(e.what()) + "\n");
38  }
39 }
void dbgout(const std::string &s)
Definition: utils.cpp:143

§ generate_image_from_lut()

CDLL_EXPORT void DLL_CALLCONV generate_image_from_lut ( LVArray2D< float > **  image,
LVArray2D< float > **  lut,
float *  LUTradii,
vector3f position,
float  pixel_max,
int  useSplineInterp,
int  samplesPerPixel 
)

Definition at line 201 of file lv_cputrack_api.cpp.

203 {
204  ImageData img((*image)->elem, (*image)->dimSizes[1], (*image)->dimSizes[0]);
205  ImageData zlut((*lut)->elem, (*lut)->dimSizes[1], (*lut)->dimSizes[0]);
206 
207  GenerateImageFromLUT(&img, &zlut, LUTradii[0], LUTradii[1], *position, useSplineInterp!=0, samplesPerPixel);
208  if (pixel_max>0) {
209  img.normalize();
210  ApplyPoissonNoise(img, pixel_max);
211  }
212 }
void GenerateImageFromLUT(ImageData *image, ImageData *zlut, float minradius, float maxradius, vector3f pos, bool splineInterp, int oversampleSubdiv)
Definition: utils.cpp:354
void ApplyPoissonNoise(ImageData &img, float poissonMax, float maxval)
Definition: utils.cpp:432

§ generate_test_image()

CDLL_EXPORT void DLL_CALLCONV generate_test_image ( LVArray2D< float > **  img,
float  xp,
float  yp,
float  size,
float  photoncount 
)

Definition at line 189 of file lv_cputrack_api.cpp.

190 {
191  try {
192  ImageData data((*img)->elem, (*img)->dimSizes[1],(*img)->dimSizes[0]);
193  GenerateTestImage(data, xp, yp, size, photoncount);
194  }
195  catch(const std::exception& e)
196  {
197  dbgout("Exception: " + std::string(e.what()) + "\n");
198  }
199 }
void GenerateTestImage(ImageData &img, float xp, float yp, float size, float SNratio)
Definition: utils.cpp:162
void dbgout(const std::string &s)
Definition: utils.cpp:143

§ get_debug_img_as_array()

CDLL_EXPORT void DLL_CALLCONV get_debug_img_as_array ( CPUTracker tracker,
LVArray2D< float > **  pdbgImg 
)

Definition at line 130 of file lv_cputrack_api.cpp.

131 {
132  float* src = tracker->GetDebugImage();
133  if (src) {
134  ResizeLVArray2D(pdbgImg, tracker->GetHeight(), tracker->GetWidth());
135  LVArray2D<float>* dst = *pdbgImg;
136 
137  // dbgout(SPrintf("copying %d elements to Labview array\n", len));
138  for (int i=0;i<dst->numElem();i++)
139  dst->elem[i] = src[i];
140  }
141 }
void ResizeLVArray2D(LVArray2D< T > **&d, int rows, int cols)
Definition: labview.h:98
int GetWidth()
Get the width of the image.
Definition: cpu_tracker.h:123
T elem[1]
Definition: labview.h:43
LabVIEW 2D Array template.
Definition: labview.h:41
int GetHeight()
Get the height of the image.
Definition: cpu_tracker.h:124
float * GetDebugImage()
Get the debug image.
Definition: cpu_tracker.h:440

§ get_ZLUT()

CDLL_EXPORT void DLL_CALLCONV get_ZLUT ( CPUTracker tracker,
int  zlutIndex,
LVArray2D< float > **  dst 
)

Definition at line 182 of file lv_cputrack_api.cpp.

183 {
184  float* zlut = tracker->GetRadialZLUT(zlutIndex);
185  ResizeLVArray2D(dst, tracker->zlut_planes, tracker->zlut_res);
186  std::copy(zlut, zlut+(tracker->zlut_planes*tracker->zlut_res), (*dst)->elem);
187 }
int zlut_planes
Number of planes per ZLUT.
Definition: cpu_tracker.h:63
int zlut_res
ZLUT resolution = number of radial steps in a plane.
Definition: cpu_tracker.h:64
float * GetRadialZLUT(int index)
Get the start of the ZLUT of a specific bead.
Definition: cpu_tracker.h:90
void ResizeLVArray2D(LVArray2D< T > **&d, int rows, int cols)
Definition: labview.h:98

§ set_image_float()

CDLL_EXPORT void DLL_CALLCONV set_image_float ( CPUTracker tracker,
LVArray2D< float > **  pData,
ErrorCluster error 
)

Definition at line 98 of file lv_cputrack_api.cpp.

99 {
100  LVArray2D<float>* data = *pData;
101  if (data->dimSizes[0] != tracker->GetWidth() || data->dimSizes[1] != tracker->GetHeight()) {
102  ArgumentErrorMsg(error, "Given image has invalid dimensions");
103  return;
104  }
105  tracker->SetImageFloat( data->elem );
106 }
int32_t dimSizes[2]
Definition: labview.h:42
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
int GetWidth()
Get the width of the image.
Definition: cpu_tracker.h:123
T elem[1]
Definition: labview.h:43
LabVIEW 2D Array template.
Definition: labview.h:41
int GetHeight()
Get the height of the image.
Definition: cpu_tracker.h:124
void SetImageFloat(float *srcImage)
Set an image with float type.
Definition: cpu_tracker.cpp:88

§ set_image_from_memory()

CDLL_EXPORT void DLL_CALLCONV set_image_from_memory ( CPUTracker tracker,
LVArray2D< uchar > **  pData,
ErrorCluster error 
)

Definition at line 68 of file lv_cputrack_api.cpp.

69 {
70  LVArray2D<uchar>* data = *pData;
71  if (data->dimSizes[0] != tracker->GetWidth() || data->dimSizes[1] != tracker->GetHeight()) {
72  ArgumentErrorMsg(error, "Given image has invalid dimensions");
73  return;
74  }
75  tracker->SetImage8Bit( data->elem, tracker->GetWidth() );
76 }
int32_t dimSizes[2]
Definition: labview.h:42
void SetImage8Bit(uchar *srcImage, uint srcpitch)
Set an image with 8 bit type.
Definition: cpu_tracker.h:254
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
int GetWidth()
Get the width of the image.
Definition: cpu_tracker.h:123
T elem[1]
Definition: labview.h:43
LabVIEW 2D Array template.
Definition: labview.h:41
int GetHeight()
Get the height of the image.
Definition: cpu_tracker.h:124

§ set_image_u16()

CDLL_EXPORT void DLL_CALLCONV set_image_u16 ( CPUTracker tracker,
LVArray2D< ushort > **  pData,
ErrorCluster error 
)

Definition at line 88 of file lv_cputrack_api.cpp.

89 {
90  LVArray2D<ushort>* data = *pData;
91  if (data->dimSizes[0] != tracker->GetWidth() || data->dimSizes[1] != tracker->GetHeight()) {
92  ArgumentErrorMsg(error, "Given image has invalid dimensions");
93  return;
94  }
95  tracker->SetImage16Bit( data->elem, tracker->GetWidth()*sizeof(ushort) );
96 }
int32_t dimSizes[2]
Definition: labview.h:42
unsigned short ushort
Definition: std_incl.h:128
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
int GetWidth()
Get the width of the image.
Definition: cpu_tracker.h:123
T elem[1]
Definition: labview.h:43
LabVIEW 2D Array template.
Definition: labview.h:41
int GetHeight()
Get the height of the image.
Definition: cpu_tracker.h:124
void SetImage16Bit(ushort *srcImage, uint srcpitch)
Set an image with 16 bit type.
Definition: cpu_tracker.h:247

§ set_image_u8()

CDLL_EXPORT void DLL_CALLCONV set_image_u8 ( CPUTracker tracker,
LVArray2D< uchar > **  pData,
ErrorCluster error 
)

Definition at line 78 of file lv_cputrack_api.cpp.

79 {
80  LVArray2D<uchar>* data = *pData;
81  if (data->dimSizes[0] != tracker->GetWidth() || data->dimSizes[1] != tracker->GetHeight()) {
82  ArgumentErrorMsg(error, "Given image has invalid dimensions");
83  return;
84  }
85  tracker->SetImage8Bit( data->elem, tracker->GetWidth() );
86 }
int32_t dimSizes[2]
Definition: labview.h:42
void SetImage8Bit(uchar *srcImage, uint srcpitch)
Set an image with 8 bit type.
Definition: cpu_tracker.h:254
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
int GetWidth()
Get the width of the image.
Definition: cpu_tracker.h:123
T elem[1]
Definition: labview.h:43
LabVIEW 2D Array template.
Definition: labview.h:41
int GetHeight()
Get the height of the image.
Definition: cpu_tracker.h:124

§ set_ZLUT()

CDLL_EXPORT void DLL_CALLCONV set_ZLUT ( CPUTracker tracker,
LVArray3D< float > **  pZlut,
float *  radii,
int  angular_steps,
bool  useCorrelation,
LVArray< float > **  radialweights,
bool  normalize 
)

Definition at line 165 of file lv_cputrack_api.cpp.

166 {
167  LVArray3D<float>* zlut = *pZlut;
168 
169  int numLUTs = zlut->dimSizes[0];
170  int planes = zlut->dimSizes[1];
171  int res = zlut->dimSizes[2];
172 
173  if (normalize) {
174  NormalizeZLUT( zlut->elem , numLUTs, planes, res);
175  }
176 
177  tracker->SetRadialZLUT(zlut->elem, planes, res, numLUTs, radii[0], radii[1], true, useCorrelation);
178  if (radialweights)
179  tracker->SetRadialWeights( ((*radialweights)->dimSize>0) ? (*radialweights)->elem : 0);
180 }
T elem[1]
Definition: labview.h:59
int32_t dimSizes[3]
Definition: labview.h:58
void normalize(TPixel *d, uint w, uint h)
Definition: utils.h:27
void SetRadialZLUT(float *data, int planes, int res, int num_zluts, float minradius, float maxradius, bool copyMemory, bool useCorrelation)
Tell the tracker where in memory the LUT is located.
void SetRadialWeights(float *radweights)
Set the radial weights to be used for profile comparisons.
LabVIEW 3D Array template.
Definition: labview.h:57
void NormalizeZLUT(float *zlut, int numBeads, int planes, int radialsteps)
Definition: utils.cpp:291