Ask Your Question

issa.ayoub's profile - activity

2018-06-12 13:03:26 -0600 received badge  Famous Question (source)
2017-07-06 03:04:47 -0600 received badge  Notable Question (source)
2017-04-05 08:42:18 -0600 received badge  Popular Question (source)
2016-06-02 15:15:16 -0600 answered a question Changing OPENCV camera view orientation on androi

After working around this problem, it seems that the opencv camera cannot be viewed in portrait mode. The problem is solved by adding: android:screenOrientation="landscape" inside AndroidManifest.xml inside activity section. In addition, here is the onCreate(): super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_main);
    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.opencv_camera);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);

Notice where the setContentView is added. Finally, Note that my main activity extended the Activity class and the in the menifest file I added: android:theme="@android:style/Theme.NoTitleBar.Fullscreen" under the application section.

2016-05-31 06:55:49 -0600 asked a question 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 !!!