Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Changing OPENCV camera view orientation on androi

I have been struggling to change the orientation of the OPENCV on my android 4.4.2 OS version. It is appearing in the landscape mode. Looks exactly like:image description

I am using opencv 2.4.11 for android. My android studio version is 2.1. Many solutions exists that rely on the Camera class of android which is depricated. I have tried the: android:screenOrientation="portrait", but doesn't work I have also:

public void setResolution(Size resolution) {

disconnectCamera();
mMaxHeight = resolution.height;
mMaxWidth = resolution.width;
// mCamera.setDisplayOrientation(90);  //* Crashes if placed here
connectCamera(getWidth(), getHeight());
mCamera.setDisplayOrientation(90);  //* Doesn't crash if here, but doesn't work either

}

Some solutions suggested that I will use transpose and flip such as:

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

Mat rgba = inputFrame.rgba();
// Rotate clockwise 90 degrees
Core.transpose(rgba, rgba);
Core.flip(rgba, rgba, 1);
... do stuff to the image ...
return rgba;

} But nothing worked out. SO I AM WONDERING Whether opencv community has a solution for this bug. If I am missing something I would like to hear from you. THANK YOU !!!