Skip to main content

Android-OpenCV camera orientation issue


First I get into JavaCameraView.java class in the OpenCV Library

and then in the initializeCamera add the following lines just before mCamera.startPreview();

            setDisplayOrientation(mCamera, 90);
            mCamera.setPreviewDisplay(getHolder());

The first function implemented like this

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


Reference : https://stackoverflow.com/questions/16669779/opencv-camera-orientation-issue

Comments