Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setFeatures / getFeatures logic for FlowPyrLK #222

Open
ofZach opened this issue Jun 4, 2017 · 2 comments
Open

setFeatures / getFeatures logic for FlowPyrLK #222

ofZach opened this issue Jun 4, 2017 · 2 comments

Comments

@ofZach
Copy link

ofZach commented Jun 4, 2017

I am seeing an issue where when I set features before calling flow and read the features back they are the same. I can see that the features are actually changing when I trace it out:


            for (int i = 0; i < prevPts.size(); i++){
                cout << " prevPts " << i << " " << prevPts[i].x << " " << prevPts[i].y << endl;
            }
            
#if CV_MAJOR_VERSION>=2 && (CV_MINOR_VERSION>4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION>=1))
			if (prevPyramid.empty()) {
				buildOpticalFlowPyramid(prev,prevPyramid,cv::Size(windowSize, windowSize),10);
			}
			buildOpticalFlowPyramid(next,pyramid,cv::Size(windowSize, windowSize),10);
			calcOpticalFlowPyrLK(prevPyramid,
                                 pyramid,
                                 prevPts,
                                 nextPts,
                                 status,
                                 err,
                                 cv::Size(windowSize, windowSize),
                                 maxLevel);
			prevPyramid = pyramid;
			pyramid.clear();
            
            for (int i = 0; i < nextPts.size(); i++){
                cout << " nextPts " << i << " " << nextPts[i].x << " " << nextPts[i].y << endl;
            }

you see things like:

 prevPts 0 870 976
 prevPts 1 990 1100
 nextPts 0 870.315 976.232
 nextPts 1 983.649 1096.83

I feel like the error is here:

	vector<ofPoint> FlowPyrLK::getFeatures(){
		ofPolyline poly =toOf(prevPts);
		return poly.getVertices();
	}

where it should be returning nextPts (which are changed after flow calculation not before) but I'm not 100% sure I understand the swapping logic to know if this change would have some other bad side effects.

@ofZach
Copy link
Author

ofZach commented Jun 4, 2017

I guess "getCurrent" would give back the right results, but what is the difference between getCurrent() and getFeatures() ? maybe the api is a little unclear here? I suspected from naming I could use setFeatures(), calcFlow() then getFeatures()....

@kylemcdonald
Copy link
Owner

@obviousjim wrote this part of ofxCv he might be able to provide some clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants