Opencv on Raspberry pi

Cross compiling OpenCV 4 for Raspberry Pi

I recommend that you do the build in a Debian Buster virtual machine or a Docker container in order to not mess your system.

Build Step

run -it --name opencv  -v $(pwd):/build arm_builder

Cross compiling OpenCV 4 for Raspberry Pi Zero

Unfortunately the crossbuild-essential-armhf from Debian will not generate working binaries for Raspberry Pi Zero, so we can’t use the cross compilation procedure… In order to cross compile OpenCV, we are going to use a slightly more involved procedure, in which we’ll basically emulate an ARM processor on a more powerful x86-64 Debian….t is much slower than the [cross compilation] approach. Please note that, even with an emulated ARM architecture, cross compiling OpenCV is much faster than building directly on a Raspberry Pi Zero where it could take days, assuming that the build doesn’t fail because of the limited amount of RAM on the Pi Zero.

Running Raspbian on x86 docker

Written on August 15, 2019, Last update on February 17, 2021
opencv raspberry-pi arm docker cross-compile