ndk中的未知类型名称'ACameraDevice'

时间:2019-03-23 20:02:02

标签: android opencv android-ndk opencv4android

我想用NDK在android中开发opencv程序,为此,我试图在android studio中构建this示例项目,但是在创建项目时会出现以下错误:

Build command failed.
Error while executing process E:\SoftWare\Android\android-ndk-r19c\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\src\main\cpp\Android.mk NDK_APPLICATION_MK=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\src\main\cpp\Application.mk APP_ABI=x86_64 NDK_ALL_ABIS=x86_64 NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\build\intermediates\ndkBuild\debug\lib APP_CPPFLAGS+=-std=c++14 C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/libopencv_ndk.so}

[x86_64] Compile++      : opencv_ndk <= native-lib.cpp

In file included from C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/native-lib.cpp:4:
In file included from C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/CV_Main.h:15:
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:15:55: error: unknown type name 'ACameraDevice'
static void CameraDeviceOnDisconnected(void* context, ACameraDevice* device) {
                                                      ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:18:48: error: unknown type name 'ACameraDevice'
static void CameraDeviceOnError(void* context, ACameraDevice* device,
                                               ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:25:35: error: unknown type name 'ACameraCaptureSession'
                                  ACameraCaptureSession* session) {
                                  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:29:36: error: unknown type name 'ACameraCaptureSession'
                                   ACameraCaptureSession* session) {
                                   ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:52:3: error: unknown type name 'ACameraDevice'
  ACameraDevice* m_camera_device;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:53:3: error: unknown type name 'ACaptureRequest'
  ACaptureRequest* m_capture_request;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:54:3: error: unknown type name 'ACameraOutputTarget'
  ACameraOutputTarget* m_camera_output_target;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:55:3: error: unknown type name 'ACaptureSessionOutput'
  ACaptureSessionOutput* m_session_output;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:56:3: error: unknown type name 'ACaptureSessionOutputContainer'
  ACaptureSessionOutputContainer* m_capture_session_output_container;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:57:3: error: unknown type name 'ACameraCaptureSession'
  ACameraCaptureSession* m_capture_session;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:59:3: error: unknown type name 'ACameraDevice_StateCallbacks'
  ACameraDevice_StateCallbacks m_device_state_callbacks;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:60:3: error: unknown type name 'ACameraCaptureSession_stateCallbacks'
  ACameraCaptureSession_stateCallbacks m_capture_session_state_callbacks;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:62:3: error: unknown type name 'ACameraManager'
  ACameraManager* m_camera_manager;
  ^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:64:3: error: unknown type name 'ACameraIdList'
  ACameraIdList* m_camera_id_list = NULL;
  ^
14 errors generated.
make: *** [C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/objs-debug/opencv_ndk/native-lib.o] Error 1

环境详细信息:

NDK版本:r19c

主机操作系统:Windows

IDE:Android Studio 3.3.2

SDK平台工具:28.0.2

SDK工具:25.2.5

1 个答案:

答案 0 :(得分:0)

要使用本机camera2 API,请将您的 APP_PLATFORM 设置为 android-24 或更高版本。在Android Studio中,这对应于build.gradle脚本中的 minSdkVersion