If I want OpenCV to use all the cores in my computer, do I have to compile it myself or can I do this with apt-get?

asked 2016-01-10 17:57:34 -0600

jackbrucesimspon gravatar image

I've been using OpenCV on the Raspberry Pi 2 (4 cores). I installed it with apt-get, yet whenever I use OpenCV via Python it only ever uses 25% of my CPU potential (1 core). Is there a way to install OpenCV via apt-get that allows me to utilise threading in the library methods or will I have to compile it myself as apt-get is unable to do this? I get the impression that this isn't occurring because even when I call OpenCV methods like haar cascade, the CPU load never goes beyond utilising a single core.

I understand that Python has the GIL, but I'm I'm I'm curious about whether the methods that I'm calling from OpenCV will be utilising all 4 cores of my machine, even if I haven't compiled it myself with the multithreading flag (as I've installed it with apt-get).

edit retag flag offensive close merge delete

Comments

apt-get is purely for installing stuff, not for configuration. So it depends what support was built into your OpenCV installation. Best thing to do is to build yourself and like you said, enable multithreading explicitly. Check this SO thread for more info on the correct flags that need to be set.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-11 04:15:58 -0600 )edit