Android Camera2可执行文件无法获取框架 [英] Android Camera2 executable failed to get frames

查看:758
本文介绍了Android Camera2可执行文件无法获取框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Camera2 NDK代码可以打开相机并获取图像.

I have one Camera2 NDK code to open the camera and get images.

该代码可通过Android应用程序/服务正常运行,但是如果我将其编译并以可执行文件身份运行,则相机会打开,但不会得到任何帧.

The code work fine via Android Application/Service, but if I compile and run it as executable the camera opened but I don't get any frames.

有什么主意吗?有人成功做到了吗?

Any idea? someone succeeded to do it?

注意

  1. 我通过"AImageReader_new"创建自己的AImageReader
  2. 我通过"AImageReader_getWindow"创建自己的ANativeWindow


注意2(已添加)


NOTE2 (ADDED)

通话有点不同

对于Android应用程序/服务,调用如下:

For Android Application/Service the calls like:

public void onCreate() {
       JNIBridge.startPreview(null);
}
public void onDestroy() {
       JNIBridge.stopPreview();
}

对于可执行文件:

int main()
{
Java_com_y30_nativecamera2_JNIBridge_startPreview(nullptr, nullptr, nullptr);

for(int i = 0; i < 10; ++i)
{
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}

Java_com_y30_nativecamera2_JNIBridge_stopPreview(nullptr, nullptr);

return 0;
}


更新


UPDATE

我在多个Android设备上再次对其进行了测试.

I tested it again on multi Android devices.

S8/S9 +(使用Andorid 8.0.0)正在重现.("ACameraManager_openCamera"状态还可以,但是我没有任何帧)

S8/S9+ (With Andorid 8.0.0) it's reproduce.("ACameraManager_openCamera" status is OK, but I don't get any frames)

像素(对于Android 9),方法"ACameraManager_openCamera"失败.

Pixel (With Android 9) the method "ACameraManager_openCamera" failed.

10-09 10:45:04.933   933  1592 I CameraService: CameraService::connect call (PID -1 "", camera ID 0) for HAL version default and Camera API version 2
10-09 10:45:04.933   933  1592 W ServiceManager: Permission failure: android.permission.CAMERA from uid=2000 pid=19606
10-09 10:45:04.933   933  1592 E CameraService: Permission Denial: can't use the camera pid=19606, uid=2000
10-09 10:45:04.933 19606 19606 E ACameraManager: openCamera: connect camera device failed: Status(-8): '1: validateClientPermissionsLocked:906: Caller "" (PID 2000, UID 19606) cannot open camera "0" without camera permission'


UPDATE2


UPDATE2

我也使用msm8996 EVB(使用Android 7.1.1)对其进行了测试:

I tested it also with msm8996 EVB (With Android 7.1.1):

(1)我遇到了Pixel2之类的权限问题.

(1) I get permission issue like the Pixel2.

(2)我用su来运行它,并且修复了权限问题(相机已打开),但是我还没有得到任何图像.

(2) I ran it with su and the permission issue fixed (the camera opened) but I already don't get any images.

推荐答案

我没有看到您的代码.根据您的描述,您已正确完成了所有操作.如果添加以下内容,则应该可以使用.

I have not seen your code. From your description, you have done everything right. If you add the following, it should work.

#include <binder/ProcessState.h>

...
main()
{
...
    android::ProcessState::self()->startThreadPool();
...
    Camera open, AImageReader_new, etc ...
...
    Close Camera
...
}

还将libbinder添加到Android.mk LOCAL_SHARED_LIBRARIES.

Also add libbinder to Android.mk LOCAL_SHARED_LIBRARIES.

这篇关于Android Camera2可执行文件无法获取框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆