имя неизвестного типа 'ACameraDevice' в ndk - PullRequest
0 голосов
/ 23 марта 2019

Я хочу разрабатывать OpenCV-программы для Android с помощью NDK, для этого я попытался создать этот пример проекта в Android Studio, но при создании проекта возникают следующие ошибки:

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 Ответ

1 голос
/ 24 марта 2019

Чтобы использовать собственный API-интерфейс camera2, установите APP_PLATFORM на android-24 или выше.В Android Studio это соответствует minSdkVersion в build.gradle скрипте.

...