Ask Your Question

Revision history [back]

I found a solution for this.

Tested - working fine. :)

Just added few lines of code to OpenCV Library JavaCameraView class.

Step 1. Go to OpenCVLibrary > Java > org.opencv > android > JavaCameraView

image description

Step 2. Add this method anywhere in the JavaCameraView class

private void setDisplayOrientation(Camera mCamera, int angle) {
    Method downPolymorphic;
        downPolymorphic = mCamera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class });
        if (downPolymorphic != null)
            downPolymorphic.invoke(mCamera, new Object[] { angle });
    catch (Exception e1)

Step 3. Search for mCamera.startPreview(); in the class and paste this code just above this.

setDisplayOrientation(mCamera, 90);

Just like this. image description

Run your code.

Happy Coding!