roh*_*was 8 c++ opencv assertion mat
我试图在OpenCV(C++)中使用以下函数
calcOpticalFlowPyrLK(prev_frame_gray, frame_gray, points[0], points[1], status, err, winSize, 3, termcrit, 0, 0.001);
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
OpenCV Error: Assertion failed ((npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0) in calcOpticalFlowPyrLK,
file /home/rohit/OpenCV_src/opencv-2.4.9/modules/video/src/lkpyramid.cpp, line 845
terminate called after throwing an instance of 'cv::Exception'
what(): /home/rohit/OpenCV_src/opencv-2.4.9/modules/video/src/lkpyramid.cpp:845:
error: (-215) (npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0 in function calcOpticalFlowPyrLK
Run Code Online (Sandbox Code Playgroud)
以下两个都返回-1
frame_gray.checkVector(2, CV_32F, true)
prev_frame_gray.checkVector(2, CV_32F, true)
Run Code Online (Sandbox Code Playgroud)
我想知道checkVector实际上做了什么,因为它会导致断言错误,如上所示.
Kor*_*nel 15
官方OpenCV的文档说:
cv::Mat::checkVector()如果矩阵是1通道(N x ptdim)或ptdim通道(1 x N)或(N x 1),则返回N; 否则为负数
OpenCV的考虑等同于即某些功能的情况下某些数据类型objectPoints的cv::solvePnP()可以是:
cv::Mat cv::Mat std::vector<cv::Point3f>有了checkVector你可以确保你是通过你的数据的正确表示.