0

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

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?

Thanks in advance for your help!

Sumeet Batra
  • 357
  • 1
  • 4
  • 14

1 Answers1

1

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"/>

Step 2: Change this line in AndroidManifest.xml

android:theme="@style/AppTheme">

           to 

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

Step 3: Then change

<activity android:name=".MainActivity">

  to

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

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.

Md. Juyel Rana
  • 540
  • 5
  • 10