Ask Your Question
6

How can I make Android Native Camera go faster?

asked 2013-03-04 15:13:50 -0600

xaffeine gravatar image

My VideoCapture loop receives only about 15 FPS on a Nexus 10. Is there any reasonable chance I could increase this up to about 30? If so, how? Logcat messages suggest that 30 FPS is possible. I would like to get frames with as little preprocessing done to them as possible, which should not take much cpu time. Is this a limitation of the native camera implementation? Would the Java camera interface enable higher frame rates?

Here is the relevant code fragment.

cv::VideoCapture reader;

reader.set( CV_CAP_PROP_CONVERT_RGB, 0 );
reader.set( CV_CAP_PROP_FPS, 30 );
reader.open( CV_CAP_ANDROID + 1-camID );
reader.set( CV_CAP_PROP_FRAME_WIDTH, 320 );
reader.set( CV_CAP_PROP_FRAME_HEIGHT, 240 );

cv::Mat frame;
while( !stopRequested() )
{
    //... get time here
    reader >> frame;
    //... record elased time here
    //... ultimately do somthing with the frame here
}
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-03-05 01:52:04 -0600

Your performance results are very strange. Are you sure, that you install right version of OpenCV Manager. You need to use ARM-v7a WITH NEON. Also check performance of tutorial-1 sample. It shows preview FPS and allows to switch Java and Native camera API.

edit flag offensive delete link more

Comments

The tutorial-1 app reports about 15 FPS or less with either the native or the Java camera. I have installed the OpenCV Manager 2.4 and the OCV 2.4 pack armeabi-v7a with Neon, from the google play store. Are you able to get better performance on a Nexus 10? The OS was Android 4.2.1 for my initial tests and is now 4.2.2, which didn't change the results.

xaffeine gravatar imagexaffeine ( 2013-03-05 13:01:07 -0600 )edit

What is camera resolution in tutorial-1? What is your lighting conditions? Camera increase exposure time and decreases frame rate if lighting is not enough. Try different lighting and check the fps.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-03-05 23:35:18 -0600 )edit

Some days ago OpenCV 2.4.4 and OpenCV Manager 2.6 have been published. Try to remove old Manager and binary pack and install new Manager from Google Play or OpenCV_2.4.4_Manager_armv7a_neon.apk from the latest SDK.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-03-06 06:45:16 -0600 )edit

I am having about 10 FPS from an installation of OpenCV 2.4.4 + OpenCV Manager 2.6 + armeabi-v7a with Neon. This is running tutorial 1 @ 800x480px, the device is a Nexus 4 Android 4.2.2. Is this normal?

Rui Marques gravatar imageRui Marques ( 2013-03-09 18:18:28 -0600 )edit

That's really weird: it runs 17fps@800x480 on my HTC DesireHD that should be slower than Nexus 4.

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2013-03-11 06:27:22 -0600 )edit

Yes, if you have some suggestions on how to debug go ahead. If i reduce the image size the value goes up obviously - eg. 500xYYYpx goes to ~17FPS. But still, i wished this was faster :(

Rui Marques gravatar imageRui Marques ( 2013-03-11 14:16:27 -0600 )edit

I'm having the same problem on my nexus 4 running android 4.3. The sample 1 included in opencv 2.4.5 is running at ~10fps.. any ideas?

razvan gravatar imagerazvan ( 2013-10-10 03:21:50 -0600 )edit
1

Again, same problem here. OpenCV 2.4.6 on nexus 4 - Android 4.3 has ~5-10fps in tutorials. A friends Samsung Galaxy Note got ~20. The following tutorials got ~20fps on nexus 4 though http://developer.sonymobile.com/downloads/code-example-module/opencv-code-example/ http://developer.sonymobile.com/knowledge-base/tutorials/android_tutorial/get-started-with-opencv-on-android/

moshansky gravatar imagemoshansky ( 2013-10-31 21:30:51 -0600 )edit
0

answered 2013-11-09 11:47:53 -0600

Creat gravatar image

I may not have a direct solution, but I might be able to point you in the right direction.

I'm also developing an app for Andriod using OpenCV, and I was mainly using my own Galaxy S2. I get the full 30 fps (with appropriate lighting conditions) when using either my own app or the tutorial app (native or java mode). With the Nexus 4 I recently got to help with development, I get only 10 at best, but after a bit of searching I've found a workaround: According to this StackOverflow post a possible workaround is to set the recording hint to true. This obviously only works with the java version, but after this change I get smooth frame rates (as far as the lighting allows it, so usually also around 30 fps).

One of the problems with this is that this works perfectly on the Nexus 4, but the SGS2 apparently can't deliver frames in NV12 format with the recording hint set and (force-) changes format. I can only hope that this will be fixed at some point in the Nexus 4, as this is a temporary workaround at best...

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-04 15:13:50 -0600

Seen: 6,358 times

Last updated: Nov 09 '13