OpenCV is the most popular (and, in my opinion, most powerful too) image processing framework available. And even better: it's open-source and free to use (including in comercial solutions)!
Although, compiling OpenCV can be something a little bit tricky for some platforms. Therefore, this post/article will show how to compile OpenCV in your Raspberry PI, making things easier for you and saving your time for cool computer vision projects.
Here are some recommendations about this process:
- Use a reliable power source. This process requires a lot of computer resources (CPU processing and memory usage), so using a non-reliable power source may cause Raspberry PI stop working (shutdown due to insuficient power sourcing or something like that).
- Don't use a fanless Raspberry PI case. As this process required a lot of computer resources, the processor will easily get hot. Therefore, keeping your Raspberry PI in a fanless case may cause shutdown for high processor temperature.
- I strongly recommend class 10 SD Card usage. This process requires a lot of file access (as every compilation of big softwares), so using class 10 SD Card will reduce compilation time a lot.
The full process comprises:
- Installing dependencies / necessary packages
- Download of OpenCV source-code
- Compile OpenCV source-code
- Install compiled OpenCV library
In order to make it easier for you, I've created a shell script (it's in code session of this post/article ). This shell script automatically does everything needed, so all you have to do is give execution permission to the script and execute it on your Raspberry PI as sudo.
In another words, all you need is put this script into Raspberry PI's memory (in your home folder) and use the following commands:
chmod +x OpenCV_CompileAndInstallScript.sh sudo ./OpenCV_CompileAndInstallScript
That's it! Just wait the end of the proccess and you're ready to use OpenCV.
- Tthe whole process will take some hours to complete. So, a good tip is using overnight period to do this.
- This script also prepares Python wrappers for OpenCV. It means that, after doing this process, you can make projects using Python and OpenCV.