用于计算光流空间导数的Python库
我正在尝试使用 Python 中的 OpenCV 从视频计算差分图像速度不变量(例如旋度、发散、变形等)。为此,我需要计算光流 x、y 方向的空间导数。不幸的是,OpenCV 似乎只提供计算光流的 API,而不提供其衍生产品。
有没有用于计算光流的空间导数的Python库?我发现这个SO问题有点类似Lucas Kanade 光流,方向向量,并且该人编写了用于计算空间导数的代码,但如果可能的话,我会喜欢一个库而不是编写我自己编码。任何建议将不胜感激!
I'm trying to compute a differential image velocity invariants (e.g. curl, divergence, deformation, etc) from a video using OpenCV in Python. To do that, I need to compute the spatial derivatives in the x,y directions of the optical flow. Unfortunately, OpenCV only seems to supply the APIs for computing optical flow, not its derivative.
Are there any Python libraries out there for computing spatial derivatives of optical flow? I found this SO question that was somewhat similar Lucas Kanade Optical Flow, Direction Vector, and there is code the person wrote for computing spatial derivatives, but if at all possible I'd love a library rather than writing the code myself. Any suggestions would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我的看法(我对光流进行了一些工作):
您想要计算光流场的各个偏导数;一个用于
x
方向,一个用于y
方向。我尝试像这样解决问题:
x
和y
流。derivative = current_state - last_state
。但这种方法非常混乱,因为导数将对最轻微的误差很敏感。只需区分近似曲线即可。
您还可以仅平滑各个矩阵并进行幼稚差异,这应该比近似数据点快得多,但应该更能容忍错误。
This is the way I see it (I've worked with optical flow a little bit):
You want to compute the individual partial derivatives of the optical flow field; one for the
x
direction, and one for they
.I'd attempt to solve the problem like so:
x
andy
flow.derivative = current_state - last_state
. But this approach is very messy, as the derivative will be sensitive to the slightest bit of error.The just differentiate that approximated curve and you're good to go.
You could also just smooth individual matrices and do a naive difference, which should be much faster than approximating data points, but should be more tolerant to error.