VideoCapture capture.read( image ) is not blocking off main thread on Android (Bug #3503)


Added by Arvind Pereira about 11 years ago. Updated over 9 years ago.


Status:Open Start date:2014-01-24
Priority:Normal Due date:
Assignee:Alexander Smorkalov % Done:

0%

Category:highgui-camera
Target version:2.4.10
Affected version:2.4.0 - 2.4.7 Operating System:Android
Difficulty:Medium HW Platform:ARM
Pull request:

Description

I am running OpenCV4Android natively to perform image processing on an Android device running Android OS v 4.2.2. This is a Tegra device. I am reading images in a separate frame grabber thread, which loops around grabbing images and then processing them. I have noticed that when the device is grabbing images, both my process as well as mediaserver consume approximately 20% CPU each. This appears to me to be an issue where OpenCV's video capture device is busy-waiting for the calls to Android's camera driver to return instead of blocking on the I/O call. This in turn is causing the process to waste massive amounts of CPU simply grabbing frames. I confirmed this by commenting out all processing (I was building image pyramids and performing background MOG processing), and found that they were contributing to only an additional 5% CPU over and above grabbing frames.

Ideally, what I would expect is that OpenCV's video capture should simply block on each frame read, thus imposing negligible load on the system beyond what it has already been consuming. i.e. on my device we should have been seeing 20% CPU load on the media-server with single-digit CPU load due to copying those frames and decoding them in videocapture.

It appears that this is an issue on OS-X when the capture device is started off in a non main thread. I suspect this is a similar bug when compiled for Android. Please fix asap - it is stealing too much CPU waiting for frames to become available!


History

Updated by Alexander Smorkalov about 11 years ago

  • Priority changed from Blocker to Normal
  • Assignee set to Alexander Smorkalov

Updated by Andrew Senin about 11 years ago

  • Status changed from New to Open

Updated by Alexander Smorkalov almost 11 years ago

  • Target version changed from 2.4.9 to 2.4.10

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4687

Also available in: Atom PDF