用于计算光流空间导数的Python库 [英] Python library for computing spatial derivatives of optical flow

查看:117
本文介绍了用于计算光流空间导数的Python库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Python中的OpenCV从视频计算差分图像速度不变性(例如,卷曲,发散,变形等).为此,我需要计算光流在x,y方向上的空间导数.不幸的是,OpenCV似乎仅提供用于计算光流的API,而不是其派生类.

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.

那里有用于计算光流空间导数的Python库吗?我发现这个SO问题有点类似

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!

推荐答案

这是我看到的方式(我已经使用了光流技术)

This is the way I see it (I've worked with optical flow a little bit):

您要计算光流场的各个偏导数;一个用于x方向,一个用于y.

You want to compute the individual partial derivatives of the optical flow field; one for the x direction, and one for the y.

我会尝试像这样解决问题:

I'd attempt to solve the problem like so:

  • 将流数组/矩阵拆分为两个矩阵:xy流.
  • 对于每种情况,您都可以走幼稚的路线,并做一个简单的区别:derivative = current_state - last_state.但是这种方法非常混乱,因为导数将对一点点的误差敏感.
  • 要解决这个问题,您可以使用易于区分的回归曲线(例如多项式)来近似化您的数据点的一块(也许是整行?).
  • Split your flow array/matrix into two matrices: x and y flow.
  • For each of those, you could go the naive route and just do a simple difference: derivative = current_state - last_state. But this approach is very messy, as the derivative will be sensitive to the slightest bit of error.
  • To counter that, you could approximate one chunk of your data points (maybe a whole row?) with a regression curve that is easily differentiable, like a polynomial.

只需区分近似曲线就可以了.

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.

这篇关于用于计算光流空间导数的Python库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆