Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any chances to reduce shutter time with android NDK camera access?

I wrote an android application that captures a live preview from the camera. It is important to have a short shutter time, which should at least be constant.

Currently I use the following code to achieve a low shutter time:

Parameters params = camera.getParameters();
params.setSceneMode(Parameters.SCENE_MODE_SPORTS);
params.setWhiteBalance(Parameters.WHITE_BALANCE_DAYLIGHT);
params.setFlashMode(Parameters.FLASH_MODE_OFF);
params.setFocusMode(Parameters.FOCUS_MODE_INFINITY);

params.setPreviewFpsRange(9000, 29453);
params.setPreviewFrameRate(29453);
params.setJpegQuality(100);
params.setPreviewFormat(ImageFormat.NV21);

params.setPreviewSize(1280,720);
params.setAntibanding(Parameters.ANTIBANDING_OFF);
params.setExposureCompensation(params.getMinExposureCompensation());
params.set("iso", 1250);
camera.setParameters(params);

The setSceneMode() seems not to be supported at my phones firmware (getSupportedSceneModes returns an empty list). The "ISO"-Setting has possibly no effect (have not looked at the picture, just calculated the frame rate, yet). Just found this code somewhere and used it... maybe it's just the wrong string?

What happens so far is: The frame rate changes between 9 and 29,453 fps, which is the only supported frame rate range. So params.setPreviewFpsRange(29453, 29453); doesn't work either. The Frame rate is high (20-30 fps) at good light conditions (normal day, indoors, directed to window) and becomes very low (8-10 fps) for medium/low light (daylight, indoors, direct away from window) conditions.

More in detail: I do not need a high frame rate, but a low shutter time. The gathered data shall be used for indoor navigation (or: Indoor Localization in a first step). The application needs to take pictures while a person is just normally walking, without the person caring about how he/she is carrying the phone. The person could be even running or "swinging" the phone (as you would normally move your arms when walking). So there is usually a lot of "motion blur", as soon the shutter time is too long. The situation is much different to "I want to make a photo" situations, where the photograph tries to hold the camera steady. We actually don't want to achieve "good photos", but want to somehow detect some edges of walls from time to time. I expect a lot of "noise" in the picture, but this is hopefully working anyway...

The Idea is, that there are possibly chances to get more control over camera parameters using the NDK. Has anyone experiences with the NDK and can answer me weather it's worth trying?

Additional Info: I'm using an HTC Desire Z (also named: "T-Mobile G2" or "HTC Vision") as test device.

like image 709
SDwarfs Avatar asked Sep 18 '12 17:09

SDwarfs


1 Answers

The short answer is "NO". The longer answer starts with a question: your app does not care about the capture, but only uses the YUV preview frames, is that correct?

As a standard downloaded app with no root access, you have no permissions to access camera (or other) device directly. You only have setParameters() API to effect the camera behaviour, and thus you are completely at the mercy of the OEM as to what camera functionality is exposed through this API.

Even on a rooted device, your capabilities are limited, but now by the specs of the device drivers and specific camera ISP.

In both cases, you should start by very carefully choosing the target device. I believe that some Android phones allow much more camera control than HTC Vision. For example, a modified version of Samsung S2 http://pfittech.com/rom_pfittech_jb.html boasts stable 25 FPS at 1080p.

like image 152
Alex Cohn Avatar answered Nov 05 '22 07:11

Alex Cohn