lluvia icon indicating copy to clipboard operation
lluvia copied to clipboard

How to get optical flow magnitude?

Open qraleq opened this issue 3 years ago • 1 comments

Hi,

I saw your demo video here: https://www.youtube.com/watch?v=mRZ6YdWb8fE, and I'm interested in how did you produce the magnitude plot? Can you please provide the code sample for that demo?

Thank you!

qraleq avatar Jun 21 '22 11:06 qraleq

Hi @qraleq,

Thanks for your interest in the project.

I generated the video using the lluvia Python library in a Jupyter notebook, quite messy at the moment due to the loading and storing of the camera data. I will prepare a new one in Colab and share it here.

In the meantime, regarding the actual computation of the flow magnitude, I performed that computation in CPU using numpy's norm function:

out_flow = node.getPort('out_flow').toHost()
flow_norm = np.linalg.norm(out_flow, axis=2)

where node is the Node representing the FlowFilter graph. out_flow is a standard ndarray [height, width, 2]. For the plotting I used:

plt.imshow(flow_norm, vmin=0, vmax=max_flow, cmap='inferno')

Does it answer your question?

jadarve avatar Jun 24 '22 22:06 jadarve

Closing as inactive. Please reopen the issue or create a new one if the issue persists.

jadarve avatar Jul 22 '23 21:07 jadarve