-
Notifications
You must be signed in to change notification settings - Fork 8
OpenCV
OpenCV is not necessary for this project, but for those who so choose, here are some notes (particularly for OpenCV in Python):
Normally, you don't want (or need) to compile OpenCV on an embedded system as that would take hours and is needlessly difficult. For OpenCV in Python in general I simply use opencv-python.
python3 -m pip install opencv-python
If you get hash mismatch errors, this could be that piwheels.org messed up the file signature. Normally this is a security feature, but once in a while piwheels.org has a mistaken signature uploaded. The workaround for this is to download the file opencv_python-3.4.3.18-cp37-cp37m-linux_armv6l.whl from https://www.piwheels.org/project/opencv-python/ and then install the file with python3 -m pip install opencv_python-3.4.3.18-cp37-cp37m-linux_armv6l.whl
If you get various import errors or library missing errors with import cv2
, here are the usual libraries you need:
apt install libatlas-base-dev libwebp-dev libtiff-dev libjasper-dev libilmbase-dev libopenexr-dev libgstreamer1.0-dev libavcodec-dev libavformat-dev libswscale-dev libqtgui4 libqt4-test
OpenCV's VideoWriter function will happily and silently fail, writing empty files (or none at all) if it is not initialized correctly.
import cv2
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
hv = cv2.VideoWriter('my.avi', fourcc, fps=10, frameSize=(640, 480))
for img in imgs:
hv.write(img)
hv.release()
The "frameSize" is best set programatically (.shape of your image) because VideoWriter will silently fail and write empty files if it's not exactly right.