-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Improve sparse pyrLK optical flow #5771
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
Conversation
float x = prevPt.x + xBase + 0.5f; | ||
float y = prevPt.y + yBase + 0.5f; | ||
|
||
I_patch[i][j] = ToFloat<T>(I(x, y)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be I(y, x)
, here and below. PtrStepSz
uses (y, x)
coordinates order.
@Jet47, since you are looking at it anyway, let me assign it to you |
Thanks for reviewing this! I believe I've addressed all of your comments except for conversion to [0,1] range. It's not clear if you're referring to the 3 channel non texture fetch code path or the int32_t textures. |
texture<ushort4, cudaTextureType2D, cudaReadModeNormalizedFloat> tex_I16UC4(false, cudaFilterModeLinear, cudaAddressModeClamp); | ||
|
||
texture<int, cudaTextureType2D, cudaReadModeElementType> tex_I32S(false, cudaFilterModePoint, cudaAddressModeClamp); | ||
texture<int4, cudaTextureType2D, cudaReadModeElementType> tex_I32SC4(false, cudaFilterModePoint, cudaAddressModeClamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove textures that are not used (ushort
, int
and int4
).
I've got the following compilation errors on my machine:
|
Could you tell me a bit more about your machine? |
I was able to build it on my machine (Ubuntu 12.04, GCC 4.6, CUDA 7.0) after some modifications. See But now I have sanity test failures. To reproduce them download opencv_extra repository from https://github.com/Itseez/opencv_extra and run the following command:
Test log:
|
I've integrated the patch that you created. It seems to work fine so I'll push that soon. If I understand the sanity check code correctly, it's basically doing some statistics on the tracked points as detected by optical flow. If so, is it reasonable to assume there might be a bit of a difference in values due to the different texture fetch methods? IE cudaReadModeElement vs cudaReadModeNormalizedFloat. If I change the sanity test to pass in a float image and a float BGRA image then the test passes. Would that be sufficient? How were the expected values determined in the performance test? Was it generated by the cpu or gpu optical flow code? Was it verified to be correct? I ask because one of the expected min values is -0.0052967071533203125 which is outside of the image. Should I generate new truth data and more tests for the different datatypes? |
return ret; | ||
} | ||
|
||
template <int cn, int PATCH_X, int PATCH_Y, bool calcErr, typename T = float> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use default template parameters for functions (typename T = float
). It is C++0x feature. Just remove = float
, the code should compile without it.
Yes, your solution is OK.
The expected values were generated by the same GPU code for previous run. It is a simple regression test that compares current results with previous launches. |
Is there anything left that I need to do for this? |
👍 |
Thank you for your contribution! |
@dtmoodie Could you please squash commits into one to remove useless intermediate changes? In case of problems try to follow this opencv/opencv_contrib#290 (comment). Also feel free to ask for help. |
Sure thing, working on squashing now. It looks like tortoiseGit doesn't want to squash due to the way I had the repo setup. I'll have the squash finished and double checked in a bit. |
… which thus allows caching of image pyramids on successive calls. Added unsigned char support for 1, 3, 4 channel images.
Well done! 👍 |
now we only need |
Modified sparse pyrlk optical flow to allow input of an image pyramid, which thus allows caching of image pyramids on successive calls.
Added uchar support for 1 and 4 channel images.
Preliminary 3 channel support, unsigned short and int support.