Ask Your Question
0

OpenCV on Raspberry Pi2 Using 25% CPU

asked 2015-09-13 15:25:10 -0600

Hi, I am trying to run Opencv on a raspberry pi 2 with Python and the Pi camera. If I have the minimum code to pull a video stream from the camera I get a solid 30 FPS with 640x480. The problem is that if I add any processing to it the frame rate drops dramatically but the CPU usage only goes up by around 5%. The overall usage will not exceed 25%. If I open up top I can see that individual cores go above that no problem but never at once.

image description

This is what it displays when the program is running.

edit retag flag offensive close merge delete

Comments

Can you be more specific. What kind of 'processing'?

boaz001 gravatar imageboaz001 ( 2015-09-14 05:00:44 -0600 )edit

I will post the code when I can. But it is just a basic object tracking program for now. Uses edge detection to find a square and put a box around it.

Cold_Turkey gravatar imageCold_Turkey ( 2015-09-14 07:47:55 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-09-16 05:18:02 -0600

mshabunin gravatar image

Make sure your OpenCV library is built with parallel framework support (TBB, OpenMP, pthreads). Run print cv2.getBuildInformation() in python interpreter and find corresponding line in the output.

Even in case when parallel framework has been enabled, some algorithms could be implemented without multithreading support.

Not sure, but it could help: try to call cv2.setNumThreads(4) to set number of threads explicitly.

__Note:__ all the above advices are compatible with OpenCV 3.x, version 2.4 uses slightly different python module naming

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-09-13 15:25:10 -0600

Seen: 1,546 times

Last updated: Sep 16 '15