I try to use cv::calcOpticalFlowPyrLK, but sometimes the internal statement in this function fails. Statement npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0. I am using OpenCV 2.3.1. The source code for this function is available here .
I find it difficult to wrap my head around my code, especially due to my limited experience with computer graphics and the lack of comments. Why does this statement work and what does he say about my problem?
Edit : I call the function as follows:
cv::calcOpticalFlowPyrLK(curBwFrame, prvFrame, features, newFeatures, trackingStatus, errors);
I found out that a vector featuresthat was obtained by calling cv::goodFeaturesToTrack(curBwFrame, features, 5, 0.2, 0.5, skinMask);with a non-blank mask, which seems large enough and a valid image, does not contain any functions. How can this happen?
curBwFrame

skinMask

, :
#include <vector>
#include <cassert>
#include <opencv2\opencv.hpp>
using std::vector;
using namespace cv;
int main() {
vector<Point2f> features;
cv::Mat curBwFrame = imread("curBwFrame.png");
cv::cvtColor(curBwFrame, curBwFrame, CV_RGB2GRAY);
imwrite("test.png", curBwFrame);
cv::Mat skinMask = imread("skinMask.png");
cv::cvtColor(skinMask, skinMask, CV_RGB2GRAY);
imwrite("test.png", skinMask);
cv::goodFeaturesToTrack(curBwFrame, features, 5, 0.2, 0.5, skinMask);
assert(features.size() > 0);
return 0;
}