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.