如何使用OpenCV在Android相机上禁用/修改AutoFocus和AutoWhiteBalance [英] How to disable/modify AutoFocus and AutoWhiteBalance on Android Camera using OpenCV

查看:507
本文介绍了如何使用OpenCV在Android相机上禁用/修改AutoFocus和AutoWhiteBalance的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android + Opencv(opencv的新增功能),目前我正在使用实时对象检测(对象保持与android设备Camera非常接近),并且我注意到Android相机的autoFocus不断修改我的(放大和缩小效果),这使我很难跟踪对象。



我需要将AUTO FOCUS 关闭,因为在我的情况下,我输入的图像越模糊,效果越好,同时我也需要关闭AutoWhiteBalance,或者设置为不同的值。



<我想知道如何通过我的OpenCV CameraBridgeViewBase,所以我可以修改相机的焦点/白平衡设置。

我试图找到一种方法解决这个问题,我注意到很多人面临同样的问题。



在这里,在堆栈溢出,将是一个伟大的地方,找到一个谁曾经一起工作,找到了一个很好的方法来克服这些问题。 $ b

解决方案

创建您自己的子类 javacameraview
public class MyJavaCameraView扩展JavaCameraView {
,您可以访问 mCamera ;
添加任何相机访问使用你感兴趣的方法
例如

$ $ p $ $ $
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);

并将这个新类用作主要活动的一部分

  //强制java相机
mOpenCvCameraView =(MyJavaCameraView)findViewById(R.id.activity_surface_view);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
mOpenCvCameraView.enableView();


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.

解决方案

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();

这篇关于如何使用OpenCV在Android相机上禁用/修改AutoFocus和AutoWhiteBalance的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆