can not input a List<Mat> pyramid into calcOpticalFlowPyrLK (OpenCV-2.4.8-android-sdk) (Bug #3509)


Added by Xin Guo about 11 years ago. Updated about 11 years ago.


Status:Cancelled Start date:2014-01-28
Priority:Normal Due date:
Assignee:Alexander Smorkalov % Done:

0%

Category:android
Target version:-
Affected version:2.4.8 (latest release) Operating System:Windows
Difficulty: HW Platform:x64
Pull request:

Description

The function of buildOpticalFlowPyramid and calcOpticalFlowPyrLK in OpenCV-2.4.8-android-sdk is:

public static int buildOpticalFlowPyramid(Mat img, List<Mat> pyramid, Size winSize, int maxLevel)

public static void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, MatOfPoint2f prevPts, MatOfPoint2f nextPts, MatOfByte status, MatOfFloat err, Size winSize, int maxLevel, TermCriteria criteria, int flags, double minEigThreshold)

If I just use the image as the input of calcOpticalFlowPyrLK, not using pyramid, it works well. But If I use buildOpticalFlowPyramid to bulid a pyramid as input of calcOpticalFlowPyrLK. The List<Mat> pyramid is not applicable for Mat prevImg.

If I declare the pyramid as vector<Mat>, buildOpticalFlowPyramid works well, but the app will be forced to stop whenever call calcOpticalFlowPyrLK.

Here is parts of the code.

MatOfByte status = new MatOfByte();
int maxlevel=2;
Mat prev = new Mat(mRgba.size(),CvType.CV_8UC1);
Mat curr = new Mat(mRgba.size(),CvType.CV_8UC1);
List&lt;Mat&gt; pyramid1= new ArrayList&lt;Mat&gt;(maxlevel);
List&lt;Mat&gt; pyramid2= new ArrayList&lt;Mat&gt;(maxlevel);
Mat pyramid3 = new Mat();
Mat pyramid4 = new Mat();
MatOfPoint2f featurestracked = new MatOfPoint2f();
MatOfFloat err = new MatOfFloat();
int i,count;
TermCriteria optical_flow_termination_criteria =new TermCriteria();
optical_flow_termination_criteria.epsilon =.03;
optical_flow_termination_criteria.maxCount = 20;
Size winSize = new Size(21,21);
Imgproc.cvtColor(hp.TrackingFrame, prev, Imgproc.COLOR_RGBA2GRAY,0);
Imgproc.cvtColor(mRgba, curr, Imgproc.COLOR_RGBA2GRAY,0);
//Build pyramid
int level1= Video.buildOpticalFlowPyramid(prev, pyramid1, winSize, maxlevel);
int level2 = Video.buildOpticalFlowPyramid(curr, pyramid2, winSize, maxlevel);
pyramid3 = Converters.vector_Mat_to_Mat(pyramid1);
pyramid4 = Converters.vector_Mat_to_Mat(pyramid2);
MatOfPoint2f features_next2f = new MatOfPoint2f(hp.features_next.toArray());
Video.calcOpticalFlowPyrLK(pyramid3, pyramid4,features_next2f,featurestracked,status,err, winSize,maxlevel,optical_flow_termination_criteria, 0, 0.001);

History

Updated by Vladislav Vinogradov about 11 years ago

Closed as duplicate for http://code.opencv.org/issues/3508.

  • Status changed from New to Cancelled

Also available in: Atom PDF