1

I am developing an OpenCV app for Android phones that does heavy image processing. As such, I want to limit my screen resolution to 640x480 to squeeze out extra fps. However, if I turn my camera 90 degrees to landscape mode, the screen resolution changes to 1920x1080 and I am not sure how to fix this. Here is my main activity code where I initialize the camera:

private MainView mOpenCvCameraView;

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

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

MainView is basically JavaCameraView with an extra method I defined:

public class MainView extends JavaCameraView {

    public MainView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @SuppressWarnings("deprecation")
    public void lockAutoExposure() {
        Camera.Parameters params = mCamera.getParameters();
        params.setExposureCompensation(params.getExposureCompensation());
        params.setAutoExposureLock(true);
        mCamera.setParameters(params);
    }


}

Finally, relevant code from manifest:

<application
    android:allowBackup="true"
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:screenOrientation="landscape"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    ...

Also, when starting the app in portrait mode, the camera view is rotated 90 degrees. I would like to have upright frames returned in portrait mode, and rotated frames returned in landscape mode, like a normal camera app.

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Sumeet Batra
  • 357
  • 1
  • 4
  • 14
  • I think [this](http://stackoverflow.com/a/39600063/3429869) link will help you with the second issue. Were you able to fix the first issue you were having? – Anvesh Arrabochu Oct 23 '16 at 08:30

0 Answers0