ViSP  2.9.0
tutorial-klt-tracker.cpp
#include <visp/vpImageConvert.h>
#include <visp/vpKltOpencv.h>
#include <visp/vpDisplayOpenCV.h>
#include <visp/vpVideoReader.h>
int main()
{
#if (VISP_HAVE_OPENCV_VERSION >= 0x010100) && defined(VISP_HAVE_FFMPEG)
try {
vpVideoReader reader;
reader.setFileName("video-postcard.mpeg");
reader.acquire(I);
IplImage * cvI = NULL;
// Display initialisation
vpDisplayOpenCV d(I, 0, 0, "Klt tracking");
vpKltOpencv tracker;
// Set tracker parameters
tracker.setMaxFeatures(200);
tracker.setWindowSize(10);
tracker.setQuality(0.01);
tracker.setMinDistance(15);
tracker.setHarrisFreeParameter(0.04);
tracker.setBlockSize(9);
tracker.setUseHarris(1);
tracker.setPyramidLevels(3);
// Initialise the tracking
tracker.initTracking(cvI);
while ( ! reader.end() )
{
reader.acquire(I);
tracker.track(cvI);
tracker.display(I, vpColor::red);
}
cvReleaseImage(&cvI);
return 0;
}
catch(vpException e) {
std::cout << "Catch an exception: " << e << std::endl;
}
#endif
}