How to get optical flow magnitude?
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!
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?
Closing as inactive. Please reopen the issue or create a new one if the issue persists.