4

I am working on a light (LED) communication system using an Android phone camera as the receiver that does thresholding on camera frames. For that, I use preview's callback method onPreviewFrame. To be more accurate there's a need to delay the capture of a frame every few frames so that the system will re-synchronize.

My questions are:

  1. How do I delay the capture (not the preview) of a single frame?
  2. Is it possible that there are internal changes of the camera fps rate that i'm not aware of and if so how do I limit or change them?

*To limit the camera fps rate I use setPreviewFpsRange, setAutoWhiteBalanceLock and setAutoExposureLock.

madlymad
  • 6,367
  • 6
  • 37
  • 68
Voly
  • 145
  • 4
  • 16
  • Please view [this answer](http://stackoverflow.com/a/19923966/2774781) to improve fps accuracy – guy_m May 10 '16 at 20:54

1 Answers1

0

You can try the newer android.hardware.camera2 package added in API level 21 which replaces the deprecated Camera class and provides a fine grained control over the Camera functionality:

Get CameraManager service

CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);

Retrieve the camera list available on your device

String[] cameraIdList = manager.getCameraIdList();

Iterate through the cameraList to select a camera with desired characteristics

for(String cameraId:cameraIdList)
{
    CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
}

Create camera callback class with preview and still capture requests

private class CameraCallback extends CameraDevice.StateCallback
{
    @Override
    public void onOpened(CameraDevice camera)
    {
        CaptureRequest previewRequest = camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW).build();

        CaptureRequest stillCaptureRequest = camera.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).build();
    }
}
Chebyr
  • 2,171
  • 1
  • 20
  • 30
  • Thank you for your answer. I fail to see how it help me control the ftp in real time though:/ – guy_m May 19 '16 at 06:46
  • The first part of the question is to independently control the timings of preview and capture of a single frame. By creating 2 separate requests, you can control the timing at will. – Chebyr May 19 '16 at 07:26
  • Will the `stillCaptureRequest` allow me to control the FTP? It seems it will just let me ask for a capture "sometimes in the close future". But it doesn't mean I can control the exact rate (at say 1/30 sec accuracy). Or does it? – guy_m May 22 '16 at 08:52