简体   繁体   English

OpenCV + Android:如何在JavaCameraView中访问摄像头

[英]OpenCV + Android: how to access the camera in JavaCameraView

Maybe a very stupid question. 也许是一个非常愚蠢的问题。 Anyway, I'm trying to get into OpenCV on Android devices. 无论如何,我正试图在Android设备上进入OpenCV。 Therefore I'm playing around with the examples of the OpenCV Android SDK. 因此,我正在玩OpenCV Android SDK的示例。 My problem is, that my code in the MainActivity which uses a JavaCameraView instance. 我的问题是,我在MainActivity中使用JavaCameraView实例的代码。 That instance has a private member which is the actual camera. 该实例有一个私人成员,它是真正的相机。

I want to access the camera in the JavaCameraView.surfaceChanged event to use code like that? 我想在JavaCameraView.surfaceChanged事件中访问相机以使用这样的代码? So question a) how to hook on that event and b) how to access the camera member? 所以问题a)如何挂钩该事件和b)如何访问相机成员?

Here's some example code from another post : 这是来自另一篇文章的一些示例代码:

public void surfaceChanged(SurfaceHolder holder, int format, int width,
        int height) {

    Size size = params.getPreviewSize();
    this.height = size.height;
    this.width = size.width;
    camera.setParameters( params );
    camera.startPreview();

}

我发现的唯一解决方案是从JavaCameraView或NativeCameraView继承以获取对其受保护的摄像头成员的访问权限。

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

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