标签:
#!/bin/sh
cd `dirname $0`/..
mkdir -p build_android_arm
cd build_android_arm
cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake $@ ../..
cd build_android_arm
make
make install
-- Tests and samples:
-- Tests: YES
-- Performance tests: YES
-- C/C++ Examples: NO
if(DEFINED WITH_V4L)
if(HAVE_CAMV4L)
set(HAVE_CAMV4L_STR "YES")
else()
set(HAVE_CAMV4L_STR "NO")
endif()
if(HAVE_CAMV4L2)
set(HAVE_CAMV4L2_STR "YES")
elseif(HAVE_VIDEOIO)
set(HAVE_CAMV4L2_STR "YES(videoio)")
else()
set(HAVE_CAMV4L2_STR "NO")
endif()
status(" V4L/V4L2:" HAVE_LIBV4L
THEN "Using libv4l1 (ver ${ALIASOF_libv4l1_VERSION}) / libv4l2 (ver ${ALIASOF_libv4l2_VERSION})"
ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
endif(DEFINED WITH_V4L)
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX))
# --- V4L ---
#luoyouren-20160629
status(" before seting ...")
status(" WITH_V4L:" ${WITH_V4L})
status(" HAVE_LIBV4L:" ${HAVE_LIBV4L})
status(" HAVE_CAMV4L:" ${HAVE_CAMV4L})
status(" HAVE_CAMV4L2:" ${HAVE_CAMV4L2})
status(" HAVE_VIDEOIO:" ${HAVE_VIDEOIO})
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
if(WITH_V4L)
if(WITH_LIBV4L)
CHECK_MODULE(libv4l1 HAVE_LIBV4L1)
CHECK_MODULE(libv4l2 HAVE_LIBV4L2)
if(HAVE_LIBV4L1 AND HAVE_LIBV4L2)
set(HAVE_LIBV4L YES)
else()
set(HAVE_LIBV4L NO)
endif()
endif()
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO)
status(" seting ...")
status(" WITH_V4L:" ${WITH_V4L})
status(" HAVE_LIBV4L:" ${HAVE_LIBV4L})
status(" HAVE_CAMV4L:" ${HAVE_CAMV4L})
status(" HAVE_CAMV4L2:" ${HAVE_CAMV4L2})
status(" HAVE_VIDEOIO:" ${HAVE_VIDEOIO})
endif(WITH_V4L)
#luoyouren-20160629
#set(WITH_V4L ON)
#set(HAVE_CAMV4L2 ON)
status(" after seting ...")
status(" WITH_V4L:" ${WITH_V4L})
status(" HAVE_LIBV4L:" ${HAVE_LIBV4L})
status(" HAVE_CAMV4L:" ${HAVE_CAMV4L})
status(" HAVE_CAMV4L2:" ${HAVE_CAMV4L2})
status(" HAVE_VIDEOIO:" ${HAVE_VIDEOIO})
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO)
/opt/ndk/android-ndk-r9/platforms/android-8/arch-arm/usr/include/linux/videodev2.h
# --- V4L ---
#luoyouren-20160629
status(" before seting ...")
status(" WITH_V4L:" ${WITH_V4L})
status(" HAVE_LIBV4L:" ${HAVE_LIBV4L})
status(" HAVE_CAMV4L:" ${HAVE_CAMV4L})
status(" HAVE_CAMV4L2:" ${HAVE_CAMV4L2})
status(" HAVE_VIDEOIO:" ${HAVE_VIDEOIO})
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
if(WITH_V4L)
if(WITH_LIBV4L)
CHECK_MODULE(libv4l1 HAVE_LIBV4L1)
CHECK_MODULE(libv4l2 HAVE_LIBV4L2)
if(HAVE_LIBV4L1 AND HAVE_LIBV4L2)
set(HAVE_LIBV4L YES)
else()
set(HAVE_LIBV4L NO)
endif()
endif()
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO)
status(" seting ...")
status(" WITH_V4L:" ${WITH_V4L})
status(" HAVE_LIBV4L:" ${HAVE_LIBV4L})
status(" HAVE_CAMV4L:" ${HAVE_CAMV4L})
status(" HAVE_CAMV4L2:" ${HAVE_CAMV4L2})
status(" HAVE_VIDEOIO:" ${HAVE_VIDEOIO})
endif(WITH_V4L)
#luoyouren-20160629
set(HAVE_CAMV4L2 ON)
status(" after seting ...")
status(" WITH_V4L:" ${WITH_V4L})
status(" HAVE_LIBV4L:" ${HAVE_LIBV4L})
status(" HAVE_CAMV4L:" ${HAVE_CAMV4L})
status(" HAVE_CAMV4L2:" ${HAVE_CAMV4L2})
status(" HAVE_VIDEOIO:" ${HAVE_VIDEOIO})
cd build_android_arm
make
make install
#include <android/log.h>
#undef LOG_TAG
#undef LOGD
#undef LOGE
#undef LOGI
#define LOG_TAG "OpenCV::android_v4l2"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#博客案例:OpenCV4Android释疑:,透析Android以JNI调OpenCV的三种方式(让OpenCVManager永不困扰)
LIB_TYPE = STATIC
ifeq ($(LIB_TYPE), STATIC)
#STATIC链接时,可以不额外携带其依赖库
#当JNI里面调用了cvCaptureFromCAM去打开AndroidNativeCamera,就需要OPENCV_CAMERA_MODULES:=on
#来增加libnative_camera_r4.4.0.so
OPENCV_LIB_TYPE:=STATIC
OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=on
else
#SHARED链接时,必须携带其依赖库,否则运行报错
OPENCV_LIB_TYPE:=SHARED
OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=on
endif
#原始openCV4Android SDK
#include ../../openCV_2410_sdk/native/jni/OpenCV.mk
#添加V4L2,重新编译后的openCV4Android SDK
include ../../openCV_2410_sdk_v4l2/native/jni/OpenCV.mk
$(warning "****************************************")
$(warning $(LOCAL_C_INCLUDES))
LOCAL_LDLIBS += -llog
LOCAL_SHARED_LIBRARIES += \
libandroid_runtime\
liblog \
libcutils \
libnativehelper \
libcore/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_SRC_FILES := ImageProc.cpp
LOCAL_MODULE := image_proc
include $(BUILD_SHARED_LIBRARY)
01-01 02:15:19.843: I/luo.uvc.jni(6649): open uvc3 ......
01-01 02:15:19.844: I/OPENCV_LUO(6649): usb camera Java_luo_uvc_jni_ImageProc_connectCamera start ....
01-01 02:15:19.844: I/OPENCV_LUO(6649): usb camera (-1) Java_luo_uvc_jni_ImageProc_connectCamera
01-01 02:15:19.844: I/OpenCV::android_v4l2(6649): CvCaptureCAM_V4L_CPP::CvCaptureCAM_V4L_CPP(-1)
01-01 02:15:19.844: I/OpenCV::android_v4l2(6649): icvCaptureFromCAM_V4L::use /dev/video0
01-01 02:15:19.844: E/OPENCV_LUO(6649): usb camera 0 open success!
01-01 02:15:19.844: I/luo.uvc.jni(6649): open uvc success!!!
02:20:51.968: D/dalvikvm(6834): Trying to load lib /data/app-lib/CameraTouch/libNDKBase.so 0x41ce1eb0
01-01 02:20:51.986: E/ION_DEBUG(6834): [add_system_map_entry]so libNDKBase.so address 0x612b7000 size 3563520 has been load into memory ion_debug_lock 0x404ad01c
01-01 02:20:52.033: D/dalvikvm(6834): Added shared lib /data/app-lib/CameraTouch/libNDKBase.so 0x41ce1eb0
01-01 02:20:52.034: D/dalvikvm(6834): No JNI_OnLoad found in /data/app-lib/CameraTouch/libNDKBase.so 0x41ce1eb0, skipping init
01-01 02:20:52.035: D/NDKBASE(6834): CMPBase::CMPBase()
01-01 02:20:52.036: D/NDKBASE(6834): CHelper::Open END
01-01 02:20:52.036: D/NDKBASE(6834): Java_com_indesign_cameratouch_NDKBase_OpenTouchNDK
01-01 02:20:52.037: D/NDKBASE(6834): CImageBase::captureThread start
01-01 02:20:52.037: D/NDKBASE(6834): CImageBase::captureThread start111
01-01 02:20:52.038: D/NDKBASE(6834): CImageBase::captureThread start00
01-01 02:20:52.038: D/NDKBASE(6834): CImageBase::captureThread start11
01-01 02:20:52.040: D/NDKBASE(6834): CCamInfo::checkDevice start
01-01 02:20:52.040: D/NDKBASE(6834): CCamInfo::checkDevice 1111
01-01 02:20:52.041: D/NDKBASE(6834): usb_device_added, Name: /dev/bus/usb/001/004
01-01 02:20:52.042: D/NDKBASE(6834): usb_device_added, Name: /dev/bus/usb/001/001
01-01 02:20:52.042: D/NDKBASE(6834): CCamInfo::checkDevice END0
01-01 02:20:52.042: D/NDKBASE(6834): CImageBase::captureThread start22
07-01 02:41:07.644: D/NDKBASE(6805): CMPBase::CMPBase()
07-01 02:41:07.645: D/NDKBASE(6805): CHelper::Open END
07-01 02:41:07.645: D/NDKBASE(6805): Java_com_indesign_cameratouch_NDKBase_OpenTouchNDK
07-01 02:41:07.645: D/NDKBASE(6805): CImageBase::captureThread start
07-01 02:41:07.645: D/NDKBASE(6805): CImageBase::captureThread start111
07-01 02:41:07.645: D/NDKBASE(6805): CImageBase::captureThread start00
07-01 02:41:07.645: D/NDKBASE(6805): CImageBase::captureThread start11
07-01 02:41:07.645: D/NDKBASE(6805): CCamInfo::checkDevice start
07-01 02:41:07.645: D/NDKBASE(6805): CCamInfo::checkDevice 1111
07-01 02:41:07.646: D/NDKBASE(6805): usb_device_added, Name: /dev/bus/usb/001/002
07-01 02:41:07.646: D/NDKBASE(6805): usb_device_added, Name: /dev/bus/usb/001/001
07-01 02:41:07.646: D/NDKBASE(6805): CCamInfo::checkDevice END1
07-01 02:41:07.646: D/NDKBASE(6805): CImageBase::captureThread start333
07-01 02:41:07.646: D/NDKBASE(6805): CameraId: 0, checking.
07-01 02:41:07.646: D/NDKBASE(6805): CameraId:cvCaptureFromCAM star
07-01 02:41:07.647: D/OpenCV::camera(6805): CvCapture_Android::CvCapture_Android(0)
07-01 02:41:07.647: D/OpenCV::camera(6805): Library name: libNDKBase.so
07-01 02:41:07.647: D/OpenCV::camera(6805): Library base address: 0x61191000
07-01 02:41:07.691: D/OpenCV::camera(6805): Libraries folder found: /data/app-lib/CameraTouch/
07-01 02:41:07.691: D/OpenCV::camera(6805): CameraWrapperConnector::connectToLib: folderPath=/data/app-lib/CameraTouch/
07-01 02:41:07.706: V/ActivityManager(684): Broadcast: Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } ordered=false userid=0 callerApp=ProcessRecord{41d6b1a0 684:system/1000}
07-01 02:41:07.706: D/dalvikvm(684): threadid=83: exiting
07-01 02:41:07.714: D/dalvikvm(684): threadid=83: bye!
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r4.1.1.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r4.0.3.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r2.3.3.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r4.2.0.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r2.2.0.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r3.0.1.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r4.3.0.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r4.0.0.so
07-01 02:41:07.841: E/OpenCV::camera(6805): ||libnative_camera_r4.4.0.so
07-01 02:41:07.841: D/OpenCV::camera(6805): try to load library ‘libnative_camera_r4.4.0.so‘
07-01 02:41:07.852: E/ION_DEBUG(6805): [add_system_map_entry]so libnative_camera_r4.4.0.so address 0x614f9000 size 282624 has been load into memory ion_debug_lock 0x4048601c
07-01 02:41:07.853: D/OpenCV::camera(6805): Loaded library ‘/data/app-lib/CameraTouch/libnative_camera_r4.4.0.so‘
07-01 02:41:07.854: D/OpenCV_NativeCamera(6805): CameraHandler::initCameraConnect(0x6122beed, 0, 0x6055fde8, 0x0)
07-01 02:41:07.855: D/OpenCV_NativeCamera(6805): Current process name for camera init: com.indesign.cameratouch
07-01 02:41:08.036: D/CameraService(132): CameraService::connect E (pid 6805 "com.indesign.cameratouch", id 0)
07-01 02:41:08.036: E/CameraService(132): CameraService::connect X (pid 6805) rejected (invalid cameraId 0).
07-01 02:41:08.037: W/CameraBase(6805): An error occurred while connecting to camera: 0
07-01 02:41:08.038: E/OpenCV_NativeCamera(6805): initCameraConnect: Unable to connect to CameraService
07-01 02:41:08.038: E/OpenCV::camera(6805): CameraWrapperConnector::connectWrapper ERROR: the initializing function returned false
07-01 02:41:08.038: E/OpenCV::camera(6805): Native_camera returned opening error: 6
07-01 02:41:08.038: D/NDKBASE(6805): CameraId: 0, fail.
07-01 02:41:08.038: D/NDKBASE(6805): CImageBase::captureThread start333
07-01 02:41:08.038: D/NDKBASE(6805): CameraId: 1, checking.
07-01 02:41:08.038: D/NDKBASE(6805): CameraId:cvCaptureFromCAM star
07-01 02:41:08.038: D/OpenCV::camera(6805): CvCapture_Android::CvCapture_Android(1)
07-01 02:41:08.038: D/OpenCV_NativeCamera(6805): CameraHandler::initCameraConnect(0x6122beed, 1, 0x6055fde8, 0x0)
07-01 02:41:08.038: D/OpenCV_NativeCamera(6805): Current process name for camera init: com.indesign.cameratouch
07-01 02:41:08.040: D/CameraService(132): CameraService::connect E (pid 6805 "com.indesign.cameratouch", id 1)
07-01 02:41:08.040: E/CameraService(132): CameraService::connect X (pid 6805) rejected (invalid cameraId 1).
07-01 02:41:08.041: W/CameraBase(6805): An error occurred while connecting to camera: 1
07-01 02:41:08.041: E/OpenCV_NativeCamera(6805): initCameraConnect: Unable to connect to CameraService
07-01 02:41:08.041: E/OpenCV::camera(6805): CameraWrapperConnector::connectWrapper ERROR: the initializing function returned false
07-01 02:41:08.041: E/OpenCV::camera(6805): Native_camera returned opening error: 6
07-01 02:41:08.041: D/NDKBASE(6805): CameraId: 1, fail.
frame = cvQueryFrame(capture); //取图片帧
case PALETTE_YUYV:
LOGI("icvRetrieveFrameCAM_V4L: capture->palette = PALETTE_YUYV");
yuyv_to_rgb24(capture->form.fmt.pix.width,
capture->form.fmt.pix.height,
(unsigned char*)(capture->buffers[capture->bufferIndex].start),
(unsigned char*)capture->frame.imageData);
break;
标签:
原文地址:http://blog.csdn.net/luoyouren/article/details/51818523