diff --git a/cmake/OpenCVDetectAndroidSDK.cmake b/cmake/OpenCVDetectAndroidSDK.cmake index 68be77619d..0173223d4e 100644 --- a/cmake/OpenCVDetectAndroidSDK.cmake +++ b/cmake/OpenCVDetectAndroidSDK.cmake @@ -283,7 +283,7 @@ macro(add_android_project target path) ocv_include_modules_recurse(${android_proj_NATIVE_DEPS}) ocv_include_directories("${path}/jni") - if (NATIVE_APP_GLUE AND 0) + if(NATIVE_APP_GLUE) include_directories(${ANDROID_NDK}/sources/android/native_app_glue) list(APPEND android_proj_jni_files ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) ocv_warnings_disable(CMAKE_C_FLAGS -Wstrict-prototypes -Wunused-parameter -Wmissing-prototypes) diff --git a/samples/android/native-activity/jni/native.cpp b/samples/android/native-activity/jni/native.cpp index 0054da9da2..052b866e62 100644 --- a/samples/android/native-activity/jni/native.cpp +++ b/samples/android/native-activity/jni/native.cpp @@ -11,9 +11,10 @@ #include #include -#include -#include -#include +#include +#include +#include +#include #define LOG_TAG "OCV:libnative_activity" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) @@ -115,10 +116,10 @@ static void engine_handle_cmd(android_app* app, int32_t cmd) { LOGI("APP_CMD_INIT_WINDOW"); - engine->capture = new cv::VideoCapture(0); + engine->capture = cv::makePtr(0); union {double prop; const char* name;} u; - u.prop = engine->capture->get(CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING); + u.prop = engine->capture->get(cv::CAP_PROP_ANDROID_PREVIEW_SIZES_STRING); int view_width = ANativeWindow_getWidth(app->window); int view_height = ANativeWindow_getHeight(app->window); @@ -135,8 +136,8 @@ static void engine_handle_cmd(android_app* app, int32_t cmd) if ((camera_resolution.width != 0) && (camera_resolution.height != 0)) { - engine->capture->set(CV_CAP_PROP_FRAME_WIDTH, camera_resolution.width); - engine->capture->set(CV_CAP_PROP_FRAME_HEIGHT, camera_resolution.height); + engine->capture->set(cv::CAP_PROP_FRAME_WIDTH, camera_resolution.width); + engine->capture->set(cv::CAP_PROP_FRAME_HEIGHT, camera_resolution.height); } float scale = std::min((float)view_width/camera_resolution.width, @@ -210,7 +211,7 @@ void android_main(android_app* app) if (!engine.capture.empty()) { if (engine.capture->grab()) - engine.capture->retrieve(drawing_frame, CV_CAP_ANDROID_COLOR_FRAME_RGBA); + engine.capture->retrieve(drawing_frame, cv::CAP_ANDROID_COLOR_FRAME_RGBA); char buffer[256]; sprintf(buffer, "Display performance: %dx%d @ %.3f", drawing_frame.cols, drawing_frame.rows, fps);