Hello,
has anybody written some example code for Lucas Kanade Flow, yet?
At the moment i use fcvCornerFast9u8 to detect Feature and now i wll use fcvTrackLKOpticalFlowu8
to calculate the position of the features in the second image.
Sadly i can find nowhere some example code for fastCV Lucas Kanade. The are much more parameters than in OpenCV :-(
Best regards Ari Kaspari
Optical Flow Lucas Kanade fcvTrackLKOpticalFlowu8
Posted: Sun, 2013-02-10 03:55
Hope the following snippet helps. By the way, there are some fixes for fcvTrackLKOpticalFlowu8 in the upcoming FastCV 1.2.0 release to improve tracking performance. The release should come out very soon.
//Initialize pyramid structures
src1Pyr = new fcvPyramidLevel[nPyramidLevels];
src2Pyr = new fcvPyramidLevel[nPyramidLevels];
dx1Pyr = new fcvPyramidLevel[nPyramidLevels];
dy1Pyr = new fcvPyramidLevel[nPyramidLevels];
fcvPyramidAllocate( src1Pyr, width, height, 4, nPyramidLevels, 0 );
fcvPyramidAllocate( src2Pyr, width, height, 4, nPyramidLevels, 0 );
fcvPyramidAllocate( dx1Pyr, width, height, 4, nPyramidLevels, 1 );
fcvPyramidAllocate( dy1Pyr, width, height, 4, nPyramidLevels, 1 );
fcvPyramidCreateu8( src1, width, height, nPyramidLevels, src1Pyr );
fcvPyramidCreateu8( src2, width, height, nPyramidLevels, src2Pyr );
fcvPyramidSobelGradientCreatei8( src1Pyr, dx1Pyr, dy1Pyr, nPyramidLevels );
fcvTrackLKOpticalFlowu8(
src1, src2, width, height,
src1Pyr, src2Pyr,
dx1Pyr, dy1Pyr,
(float *) featureXY_in.Ptr(),
(float *) featureXY_out.Ptr(),
(int32_t*)featureStatus_in.Ptr(),
featureXY_in.Shape().height,
windowWidth, windowHeight,
maxIterations, nPyramidLevels,
maxResidue, minDisplacement, 0, 0 );
Try to set each featureStatus[i] to '0' before calling fcvTrackLKOpticalFlowu8
I found that fcvTrackLKOpticalFlowu8 doesn't operate on features[i] where featureStatus[i] < 1
I guess that featureStatus is an in AND out parameter, meaning that it works in both directions, so if a some featureStatus[i] gets '-5' for large_residual it (feature number i) will never get processed again unless you set it's status before calling LK.
It took me almost 3 days to figure this out, but I'm still not sure whether it's a bug or feature. The doc doesn't say if it's an input or/and output parameter.
Hi guys,
I guess I'm confused a bit. Is the featureXY_in the result from fcvCornerFast9u8() hardcasted from (uint32_t *) to (float *)?
Hi Everyone,
I awant to track some key points, from a reference src in a current src.
I am first extracting keypoints from reference src using fcvCornerHarrisu8, getting corner's array, and passing refrence src, current src, extracted corner's array, in fcvTrackLKOpticalFlowu8, in which i expect that the other array which i passed will get filled for the matched key points in the current frame.
I am not getting the correct result, by feature status is coming negative, what is the significance of this corner status?
Does it require that the src1 and src2 have to be of same width and height?
Is the array filled for current frame have one-t-one correspondence from the array passed for the refrence frame.
Please help in getting my doubt cleared.
thanks
Sourav
src1 and src2 have the same dimension. The parameter list has been cleaned up and made more clear in fcvTrackLKOpticalFlowu8_v2, please use that version and make sure inputs are filled properly.