JavaCameraView和android(OpenCV)的定位

时间:2015-09-04 13:12:21

标签: java android opencv

我是openCV API的新开发人员,我无法在JavaCameraView上设置方向,有人可以帮助代码吗?

相机上的方向似乎已反转。

轴也是反转的,已经尝试过函数setMaxFrameSize(),但没有成功。

public class AbrirCamera extends Activity implements CameraBridgeViewBase.CvCameraViewListener2 {

    private JavaCameraView mOpencvCameraView;

    private OrientationEventListener orientationListener = null;



    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch(status)
            {
                case LoaderCallbackInterface.SUCCESS:
                    Log.i(TAG, "Sucesso Carregando OpenCV.");
                    mOpencvCameraView.enableView();
                    break;

                default:
                    super.onManagerConnected(status);
                    break;

            }
        }
    };


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_abrir_camera);

        mOpencvCameraView = (JavaCameraView) findViewById(R.id.aCameraView);
        mOpencvCameraView.setVisibility(SurfaceView.VISIBLE);
        mOpencvCameraView.setCvCameraViewListener(this);
        mOpencvCameraView.enableFpsMeter();


    }


    @Override
    public void onResume() {
        super.onResume();
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
    }

    public void onDestroy()
    {
        super.onDestroy();
        if (mOpencvCameraView != null)
        {
            mOpencvCameraView.disableView();
        }
    }


    @Override
    public void onCameraViewStarted(int width, int height) {



    }


    @Override
    public void onCameraViewStopped() {

    }

    @Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {


        return inputFrame.rgba();

    }

}

1 个答案:

答案 0 :(得分:0)

嗯,我自己想出了答案,

刚刚添加了文件styles.xml,如下所示:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

    <style name="Landscape_camera">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
    </style>

</resources>

之后,刚刚修改了活动中的布局以使用此样式。