Debugging summary for rPPG (c++)
Published:
This is a summary for me only about the coding port phase from python to c++. And a test post.
Some valuable feedbacks from collaborator
- Avoid using pointers at all cost, e.g., try to avoid
double* npFFTFreq(int nfft, double d)
. It’s now the time okay to usevector<double>
as the return type, since the compiler is clever enough to use a “move” operation to move your local vector variable defined in the function out of it without doing the “copy” operation that compiles do in the old days. - The issue of
double* freq_grid = npFFTFreq (nfft, 1.0/frame_rate);
is that each time you run it, a new block of memory is created by new in your function and it’s never cleaned up until the destroy of class personRPPG or until the end of the program. This is a memory leakage issue, unless you explicitly delete freq_grid; after using, which is too much to worry about. Of course, you can allocate the memory outsidenpFFTFreq()
but again it’s the old style.