Raspberry Pi video tracking performance is slow

asked 2018-02-25 01:25:16 -0600

bluman855 gravatar image

Hello!

I've been working on a sentry gun project I found on youtube a while back, and I've run into a huge issue. Code I'm using can be found here: https://github.com/atainter/Tracking-...

When nothing is moving in front of the camera, the framerate is good (20+ FPS), but when I move my hand in front of the camera, and it detects it (and draws a bounding box around it) the framerate drops to something like 1 frame per 2 seconds. On the YouTube video itself: https://youtu.be/HoRPWUl_sF8?t=33m57s it shows their turret running at a reasonably high framerate (15+ FPS). The RPi has to process each frame that the camera sends to it, and from the information on the frame, sends a command to the motors on the turret. The problem I have with the framerate is that if its running at 1 frame every 3 seconds then my turret is practically useless because its making one small adjustment every 3 seconds. I'm running OpenCV 3.1.0. Might upgrading OpenCV solve this issue?

edit retag flag offensive close merge delete

Comments

  • it's easy to cheat in videos, and they're only for bragging.
  • profile your app, locate the bottlenecks
  • try a smaller image / camera resolution
  • not all pi's are the same, and the older ones are really slow.
berak gravatar imageberak ( 2018-02-25 04:22:09 -0600 )edit

Thanks for the reply!

-Others have successfully replicated the project shown with the exact code, I think the problem is different.

-I've tried to lower the camera resolution to 100x100px but there was no performance increase.

-I'm using a RPi 3. I know that older models are slow.

Maybe its a problem with my OpenCV installation? Even when the FPS is tanking, CPU usage does not exceed 25%.

bluman855 gravatar imagebluman855 ( 2018-02-25 11:47:25 -0600 )edit
  • "I've tried to lower the camera resolution to 100x100px" -- you have to check the result value from cap.set(...). only specific formats will be supported, 100x100 is unlikely, 320x240 likely.

  • "Maybe its a problem with my OpenCV installation" -- well, how did you do that ? check cv2.getBuildInformation(), for hw support compiled in. tbb, neon ? when in doubt, you'll have to compile your own cv2 locally, with optimisation libs installed before.

  • "Others... " -- ...

berak gravatar imageberak ( 2018-02-25 12:08:27 -0600 )edit

Did you solve the issue ? If yes, then can you share your solution

Vector7 gravatar imageVector7 ( 2018-10-19 18:47:13 -0600 )edit