简体   繁体   中英

OpenCV Library for Android (portrait camera)

I am developing android application with facial recogniton using opencv library. My problem is the screen orientation. I got a solution with code below in JavaCameraView class.

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

The camera is good but the facial detection doesnt work.

I found this but I think that the solution does not work in latest version of opencv library.

Any ideas could be useful.

Thanks in advance.

You have to also create the setDisplayOrientation by adding 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)
    {
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM