delmottea / libCMT

c++ port of the python code from https://github.com/gnebehay/CMT
BSD 3-Clause "New" or "Revised" License
67 stars 45 forks source link

Runtime error in track() #1

Open pthtruc opened 10 years ago

pthtruc commented 10 years ago

Runtime error in track(), at line cv::calcOpticalFlowPyrLK(im_gray, im_prev, nextPts, pts_back, status_back, err_back);

happened at frame_0002 (attached); tracker is initialized with frame_0001 and topleft = (49, 114), bottomright = ( 531, 275).

frame_0001 frame_0002

delmottea commented 10 years ago

I got an error with your 2 images, but not at the same position than you (the error happened when all the detected features are in the selected area and no one outside), I committed an update on CMT.cpp and it works with your 2 images on my computer. Can you try again and say me if it works?

Do you call cmt.initialise on the first frame before calling cmt.processFrame?

thanks

pthtruc commented 10 years ago

It works on the two images and some other videos! Yes, I did call cmt.initalise(im, topleft, bottomright) on the first frame.

In my codes, I just add the below since those two are not defined in C/C++. Do you think it makes any difference?

define NAN (INT_MIN)

define isnan(x) ( ((x)==NAN)? 1: 0 )

delmottea commented 10 years ago

INT_MIN may not be the best for define NAN but maybe it works. The best solution is to compile with c++11 that defines NAN I made a new commit with compatibility code that I have found on internet, it should work but maybe it's dependent of the compiler.

pthtruc commented 10 years ago

Thank you, delmottea, for your great work! Quick questions:

delmottea commented 10 years ago

I've added nbInitialKeypoints = 0 in the constructor so you can use it to check if it's initialized. and thanks for the CV_PI constant, I didn't thought to use it