How to disable/modify AutoFocus and AutoWhiteBalance on Android Camera using OpenCV

一曲冷凌霜 提交于 2019-12-21 19:20:12

问题


I'm using Android + Opencv(new to opencv) and I'm currently working with real time object detection (the object stays really close to the android device Camera) , and I noticed that the Android camera's autoFocus keeps modifying my frames (kind of 'zoom in' and 'zoom out' effect) which make it harder for me to keep tracking the object.

I need to turn the "AUTO FOCUS" off because in my case the more blurred image input I have, the better, and I also need to turn the AutoWhiteBalance off as well, or maybe set to a different value.

I would like to know how to do it through my OpenCV CameraBridgeViewBase so I could modify the camera's Focus/WhiteBalance settings.

I've trying to find a way to solve it, and I noticed that many people face the same problems.

Here, at Stack Overflow, would be a great place to find someone who have worked with that and found a good way to overcome these problems.


回答1:


create your own subclass of javacameraview public class MyJavaCameraView extends JavaCameraView { where you can have access to mCamera; add whatever camera access using method you are interested in for example

// Setup the camera
public void setFlashMode(boolean flashLightON) {
    Camera camera = mCamera;
    if (camera != null) {
        Camera.Parameters params = camera.getParameters();
                params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
            camera.setParameters(params);

and use this new class as part of the main activity

    //force java camera
    mOpenCvCameraView = (MyJavaCameraView) findViewById(R.id.activity_surface_view);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);
    mOpenCvCameraView.enableView();


来源:https://stackoverflow.com/questions/32018814/how-to-disable-modify-autofocus-and-autowhitebalance-on-android-camera-using-ope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!