Merge pull request #1422 from SpecLad:nat-act-upd

pull/1415/merge
Roman Donchenko 11 years ago committed by OpenCV Buildbot
commit 54c6830937
  1. 2
      cmake/OpenCVDetectAndroidSDK.cmake
  2. 17
      samples/android/native-activity/jni/native.cpp

@ -283,7 +283,7 @@ macro(add_android_project target path)
ocv_include_modules_recurse(${android_proj_NATIVE_DEPS}) ocv_include_modules_recurse(${android_proj_NATIVE_DEPS})
ocv_include_directories("${path}/jni") ocv_include_directories("${path}/jni")
if (NATIVE_APP_GLUE AND 0) if(NATIVE_APP_GLUE)
include_directories(${ANDROID_NDK}/sources/android/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) 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) ocv_warnings_disable(CMAKE_C_FLAGS -Wstrict-prototypes -Wunused-parameter -Wmissing-prototypes)

@ -11,9 +11,10 @@
#include <math.h> #include <math.h>
#include <queue> #include <queue>
#include <opencv2/core/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/utility.hpp>
#include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#define LOG_TAG "OCV:libnative_activity" #define LOG_TAG "OCV:libnative_activity"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #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"); LOGI("APP_CMD_INIT_WINDOW");
engine->capture = new cv::VideoCapture(0); engine->capture = cv::makePtr<cv::VideoCapture>(0);
union {double prop; const char* name;} u; 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_width = ANativeWindow_getWidth(app->window);
int view_height = ANativeWindow_getHeight(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)) 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_WIDTH, camera_resolution.width);
engine->capture->set(CV_CAP_PROP_FRAME_HEIGHT, camera_resolution.height); engine->capture->set(cv::CAP_PROP_FRAME_HEIGHT, camera_resolution.height);
} }
float scale = std::min((float)view_width/camera_resolution.width, 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.empty())
{ {
if (engine.capture->grab()) 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]; char buffer[256];
sprintf(buffer, "Display performance: %dx%d @ %.3f", drawing_frame.cols, drawing_frame.rows, fps); sprintf(buffer, "Display performance: %dx%d @ %.3f", drawing_frame.cols, drawing_frame.rows, fps);

Loading…
Cancel
Save