FlowVis
raw JSON → 0.1 verified Sat May 09 auth: no python
A Python package for easy visualization of optical flow fields, providing utilities to convert flow vectors into color-coded images for quick inspection. Current version 0.1, released as an initial alpha with simple generation and display functions; maintenance is sporadic.
pip install flow-vis Common errors
error ImportError: cannot import name 'flow_viz' from 'flow_viz' ↓
cause The correct import is from the module 'flow_vis', not 'flow_viz'. The function is named 'flow_viz' inside 'flow_vis'.
fix
Use: from flow_vis import flow_viz
error ModuleNotFoundError: No module named 'cv2' ↓
cause OpenCV is required but not installed automatically.
fix
Install opencv-python: pip install opencv-python
error ValueError: operands could not be broadcast together with shapes ↓
cause The flow array must have shape (H, W, 2). If you provide a scalar or wrong dimensions, it fails.
fix
Ensure your flow array is a 3D numpy array with last dimension size 2.
Warnings
gotcha The input flow array must be of shape (H, W, 2) with the last dimension containing (dx, dy). The values are not normalized; the function will clip to a default range [-20, 20] pixels. ↓
fix Normalize your flow values to a sensible range (e.g., clip to [-20,20]) or adjust the function's internal parameters.
deprecated The package uses 'cv2' (OpenCV) internally but does not declare it as a hard dependency, causing import errors if OpenCV is missing. ↓
fix Install opencv-python separately: pip install opencv-python.
gotcha The function 'flow_viz' returns an RGB image in uint8 format with values in [0,255]. Do not expect normalized float output. ↓
fix Use the resulting image directly with OpenCV or matplotlib; for float display, convert to float32 and divide by 255.
Imports
- flow_viz wrong
import flow_vizcorrectfrom flow_vis import flow_viz - make_colorwheel
from flow_vis import make_colorwheel
Quickstart
import numpy as np
from flow_vis import flow_viz
# Create a dummy flow field (height, width, 2)
flow = np.random.uniform(-10, 10, (100, 200, 2)).astype(np.float32)
# Visualize
rgb = flow_viz(flow)
# Optionally display using OpenCV
import cv2
cv2.imshow('Optical Flow', rgb)
cv2.waitKey(0)
cv2.destroyAllWindows()