QTrk
Public Member Functions | Public Attributes | List of all members
XCor1DBuffer Class Reference

Class to facilitate 1D cross correlation calculations. More...

#include <cpu_tracker.h>

Public Member Functions

 XCor1DBuffer (int xcorw)
 Constructs the buffer and initiates the FFT workers. More...
 
void XCorFFTHelper (complex_t *prof, complex_t *prof_rev, scalar_t *result)
 Calculates a cross correlation much like https://en.wikipedia.org/wiki/Autocorrelation#Efficient_computation. More...
 

Public Attributes

kissfft< scalar_tfft_forward
 Handle to forward FFT kissfft instance. More...
 
kissfft< scalar_tfft_backward
 Handle to backward FFT kissfft instance. More...
 
int xcorw
 Width of the cross correlation. More...
 

Detailed Description

Class to facilitate 1D cross correlation calculations.

Definition at line 9 of file cpu_tracker.h.

Constructor & Destructor Documentation

§ XCor1DBuffer()

XCor1DBuffer::XCor1DBuffer ( int  xcorw)
inline

Constructs the buffer and initiates the FFT workers.

Definition at line 12 of file cpu_tracker.h.

12  : fft_forward(xcorw, false), fft_backward(xcorw, true), xcorw(xcorw)
13  {}
int xcorw
Width of the cross correlation.
Definition: cpu_tracker.h:17
kissfft< scalar_t > fft_backward
Handle to backward FFT kissfft instance.
Definition: cpu_tracker.h:16
kissfft< scalar_t > fft_forward
Handle to forward FFT kissfft instance.
Definition: cpu_tracker.h:15

Member Function Documentation

§ XCorFFTHelper()

void XCor1DBuffer::XCorFFTHelper ( complex_t prof,
complex_t prof_rev,
scalar_t result 
)

Calculates a cross correlation much like https://en.wikipedia.org/wiki/Autocorrelation#Efficient_computation.

  • Calculates the FFTs of both the normal and reverse profiles
  • Multiplies the FFT of the normal profile with the complex conjugate FFT of the reverse profile
  • Transforms the result back to obtain the cross correlation
Parameters
[in]profThe original profile.
[in]prof_revThe reversed profile.
[out]resultPre-allocated array that will hold the cross correlation.

Definition at line 138 of file cpu_tracker.cpp.

139 {
140  complex_t* fft_out = (complex_t*)ALLOCA(sizeof(complex_t)*xcorw);
141  complex_t* fft_out_rev = (complex_t*)ALLOCA(sizeof(complex_t)*xcorw);
142 
143  fft_forward.transform(prof, fft_out);
144  fft_forward.transform(prof_rev, fft_out_rev);
145 
146  // Multiply with conjugate of reverse
147  for (int x=0;x<xcorw;x++) {
148  fft_out[x] *= conjugate(fft_out_rev[x]);
149  }
150 
151  fft_backward.transform(fft_out, fft_out_rev);
152 
153  for (int x=0;x<xcorw;x++)
154  result[x] = fft_out_rev[ (x+xcorw/2) % xcorw ].real();
155 }
int xcorw
Width of the cross correlation.
Definition: cpu_tracker.h:17
kissfft< scalar_t > fft_backward
Handle to backward FFT kissfft instance.
Definition: cpu_tracker.h:16
kissfft< scalar_t > fft_forward
Handle to forward FFT kissfft instance.
Definition: cpu_tracker.h:15
T conjugate(const T &v)
Definition: cpu_tracker.cpp:30
#define ALLOCA(size)
Definition: std_incl.h:151
std::complex< scalar_t > complex_t
Definition: scalar_types.h:12

Member Data Documentation

§ fft_backward

kissfft<scalar_t> XCor1DBuffer::fft_backward

Handle to backward FFT kissfft instance.

Definition at line 16 of file cpu_tracker.h.

§ fft_forward

kissfft<scalar_t> XCor1DBuffer::fft_forward

Handle to forward FFT kissfft instance.

Definition at line 15 of file cpu_tracker.h.

§ xcorw

int XCor1DBuffer::xcorw

Width of the cross correlation.

Definition at line 17 of file cpu_tracker.h.


The documentation for this class was generated from the following files: