本文介绍了OpenCV Android摄像头未全屏显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作适用于Android的OpenCV应用,该应用可以进行大量的图像处理.为了提高帧速率,我将帧大小限制为640 x 480,如下所示:

I am making an OpenCV App for Android that does heavy image processing. To increase my frame rate, I limited my frame size to 640 x 480 like so:

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch(status) {
        case LoaderCallbackInterface.SUCCESS:
        {
            mOpenCvCameraView.setMaxFrameSize(640, 480);
            Log.i(TAG, "Loaded Successfully");
            mOpenCvCameraView.enableView();
            System.loadLibrary("opencvnative");

            break;
        }
        default:
        {
            super.onManagerConnected(status);
        }
        }
    }
};

其中mOpenCvCameraView的类型为JavaCameraView.不幸的是,这种方法使框架小于屏幕尺寸.在降低分辨率之后是否可以拉伸框架以适合屏幕,还是有更好的方法来解决此问题?

Where mOpenCvCameraView is of type JavaCameraView. Unfortunately, this approach makes the frame smaller than the screen size. Is it possible to stretch the frame to fit the screen after reducing the resolution, or is there a better way to go about this?

提前感谢您的帮助!

推荐答案

步骤1:首先,您必须将其放入AndroidManifest.xml

Step1: First you have to put these inside AndroidManifest.xml

<supports-screens android:resizeable="true"
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"
    android:anyDensity="true" />

<uses-permission android:name="android.permission.CAMERA"/>

<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>

第2步:在AndroidManifest.xml中更改此行

Step 2: Change this line in AndroidManifest.xml

android:theme="@style/AppTheme">

           to

android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

第3步:然后更改

<activity android:name=".MainActivity">

  to

<activity android:name=".MainActivity"
        android:screenOrientation="landscape"
        android:configChanges="keyboardHidden|orientation">

第4步:完成上述操作后,将此行放入Java类的onCreate()方法

Step 4: After completing the above put this line to onCreate() method on java class

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

如果您成功完成了这些操作,我希望它能正常工作.

if you successfully done these i hope it will working fine.

这篇关于OpenCV Android摄像头未全屏显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:18