Python Library For Computing Spatial Derivatives Of Optical Flow
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 spat
Solution 1:
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 the y
.
I'd attempt to solve the problem like so:
- Split your flow array/matrix into two matrices:
x
andy
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.
Post a Comment for "Python Library For Computing Spatial Derivatives Of Optical Flow"