如何从密集光流中提取速度矢量?
问题:我正在尝试对齐移动视频的两帧。
我目前正在尝试使用函数“cvCalcOpticalFlowLK”,结果以“CvArr”的形式输出 x 和 y 的速度向量。
所以我得到了结果,但我不知道如何使用这些向量数组。
我的问题是......我如何知道每个像素的速度是多少?它只是该特定点的每个像素值的值吗?
注意:我会使用其他光流函数,例如 cvCalcOpticalFlowPyrLK(),因为它更容易,但我想要密集的光流。
Problem: I'm trying to align two frames of a moving video.
I'm currently trying to use the function "cvCalcOpticalFlowLK" and the result outputs velocity vectors of x and y in the form of a "CvArr".
So I obtained the result, but i'm not sure how to use these vector arrays.
My question is this... how do i know what is the velocity of each pixel? Is it just the value of each pixel value at that particular point?
Note: I would've used the other optical flow functions such as cvCalcOpticalFlowPyrLK() as it is much easier, but i want the dense optical flow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
显然我最初的假设是正确的。光流函数的“velx”和“vely”输出是每个像素值的实际速度。为了最好地提取它们,我从原始数据中访问了像素并提取了值。有两种方法可以做到这一点。
cvGet2D()——这种方式速度较慢,但如果您只需要访问 1 个像素,那就没问题。
或
(uchar*)(图像->imageData + height*image->widthStep + width);
(图像是IplImage,宽度和高度只是图像对应的宽度和高度)
Apparently my original assumption was true. The "velx" and "vely" outputs from the optical flow function are the actual velocities for each pixel value. To best extract them, I accessed the pixel from the raw data and pulled the value. There are 2 ways to do this.
cvGet2D() -- this way is slower but if you only need to access 1 pixel it's okay.
or
(uchar*)(image->imageData + height*image->widthStep + width);
(image is an IplImage, width and height are just the corresponding widths and heights of the image)
如果您需要每个像素的运动矢量,那么您需要计算所谓的“密集光流”。从 openCV 2.1 开始,有一个函数可以做到这一点:calcOpticalFlowFarneback。
请参阅下面的链接:
http://opencv.itseez.com/modules /video/doc/motion_analysis_and_object_tracking.html?highlight=calcopticalflowfarneback#cv2.calcOpticalFlowFarneback
If you need the motion vectors for each pixel, then you need to compute what's called 'dense optical flow'. Starting from openCV 2.1, there is a function to do exactly that: calcOpticalFlowFarneback.
See the link below:
http://opencv.itseez.com/modules/video/doc/motion_analysis_and_object_tracking.html?highlight=calcopticalflowfarneback#cv2.calcOpticalFlowFarneback
velx 和 vely 是光流而不是实际速度。
您使用的方法已过时。使用这个calcOpticalFlowFarneback()
velx and vely are optical flow not the actual velocity.
The method you used is Obsolete. Use this calcOpticalFlowFarneback()