javaandroidopencvcameracomputer-vision

Using Camera LED Flash with OpenCV on Android


I have an application using OpenCV for Android and was wondering if it was possible to enable the camera's LED.

Currently my camera is set up using the following code:

camera = new VideoCapture(Highgui.CV_CAP_ANDROID);

All examples I've seen which enable the LED Flash require Camera.Parameters which I don't have access to with this camera setup.

Is there any simple way to enable the LED without switching to using the basic Camera class for my videostream, as this tends to be much slower.

Thanks for any help in advance.


Solution

  • In OpenCV for Android 2.4, you can do this,

    mCamera.set(
      Highgui.CV_CAP_PROP_ANDROID_FLASH_MODE,
      Highgui.CV_CAP_ANDROID_FLASH_MODE_ON
    );
    

    Other options are: CV_CAP_ANDROID_FLASH_MODE_AUTO, CV_CAP_ANDROID_FLASH_MODE_OFF, CV_CAP_ANDROID_FLASH_MODE_TORCH andCV_CAP_ANDROID_FLASH_MODE_REDEYE.

    However, using this causes the application to automatically close on my tablet (Asus TF101). Hopefully it works on others.