简体   繁体   English

适用于Android的OpenCV库(人像摄像头)

[英]OpenCV Library for Android (portrait camera)

I am developing android application with facial recogniton using opencv library. 我正在使用opencv库开发面部识别的android应用程序。 My problem is the screen orientation. 我的问题是屏幕方向。 I got a solution with code below in JavaCameraView class. 我在JavaCameraView类中获得了以下代码的解决方案。

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. 我发现了这个,但我认为该解决方案在最新版本的opencv库中不起作用。

Any ideas could be useful. 任何想法都可能有用。

Thanks in advance. 提前致谢。

You have to also create the setDisplayOrientation by adding this: 您还必须通过添加以下内容来创建setDisplayOrientation

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)
    {
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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