1
votes

I am trying to use calcOpticalFlowPyrLK for feature tracking. Function is used as follows

TermCriteria termcrit(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03);

Size winSize(31,31);

vector < uchar > status;

vector < float > err;

calcOpticalFlowPyrLK(prevGray, gray, point[0], point[1], status, err, winSize, 3, termcrit, 0, 0, 0.001);

All the parameter are correct. In point[0] there are already given set of points. But while i try to execute the program it gives following error. I am using Visual C++ 2010.

.....................................

First-chance exception at 0x74c426df (msvcr100.dll) in GFFER.exe: 0xC0000005: Access violation writing location 0x058fe000. Unhandled exception at 0x74c426df (msvcr100.dll) in GFFER.exe: 0xC0000005: Access violation writing location 0x058fe000.

.....................................

Do you have any idea how can i resolve this problem.

Thanks in advance!!

1
Check that prevGray, gray, are initialized appropriately. Same too for the vector of 2D points. You should provide the code where you initialize these variables to give more context to your problem. At present, the error suggests that you code is trying to access memory that was probably not allocated. But it is hard to tell just from the few lines of code you gave.lightalchemist
I had a similar issue that was resolved by switching from debug to release. Although I'm not sure what the root cause of the problem was or why this fixed it.NickF

1 Answers

0
votes

Access violation writing location

The error seems to occur when writing data to a location which is not initialized. In your code, point[1], status and err are the only locations where a write occurs.

status and err and defined correctly. The problem must be with point[1]. Is it of the type vector<Point2f>.

Why don't you try using two separate vectors instead of an array of vectors, say, point0 point1.