ofxOpenCV Optical Flow with IplImage

Hello,

Having trouble with the cvCalcOpticalFlowFarneback function that I have used many times with the add-on successfully in pervious versions of OF. I normally pass in CvArr* with the getCvImage() function which is an lplImage* to the cvCalcOpticalFlowFarneback function and it works as expected. But now there is the error:
Reference to type 'const cv::_InputArray' could not bind to an rvalue of type 'IplImage *' (aka '_IplImage *')
I can convert the lplImages to cv::Mat and then use those, but seems like the data copy will slow things down.

I think the ⁨addons⁩ ▸ ⁨ofxOpenCv⁩ ▸ ⁨libs⁩ ▸ ⁨opencv⁩ ▸ ⁨include⁩ ▸ ⁨opencv2⁩ ▸ ⁨video ▸ ⁩tracking_c.h file is missing so the CvArr* arguments are not available.

I am using OF v.0.11.0 on OSX 10.14.6

Any thoughts are much appreciated.

Thanks!
Nick

Im running to the same problem, have you found the solution for this?

Hi @ives,
I found the tracking_c.h file from previous versions of Openframeworks and copied it into the project. I don’t remember where I pulled it from, but something like the following may work.https://github.com/openframeworks/openFrameworks/tree/1df381d96c5cf0523190109edb5e41b14250b152/addons/ofxOpenCv/libs/opencv/include/opencv2/video

I can attach the specific one I used if that doesn’t work.

Without copying tracking_c.h, this is the code I use to get around it.

cv::Mat prevMat = cv::cvarrToMat(threadVars.prevImg.getCvImage());
        cv::Mat currMat = cv::cvarrToMat(threadVars.currImg.getCvImage());
        cv::Mat threadMat = cv::cvarrToMat(threadVars.mat);
        cv::calcOpticalFlowFarneback(prevMat, currMat,
                                   threadMat,
                                   0.15, 2,
                                   3, 2, 3,
                                   0.8, 0);

Where threadVars.prevImg and threadVars.currImg are ofxCvGrayscaleImage
and threadVars.mat is CvMat* mat;