Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Error: Assertion failed (prevPyr[level * lvlStep1].size() == nextPyr[level * lvlStep2].size()) in void cv::calcOpticalFlowPyrLK

I am working on 2 images, on the first one i found goodFeaturesToTrack and draw it then on it, i am trying to to tracking with that to the second image but the line of calling calcOpticalFlowPyrLK gets an error:

error(): OpenCV Error: Assertion failed (prevPyr[level * lvlStep1].size() == nextPyr[level * lvlStep2].size()) in void  cv::calcOpticalFlowPyrLK(InputArray, InputArray, InputArray, InputOutputArray, OutputArray, OutputArray, Size, int, cv::TermCriteria, int, double), file /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/video/src/lkpyramid.cpp, line 979

And i do not understand what the proble, is.

    MatOfPoint2f prevPts = new MatOfPoint2f();
    MatOfPoint2f nextPts = new MatOfPoint2f();
    MatOfByte status = new MatOfByte();
    MatOfFloat err = new MatOfFloat();
    //when to stop
    TermCriteria optical_flow_termination_criteria=new TermCriteria();
    optical_flow_termination_criteria.epsilon=0.3;
    optical_flow_termination_criteria.maxCount =20;
    int maxlevel = 2;
    Size s = new Size( 21, 21);


    MatOfPoint corners = new MatOfPoint();
    Imgproc.goodFeaturesToTrack(tmp,corners,maxCorners,qualityLevel,minDistance,newMat(),blockSize,
  useHarrisDetector,k);

    org.opencv.core.Point[] points = corners.toArray();
    for (org.opencv.core.Point p : points) {
        Core.circle(tmp2, p, 8, circleColor);
    }

    corners.convertTo(prevPts, CvType.CV_32FC2);

    Video.calcOpticalFlowPyrLK(tmp, secondtmp, prevPts, nextPts, status, err,s,maxlevel,optical_flow_termination_criteria,2,1);

Thank in advance!!

OpenCV Error: Assertion failed (prevPyr[level * lvlStep1].size() == nextPyr[level * lvlStep2].size()) in void cv::calcOpticalFlowPyrLK

I am working on 2 images, on the first one i found goodFeaturesToTrack and draw it then on it, i am trying to to tracking with that to the second image but the line of calling calcOpticalFlowPyrLK gets an error:

error(): OpenCV Error: Assertion failed (prevPyr[level * lvlStep1].size() == nextPyr[level * lvlStep2].size()) in void  cv::calcOpticalFlowPyrLK(InputArray, InputArray, InputArray, InputOutputArray, OutputArray, OutputArray, Size, int, cv::TermCriteria, int, double), file /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/video/src/lkpyramid.cpp, line 979

And i do not understand what the proble, is.

    MatOfPoint2f prevPts = new MatOfPoint2f();
    MatOfPoint2f nextPts = new MatOfPoint2f();
    MatOfByte status = new MatOfByte();
    MatOfFloat err = new MatOfFloat();
    //when to stop
    TermCriteria optical_flow_termination_criteria=new TermCriteria();
    optical_flow_termination_criteria.epsilon=0.3;
    optical_flow_termination_criteria.maxCount =20;
    int maxlevel = 2;
    Size s = new Size( 21, 21);


    MatOfPoint corners = new MatOfPoint();
    Imgproc.goodFeaturesToTrack(tmp,corners,maxCorners,qualityLevel,minDistance,newMat(),blockSize,
  useHarrisDetector,k);

    org.opencv.core.Point[] points = corners.toArray();
    for (org.opencv.core.Point p : points) {
        Core.circle(tmp2, p, 8, circleColor);
    }

    corners.convertTo(prevPts, CvType.CV_32FC2);

    Video.calcOpticalFlowPyrLK(tmp, secondtmp, prevPts, nextPts, status, err,s,maxlevel,optical_flow_termination_criteria,2,1);

Thank in advance!!