OpenCV Optical Flow Approval

I am trying to track landmarks along the facial features obtained through dsift using python 2.7 and openCV 2.4.11. I want to track these functions between frames.

However, I get the following error. I checked the input images as single-channel equal sizes (and unsigned 8-bit type), as well as with the previous points:

OpenCV Error: Assertion failed ((npoints = prevPtsMat.checkVector(2, CV_32F, tru e)) >= 0) in cv::calcOpticalFlowPyrLK, file ..\..\..\modules\video\src\lkpyramid.cpp cv2.error: ..\..\..\modules\video\src\lkpyramid.cpp:845: error: (-215) (npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0 in function cv::calcOpticalFlowP yrLK 

The resulting string:

 new_pts, ttl, err = cv2.calcOpticalFlowPyrLK(self.old_img, i_img, i_old_pts, None) 

Does anyone know where I can start debugging this?

+5
source share
1 answer

I had the same problem when I watched the optical stream. I tried many different ways to solve this problem. But in vain.

Finally, there was an example program in which they tracked the use of the shi-tomsi definition of corner points, and these points were used in the LK algorithm, and it worked perfectly. Therefore, I examined the data types and output sizes of the Shi-Tomsi detector, and I made sure that my points that need to be tracked are of the same type. It hurt!

Here is what you need to know.

  • make sure the images are grayscale.
  • your coordinate parameter, which is i_old_pts, should be a single precision floating point, meaning float32. This type is available when using numpy. pyat float - float64
  • the coordinate parameter i_old_pts (from your program) should be a numpy array with size (n, 1,2), where n represents the number of points.

That should work.

+9
source

Source: https://habr.com/ru/post/1239543/


All Articles