Ask Your Question
1

Best way to get most FPS android camera?

asked 2013-03-13 06:02:05 -0600

MysticBE gravatar image

updated 2013-03-13 06:03:43 -0600

I am currently working on an application that uses the OpenCV Library 2.4.4 in Android. I am doing a Canny edge detection and a guassian blur (to reduce noise) but the maximum FPS i'm currently getting is 8.5 FPS in the minimum resolution (320x240). In the normal resolution (960x720) it drops to about 2.3 FPS.

I read about the JNI (C++ code) and was wondering if the camera would receive more Frames Per Second if I used the JNI/ Native/C++, or won't that change a thing?

I am using a Samsung Galaxy S3 with a quad core processor, so I am really wondering if there is no possible way to get the FPS higher (threading maybe with OpenCV is that is an option? I haven't really found anything about it).

edit retag flag offensive close merge delete

Comments

2

I'd be interested to know the answer to this too... I recently changed from an HTC Desire S to a Nexus 4 and despite the significant increase in processor power, I get very similar frame rates in my OpenCV apps - using the preview at the same resolution (800x480).

I expected the simple increase in computing power to give me a clear boost, even tho of course at the same time I changed from Android 2.3.x to 4.2 and OpenCV from 2.4.0 to 2.4.4, but even with very light use of OpenCV calls I never get above 10fps.

Barry Thomas gravatar imageBarry Thomas ( 2013-03-13 06:39:20 -0600 )edit

I found something very strange and interesting, when I work with OpenCV example number 2, the mixed Process (Java and C++ JNI) I get double the FPS then when I just use the normal one (without the JNI) .... how is this possible? The Canny edge detection has double the FPS with the JNI part included (Tutorial 2) then without it.. so weird

MysticBE gravatar imageMysticBE ( 2013-03-13 11:52:56 -0600 )edit

@Barry I think opencv has some problems with the Nexus 4. I tested with a simple sample and it does not go above 10fps. With other device it goes up to 30fps.

Rui Marques gravatar imageRui Marques ( 2013-03-13 15:07:27 -0600 )edit

@Rui Interesting... thanks. Fortunately I'm just experimenting with OpenCV really and don't have a serious need for high speed, but 10fps is very disappointing :(

Barry Thomas gravatar imageBarry Thomas ( 2013-03-14 04:29:37 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-03-13 06:57:54 -0600

sammy gravatar image

updated 2013-03-13 15:07:14 -0600

It seems that the only way to get the most of your Android Camera is to use the Java API (The Android API for camera access, not the OpenCV-provided ones).

You should write a Java video capture class, that receives notifications every time a new frame is captured. (Similarly, you can start the camera in picture preview mode, and get new frame notification callbacks).

Then, forward the frame buffers to you native code using JNI calls.

The exact way to do it depends on the Android version, and sometimes, on the phone maker. They do not always use the Android conventions. If you want a portable camera app, you should write different implementations for each Android version, and load the appropriate one at runtime:

class CameraInterface {};
class CameraInterface2_2 : public CameraInterface {};
class CameraInterfaceIceCream : public CameraInterface {};
....

CameraInterface camera;
if(AndroidVersion == IceCream)
{
    camera = new CameraInterfaceIceCream();
}
...

Here is where you can start

Please read carefully the documentation for the camera API. You should guarantee some maximum delay for camera callbacks, and make sure the frame is not altered, and so on.

edit flag offensive delete link more
-1

answered 2013-03-13 06:48:38 -0600

What is actually happening is your android phone assigning the amount of memory your application could use. It is the same when creating applications on a desktop computer. When you want to benefit from the processing power, you should look for commands to explicitly reserve working memory on your phone.

Haven't worked in android so no idea how this is done, but this tip should help to get you more information from the net.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-13 06:02:05 -0600

Seen: 17,920 times

Last updated: Mar 13 '13