My team is trying to run vision tracking on our Raspberry Pi for the lifts. We wanted to record the video output so we could debug in real time just in case something went wrong during a match, but OpenCV doesn’t run the commands related to the VideoWriter class. There aren’t any errors that come from the shell, but the program literally skips over those lines of code. Has anyone else had any problems similar to this on the pi? Do you know how to fix this error?
Thanks,
Jonathan Daniel
Head Programmer
Fernbank LINKS Robotics
The wpilib opencv artifacts are not compiled with non-free codec support. Because of this, both VideoWriter and VideoCapture do not support reading or writing from encoded streams such as Avi or mpeg-4. You will need to write individual frames as jpegs using imwrite if you want to write frames.
Does it work using MPJEG as the codec type for VideoWriter? We’ve done that before as an alternative to tying up CPU cycles trying to do H264 or whatever encoding on the fly.
Be careful with MJPEG for recording on an embedded arm device. MJPEG is bitrate hungry and ranges anywhere from 10x to 20x larger than something like h264 or v8. This can easily saturate your SD card’s throughput.
WebM might be an option. Another possibility is to use the v4l2-loopback and gstreamer to record locally with x264 in a separate thread, while having your vision processing run on a forked stream.