diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f9ac71107..adc457c4c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON ) OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC ) OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF ANDROID AND NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX ) -OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_USE_STLPORT AND ANDROID_SOURCE_TREE ) +OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE ) OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID ) # 3rd party libs @@ -468,6 +468,10 @@ if(BUILD_ANDROID_PACKAGE) add_subdirectory(android/package) endif() +if (ANDROID AND NOT BUILD_ANDROID_SERVICE AND NOT BUILD_ANDROID_PACKAGE AND NOT BUILD_CAMERA_WRAPER) + add_subdirectory(android/libinfo) +endif() + # ---------------------------------------------------------------------------- # Finalization: generate configuration-based files # ---------------------------------------------------------------------------- diff --git a/android/README.android b/android/README.android index 46207b0305..dd870b28ea 100644 --- a/android/README.android +++ b/android/README.android @@ -1 +1 @@ -See http://code.opencv.org/projects/opencv/wiki/OpenCV4Android +See http://opencv.org/android diff --git a/android/libinfo/CMakeLists.txt b/android/libinfo/CMakeLists.txt new file mode 100644 index 0000000000..f8e8e15afe --- /dev/null +++ b/android/libinfo/CMakeLists.txt @@ -0,0 +1,39 @@ +project(libopencv_info) +if(NOT ANDROID_PACKAGE_RELEASE) + set(ANDROID_PACKAGE_RELEASE 1) +endif() + +if(NOT ANDROID_PACKAGE_PLATFORM) + if(ARMEABI_V7A) + if(NEON) + set(ANDROID_PACKAGE_PLATFORM armv7a_neon) + else() + set(ANDROID_PACKAGE_PLATFORM armv7a) + endif() + elseif(ARMEABI_V6) + set(ANDROID_PACKAGE_PLATFORM armv6) + elseif(ARMEABI) + set(ANDROID_PACKAGE_PLATFORM armv5) + elseif(X86) + set(ANDROID_PACKAGE_PLATFORM x86) + elseif(MIPS) + set(ANDROID_PACKAGE_PLATFORM mips) + else() + message(ERROR "Can not automatically determine the value for ANDROID_PACKAGE_PLATFORM") + endif() +endif() + +add_definitions(-DANDROID_PACKAGE_RELEASE=${ANDROID_PACKAGE_RELEASE} -DANDROID_PACKAGE_PLATFORM="${ANDROID_PACKAGE_PLATFORM}") + +include_directories(jni/BinderComponent jni/include "${OpenCV_SOURCE_DIR}/modules/core/include") + +add_library(opencv_info SHARED info.c) + +set_target_properties(${the_module} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} + INSTALL_NAME_DIR lib + ) + +get_filename_component(lib_name "opencv_info" NAME) +install(FILES "${LIBRARY_OUTPUT_PATH}/${lib_name}" DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) \ No newline at end of file diff --git a/android/libinfo/info.c b/android/libinfo/info.c new file mode 100644 index 0000000000..f1e5bf01ed --- /dev/null +++ b/android/libinfo/info.c @@ -0,0 +1,31 @@ +#include "opencv2/core/version.hpp" +#include + +const char* GetPackageName(void); +const char* GetRevision(void); +const char* GetLibraryList(void); +JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv *, jclass); + +#define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" ANDROID_PACKAGE_PLATFORM +#define PACKAGE_REVISION CVAUX_STR(CV_SUBMINOR_VERSION) CVAUX_STR(ANDROID_PACKAGE_RELEASE) + +const char* GetPackageName(void) +{ + return PACKAGE_NAME; +} + +const char* GetRevision(void) +{ + return PACKAGE_REVISION; +} + +const char* GetLibraryList(void) +{ + return ""; +} + +JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv * env, jclass clazz) +{ + (void)clazz; + return (*env)->NewStringUTF(env, GetLibraryList()); +} diff --git a/android/scripts/cmake_android_all_cameras.py b/android/scripts/cmake_android_all_cameras.py index f44710424b..75470e9c8d 100755 --- a/android/scripts/cmake_android_all_cameras.py +++ b/android/scripts/cmake_android_all_cameras.py @@ -10,11 +10,11 @@ HomeDir = os.getcwd() for s in ConfFile.readlines(): s = s[0:s.find("#")] if (not s): - continue + continue keys = s.split(";") if (len(keys) < 4): - print("Error: invalid config line: \"%s\"" % s) - continue + print("Error: invalid config line: \"%s\"" % s) + continue MakeTarget = str.strip(keys[0]) Arch = str.strip(keys[1]) NativeApiLevel = str.strip(keys[2]) @@ -22,37 +22,41 @@ for s in ConfFile.readlines(): AndroidTreeRoot = str.strip(AndroidTreeRoot, "\n") print("Building %s for %s" % (MakeTarget, Arch)) BuildDir = os.path.join(HomeDir, MakeTarget + "_" + Arch) + if (os.path.exists(BuildDir)): - shutil.rmtree(BuildDir) + shutil.rmtree(BuildDir) + try: - os.mkdir(BuildDir) + os.mkdir(BuildDir) except: - print("Error: cannot create direcotry \"%s\"" % BuildDir) - continue + print("Error: cannot create direcotry \"%s\"" % BuildDir) + continue + shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True) if (Arch == "x86"): - shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system")) + shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system")) elif (Arch == "mips"): - shutil.copytree(os.path.join(AndroidTreeRoot, "bin_mips", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system")) + shutil.copytree(os.path.join(AndroidTreeRoot, "bin_mips", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system")) else: - shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system")) + shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system")) + os.chdir(BuildDir) BuildLog = os.path.join(BuildDir, "build.log") - CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_USE_STLPORT=ON ../../ > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog) + CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_STL=stlport_static ../../ > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog) MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog); - #print(CmakeCmdLine) + print(CmakeCmdLine) os.system(CmakeCmdLine) - #print(MakeCmdLine) + print(MakeCmdLine) os.system(MakeCmdLine) os.chdir(HomeDir) CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so") if (os.path.exists(CameraLib)): - try: - shutil.copyfile(CameraLib, os.path.join("..", "3rdparty", "lib", Arch, "lib" + MakeTarget + ".so")) - print("Building %s for %s\t[\033[92mOK\033[0m]" % (MakeTarget, Arch)); - except: - print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch)); + try: + shutil.copyfile(CameraLib, os.path.join("..", "3rdparty", "lib", Arch, "lib" + MakeTarget + ".so")) + print("Building %s for %s\t[\033[92mOK\033[0m]" % (MakeTarget, Arch)); + except: + print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch)); else: - print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch)); -ConfFile.close() + print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch)); +ConfFile.close() diff --git a/android/scripts/cmake_android_service.sh b/android/scripts/cmake_android_service.sh index eb30991826..3503bb73d3 100755 --- a/android/scripts/cmake_android_service.sh +++ b/android/scripts/cmake_android_service.sh @@ -4,5 +4,5 @@ cd `dirname $0`/.. mkdir -p build_service cd build_service -cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_USE_STLPORT=ON -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/2.2.2/ $@ ../.. +cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../.. diff --git a/android/service/doc/AndroidAppUsageModel.dia b/android/service/doc/AndroidAppUsageModel.dia index 9f71469856..0313d5c642 100644 Binary files a/android/service/doc/AndroidAppUsageModel.dia and b/android/service/doc/AndroidAppUsageModel.dia differ diff --git a/android/service/doc/build_uml.py b/android/service/doc/build_uml.py index 9909a73c44..df9eb7bcd5 100755 --- a/android/service/doc/build_uml.py +++ b/android/service/doc/build_uml.py @@ -20,4 +20,4 @@ if (not os.path.exists(TARGET_PATH)): for filename in os.listdir("."): if ("dia" == filename[-3:]): - os.system("%s --export %s %s" % (DiaPath, os.path.join(TARGET_PATH, filename[0:len(filename)-4] + ".png"), filename)) \ No newline at end of file + os.system("%s --export %s %s" % (DiaPath, os.path.join(TARGET_PATH, filename[0:len(filename)-4] + ".png"), filename)) \ No newline at end of file diff --git a/android/service/doc/img/AndroidAppUsageModel.png b/android/service/doc/img/AndroidAppUsageModel.png index 81d03acaa8..b5ec637c7f 100644 Binary files a/android/service/doc/img/AndroidAppUsageModel.png and b/android/service/doc/img/AndroidAppUsageModel.png differ diff --git a/android/service/engine/AndroidManifest.xml b/android/service/engine/AndroidManifest.xml index f29c72f531..b1d6f691c3 100644 --- a/android/service/engine/AndroidManifest.xml +++ b/android/service/engine/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="20" + android:versionName="2.0" > diff --git a/android/service/engine/CMakeLists.txt b/android/service/engine/CMakeLists.txt index 87c8635b7d..529aef9bd5 100644 --- a/android/service/engine/CMakeLists.txt +++ b/android/service/engine/CMakeLists.txt @@ -1,10 +1,16 @@ set(engine OpenCVEngine) set(JNI_LIB_NAME ${engine} ${engine}_jni) + +unset(__android_project_chain CACHE) add_android_project(opencv_engine "${CMAKE_CURRENT_SOURCE_DIR}" SDK_TARGET 8 ${ANDROID_SDK_TARGET} IGNORE_JAVA ON) -link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib" "${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib" "${ANDROID_SOURCE_TREE}/bin_${ANDROID_ARCH_NAME}/system/lib") +link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib" "${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib" "${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}") -SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-allow-shlib-undefined") +# -D__SUPPORT_ARMEABI_FEATURES key is also available +add_definitions(-DPLATFORM_ANDROID -D__SUPPORT_ARMEABI_V7A_FEATURES -D__SUPPORT_TEGRA3 -D__SUPPORT_MIPS) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") + +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-allow-shlib-undefined") file(GLOB engine_files "jni/BinderComponent/*.cpp" "jni/BinderComponent/*.h" "jni/include/*.h") include_directories(jni/BinderComponent jni/include) diff --git a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp index 6b99799933..e08082004c 100644 --- a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp +++ b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp @@ -130,7 +130,7 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version) LOGD("Trying to load info library \"%s\"", tmp.c_str()); void* handle; - char* (*info_func)(); + const char* (*info_func)(); handle = dlopen(tmp.c_str(), RTLD_LAZY); if (handle) diff --git a/android/service/engine/jni/JNIWrapper/HardwareDetector_jni.cpp b/android/service/engine/jni/JNIWrapper/HardwareDetector_jni.cpp index b55c0b8e3d..be30d877b7 100644 --- a/android/service/engine/jni/JNIWrapper/HardwareDetector_jni.cpp +++ b/android/service/engine/jni/JNIWrapper/HardwareDetector_jni.cpp @@ -3,7 +3,7 @@ #include #include -JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetCpuID(JNIEnv* env, jclass) +JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetCpuID(JNIEnv* , jclass) { return GetCpuID(); } @@ -14,12 +14,12 @@ JNIEXPORT jstring JNICALL Java_org_opencv_engine_HardwareDetector_GetPlatformNam return env->NewStringUTF(hardware_name.c_str()); } -JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetProcessorCount(JNIEnv* env, jclass) +JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_GetProcessorCount(JNIEnv* , jclass) { return GetProcessorCount(); } -JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_DetectKnownPlatforms(JNIEnv* env, jclass) +JNIEXPORT jint JNICALL Java_org_opencv_engine_HardwareDetector_DetectKnownPlatforms(JNIEnv* , jclass) { return DetectKnownPlatforms(); } \ No newline at end of file diff --git a/android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp b/android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp index 96b5dc3115..dac4916563 100644 --- a/android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp +++ b/android/service/engine/jni/JNIWrapper/OpenCVEngine_jni.cpp @@ -30,7 +30,7 @@ JNIEXPORT jobject JNICALL Java_org_opencv_engine_BinderConnector_Connect(JNIEnv* return javaObjectForIBinder(env, OpenCVEngineBinder); } -JNIEXPORT jboolean JNICALL Java_org_opencv_engine_BinderConnector_Init(JNIEnv* env, jobject thiz, jobject market) +JNIEXPORT jboolean JNICALL Java_org_opencv_engine_BinderConnector_Init(JNIEnv* env, jobject , jobject market) { LOGD("Java_org_opencv_engine_BinderConnector_Init"); diff --git a/android/service/engine/jni/NativeService/PackageInfo.cpp b/android/service/engine/jni/NativeService/PackageInfo.cpp index 67b608d04d..237e979d8d 100644 --- a/android/service/engine/jni/NativeService/PackageInfo.cpp +++ b/android/service/engine/jni/NativeService/PackageInfo.cpp @@ -363,7 +363,7 @@ InstallPath(install_path) } else { - LOGE("Library loading error (%x, %x): \"%s\"", name_func, revision_func, error); + LOGE("Library loading error (%p, %p): \"%s\"", name_func, revision_func, error); } } else diff --git a/android/service/engine/jni/include/EngineCommon.h b/android/service/engine/jni/include/EngineCommon.h index 99b5af30d3..67a94e270f 100644 --- a/android/service/engine/jni/include/EngineCommon.h +++ b/android/service/engine/jni/include/EngineCommon.h @@ -6,7 +6,7 @@ #define LOG_TAG "OpenCVEngine" #ifndef OPEN_CV_ENGINE_VERSION - #define OPEN_CV_ENGINE_VERSION 1 + #define OPEN_CV_ENGINE_VERSION 2 #endif #define LIB_OPENCV_INFO_NAME "libopencv_info.so" diff --git a/doc/conf.py b/doc/conf.py index 7abafa3596..40b8e27137 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -293,7 +293,7 @@ extlinks = { 'svms':('http://opencv.itseez.com/modules/ml/doc/support_vector_machines.html#%s', None), 'drawingfunc':('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#%s', None), 'xmlymlpers':('http://opencv.itseez.com/modules/core/doc/xml_yaml_persistence.html#%s', None), - 'huivideo' : ('http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None), + 'hgvideo' : ('http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None), 'gpuinit' : ('http://opencv.itseez.com/modules/gpu/doc/initalization_and_information.html#%s', None), 'gpudatastructure' : ('http://opencv.itseez.com/modules/gpu/doc/data_structures.html#%s', None), 'gpuopmatrices' : ('http://opencv.itseez.com/modules/gpu/doc/operations_on_matrices.html#%s', None), diff --git a/doc/opencv2manager.pdf b/doc/opencv2manager.pdf index 341c1a5455..b70f8cd783 100644 Binary files a/doc/opencv2manager.pdf and b/doc/opencv2manager.pdf differ diff --git a/doc/opencv2refman.pdf b/doc/opencv2refman.pdf index ace7d26370..b2ed9cafdd 100644 Binary files a/doc/opencv2refman.pdf and b/doc/opencv2refman.pdf differ diff --git a/doc/opencv_cheatsheet.pdf b/doc/opencv_cheatsheet.pdf index fbb5986bbf..6616d9bd72 100644 Binary files a/doc/opencv_cheatsheet.pdf and b/doc/opencv_cheatsheet.pdf differ diff --git a/doc/opencv_tutorials.pdf b/doc/opencv_tutorials.pdf index ac8cb9d220..f6e7a8dbb9 100644 Binary files a/doc/opencv_tutorials.pdf and b/doc/opencv_tutorials.pdf differ diff --git a/doc/opencv_user.pdf b/doc/opencv_user.pdf index 1602670f76..db0ffb27b1 100644 Binary files a/doc/opencv_user.pdf and b/doc/opencv_user.pdf differ diff --git a/doc/tutorials/highgui/video-input-psnr-ssim/video-input-psnr-ssim.rst b/doc/tutorials/highgui/video-input-psnr-ssim/video-input-psnr-ssim.rst index 1f0012e230..1f024ac93d 100644 --- a/doc/tutorials/highgui/video-input-psnr-ssim/video-input-psnr-ssim.rst +++ b/doc/tutorials/highgui/video-input-psnr-ssim/video-input-psnr-ssim.rst @@ -27,9 +27,9 @@ As a test case where to show off these using OpenCV I've created a small program How to read a video stream (online-camera or offline-file)? =========================================================== -Essentially, all the functionalities required for video manipulation is integrated in the :huivideo:`VideoCapture ` C++ class. This on itself builds on the FFmpeg open source library. This is a basic dependency of OpenCV so you shouldn't need to worry about this. A video is composed of a succession of images, we refer to these in the literature as frames. In case of a video file there is a *frame rate* specifying just how long is between two frames. While for the video cameras usually there is a limit of just how many frames they can digitalize per second, this property is less important as at any time the camera sees the current snapshot of the world. +Essentially, all the functionalities required for video manipulation is integrated in the :hgvideo:`VideoCapture ` C++ class. This on itself builds on the FFmpeg open source library. This is a basic dependency of OpenCV so you shouldn't need to worry about this. A video is composed of a succession of images, we refer to these in the literature as frames. In case of a video file there is a *frame rate* specifying just how long is between two frames. While for the video cameras usually there is a limit of just how many frames they can digitalize per second, this property is less important as at any time the camera sees the current snapshot of the world. -The first task you need to do is to assign to a :huivideo:`VideoCapture ` class its source. You can do this either via the :huivideo:`constructor ` or its :huivideo:`open ` function. If this argument is an integer then you will bind the class to a camera, a device. The number passed here is the ID of the device, assigned by the operating system. If you have a single camera attached to your system its ID will probably be zero and further ones increasing from there. If the parameter passed to these is a string it will refer to a video file, and the string points to the location and name of the file. For example, to the upper source code a valid command line is: +The first task you need to do is to assign to a :hgvideo:`VideoCapture ` class its source. You can do this either via the :hgvideo:`constructor ` or its :hgvideo:`open ` function. If this argument is an integer then you will bind the class to a camera, a device. The number passed here is the ID of the device, assigned by the operating system. If you have a single camera attached to your system its ID will probably be zero and further ones increasing from there. If the parameter passed to these is a string it will refer to a video file, and the string points to the location and name of the file. For example, to the upper source code a valid command line is: .. code-block:: bash @@ -46,7 +46,7 @@ We do a similarity check. This requires a reference and a test case video file. VideoCapture captUndTst; captUndTst.open(sourceCompareWith); -To check if the binding of the class to a video source was successful or not use the :huivideo:`isOpened ` function: +To check if the binding of the class to a video source was successful or not use the :hgvideo:`isOpened ` function: .. code-block:: cpp @@ -56,7 +56,7 @@ To check if the binding of the class to a video source was successful or not use return -1; } -Closing the video is automatic when the objects destructor is called. However, if you want to close it before this you need to call its :huivideo:`release ` function. The frames of the video are just simple images. Therefore, we just need to extract them from the :huivideo:`VideoCapture ` object and put them inside a *Mat* one. The video streams are sequential. You may get the frames one after another by the :huivideo:`read ` or the overloaded >> operator: +Closing the video is automatic when the objects destructor is called. However, if you want to close it before this you need to call its :hgvideo:`release ` function. The frames of the video are just simple images. Therefore, we just need to extract them from the :hgvideo:`VideoCapture ` object and put them inside a *Mat* one. The video streams are sequential. You may get the frames one after another by the :hgvideo:`read ` or the overloaded >> operator: .. code-block:: cpp @@ -73,9 +73,9 @@ The upper read operations will leave empty the *Mat* objects if no frame could b // exit the program } -A read method is made of a frame grab and a decoding applied on that. You may call explicitly these two by using the :huivideo:`grab ` and then the :huivideo:`retrieve ` functions. +A read method is made of a frame grab and a decoding applied on that. You may call explicitly these two by using the :hgvideo:`grab ` and then the :hgvideo:`retrieve ` functions. -Videos have many-many information attached to them besides the content of the frames. These are usually numbers, however in some case it may be short character sequences (4 bytes or less). Due to this to acquire these information there is a general function named :huivideo:`get ` that returns double values containing these properties. Use bitwise operations to decode the characters from a double type and conversions where valid values are only integers. Its single argument is the ID of the queried property. For example, here we get the size of the frames in the reference and test case video file; plus the number of frames inside the reference. +Videos have many-many information attached to them besides the content of the frames. These are usually numbers, however in some case it may be short character sequences (4 bytes or less). Due to this to acquire these information there is a general function named :hgvideo:`get ` that returns double values containing these properties. Use bitwise operations to decode the characters from a double type and conversions where valid values are only integers. Its single argument is the ID of the queried property. For example, here we get the size of the frames in the reference and test case video file; plus the number of frames inside the reference. .. code-block:: cpp @@ -85,7 +85,7 @@ Videos have many-many information attached to them besides the content of the fr cout << "Reference frame resolution: Width=" << refS.width << " Height=" << refS.height << " of nr#: " << captRefrnc.get(CV_CAP_PROP_FRAME_COUNT) << endl; -When you are working with videos you may often want to control these values yourself. To do this there is a :huivideo:`set ` function. Its first argument remains the name of the property you want to change and there is a second of double type containing the value to be set. It will return true if it succeeds and false otherwise. Good examples for this is seeking in a video file to a given time or frame: +When you are working with videos you may often want to control these values yourself. To do this there is a :hgvideo:`set ` function. Its first argument remains the name of the property you want to change and there is a second of double type containing the value to be set. It will return true if it succeeds and false otherwise. Good examples for this is seeking in a video file to a given time or frame: .. code-block:: cpp @@ -93,7 +93,7 @@ When you are working with videos you may often want to control these values your captRefrnc.set(CV_CAP_PROP_POS_FRAMES, 10); // go to the 10th frame of the video // now a read operation would read the frame at the set position -For properties you can read and change look into the documentation of the :huivideo:`get ` and :huivideo:`set ` functions. +For properties you can read and change look into the documentation of the :hgvideo:`get ` and :hgvideo:`set ` functions. Image similarity - PSNR and SSIM diff --git a/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst b/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst index afd7b77e6e..b46e417d5a 100644 --- a/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst +++ b/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst @@ -7,9 +7,10 @@ OpenCV4Android SDK This tutorial was designed to help you with installation and configuration of OpenCV4Android SDK. -This guide was written with MS Windows 7 in mind, though it should work with GNU Linux and Apple MacOS as well. +This guide was written with MS Windows 7 in mind, though it should work with GNU Linux and Apple +Mac OS as well. -This tutorial assumes you have the following installed and configured: +This tutorial assumes you have the following software installed and configured: * JDK @@ -23,7 +24,20 @@ This tutorial assumes you have the following installed and configured: If you need help with anything of the above, you may refer to our :ref:`android_dev_intro` guide. -If you encounter any error after thoroughly following these steps, feel free to contact us via `OpenCV4Android `_ discussion group or OpenCV `Q&A forum `_. We'll do our best to help you out. +If you encounter any error after thoroughly following these steps, feel free to contact us via +`OpenCV4Android `_ discussion group or +OpenCV `Q&A forum `_. We'll do our best to help you out. + +Tegra Android Development Pack users +==================================== + +You may have used `Tegra Android Development Pack `_ +(**TADP**) released by **NVIDIA** for Android development environment setup. + +Beside Android development tools the TADP 2.0 includes OpenCV4Android SDK, so it can be already +installed in your system and you can skip to :ref:`Running_OpenCV_Samples` section of this tutorial. + +More details regarding TADP can be found in the :ref:`android_dev_intro` guide. General info ============ @@ -57,32 +71,44 @@ The structure of package contents looks as follows: * :file:`sdk` folder contains OpenCV API and libraries for Android: -* :file:`sdk/java` folder contains an Android library Eclipse project providing OpenCV Java API that can be imported into developer's workspace; +* :file:`sdk/java` folder contains an Android library Eclipse project providing OpenCV Java API that + can be imported into developer's workspace; -* :file:`sdk/native` folder contains OpenCV C++ headers (for JNI code) and native Android libraries (\*\.so and \*\.a) for ARM-v5, ARM-v7a and x86 architectures; +* :file:`sdk/native` folder contains OpenCV C++ headers (for JNI code) and native Android libraries + (\*\.so and \*\.a) for ARM-v5, ARM-v7a and x86 architectures; * :file:`sdk/etc` folder contains Haar and LBP cascades distributed with OpenCV. -* :file:`apk` folder contains Android packages that should be installed on the target Android device to enable OpenCV library access via OpenCV Manager API (see details below). +* :file:`apk` folder contains Android packages that should be installed on the target Android device + to enable OpenCV library access via OpenCV Manager API (see details below). - On production devices that have access to Google Play Market (and internet) these packages will be installed from Market on the first start of an application using OpenCV Manager API. - But dev kits without Market or internet require this packages to be installed manually. - (Install the `Manager.apk` and the corresponding `binary_pack.apk` depending on the device CPU, the Manager GUI provides this info). + On production devices that have access to Google Play Market (and Internet) these packages will be + installed from Market on the first start of an application using OpenCV Manager API. + But devkits without Market or Internet connection require this packages to be installed manually. + Install the `Manager.apk` and the corresponding `binary_pack.apk` depending on the device CPU, + the Manager GUI provides this info. Below you'll see exact commands on how to do this. - **Note**: installation from internet is the preferable way since we may publish updated versions of this packages on the Market. + .. note:: Installation from Internet is the preferable way since OpenCV team may publish updated + versions of this packages on the Market. * :file:`samples` folder contains sample applications projects and their prebuilt packages (APK). - Import them into Eclipse workspace (like described below) and browse the code to learn possible ways of OpenCV use on Android. + Import them into Eclipse workspace (like described below) and browse the code to learn possible + ways of OpenCV use on Android. * :file:`doc` folder contains various OpenCV documentation in PDF format. It's also available online at http://docs.opencv.org. - **Note**: the most recent docs (nightly build) are at http://docs.opencv.org/trunk/. - Generally, it's more up-to-date, but can refer to not-yet-released functionality. + .. note:: The most recent docs (nightly build) are at http://docs.opencv.org/trunk/. + Generally, it's more up-to-date, but can refer to not-yet-released functionality. -Starting version 2.4.3 `OpenCV4Android SDK` uses `OpenCV Manager` API for library initialization. `OpenCV Manager` is an Android service based solution providing the following benefits for OpenCV applications developers: +.. TODO: I'm not sure that this is the best place to talk about OpenCV Manager -* Compact apk-size, since all applications use the same binaries from Manager and do not store native libs within themselves; +Starting from version 2.4.3 `OpenCV4Android SDK` uses `OpenCV Manager` API for library +initialization. `OpenCV Manager` is an Android service based solution providing the following +benefits for OpenCV applications developers: + +* Compact apk-size, since all applications use the same binaries from Manager and do not store + native libs within themselves; * Hardware specific optimizations are automatically enabled on all supported platforms; @@ -92,7 +118,6 @@ Starting version 2.4.3 `OpenCV4Android SDK` uses `OpenCV Manager` API for librar .. - For additional information on OpenCV Manager see the: * |OpenCV4Android_Slides|_ @@ -106,29 +131,21 @@ For additional information on OpenCV Manager see the: .. |OpenCV4Android_Reference| replace:: Reference Manual .. _OpenCV4Android_Reference: http://docs.opencv.org/android/refman.html -Tegra Android Development Pack users -==================================== - -You may have used `Tegra Android Development Pack `_ -(**TADP**) released by **NVIDIA** for Android development environment setup. - -Beside Android development tools the TADP 2.0 includes OpenCV4Android SDK 2.4.2, so it can be already installed in your system and you can skip to running the ``face-detection`` sample. - -More details regarding TADP can be found in the :ref:`android_dev_intro` guide. - Manual OpenCV4Android SDK setup =============================== Get the OpenCV4Android SDK -------------------------- -#. Go to the `OpenCV dowload page on SourceForge `_ and download the latest available version. Currently it's |opencv_android_bin_pack_url|_ +#. Go to the `OpenCV download page on SourceForge `_ + and download the latest available version. Currently it's |opencv_android_bin_pack_url|_. -#. Create a new folder for Android with OpenCV development. For this tutorial I have unpacked OpenCV to the :file:`C:\\Work\\OpenCV4Android\\` directory. +#. Create a new folder for Android with OpenCV development. For this tutorial we have unpacked + OpenCV SDK to the :file:`C:\\Work\\OpenCV4Android\\` directory. - .. note:: Better to use a path without spaces in it. Otherwise you may have problems with :command:`ndk-build`. + .. note:: Better to use a path without spaces in it. Otherwise you may have problems with :command:`ndk-build`. -#. Unpack the OpenCV package into the chosen directory. +#. Unpack the SDK archive into the chosen directory. You can unpack it using any popular archiver (e.g with |seven_zip|_): @@ -148,12 +165,13 @@ Get the OpenCV4Android SDK .. |seven_zip| replace:: 7-Zip .. _seven_zip: http://www.7-zip.org/ -Open OpenCV library and samples in Eclipse ------------------------------------------- +Import OpenCV library and samples to the Eclipse +------------------------------------------------ -#. Start *Eclipse* and choose your workspace location. +#. Start Eclipse and choose your workspace location. - We recommend to start working with OpenCV for Android from a new clean workspace. A new Eclipse workspace can for example be created in the folder where you have unpacked OpenCV4Android SDK package: + We recommend to start working with OpenCV for Android from a new clean workspace. A new Eclipse + workspace can for example be created in the folder where you have unpacked OpenCV4Android SDK package: .. image:: images/eclipse_1_choose_workspace.png :alt: Choosing C:\Work\android-opencv\ as workspace location @@ -162,24 +180,28 @@ Open OpenCV library and samples in Eclipse #. Import OpenCV library and samples into workspace. OpenCV library is packed as a ready-for-use `Android Library Project - `_. You can simply reference it in your projects. + `_. + You can simply reference it in your projects. - Each sample included into the |opencv_android_bin_pack| is a regular Android project that already references OpenCV library. - Follow the steps below to import OpenCV and samples into the workspace: + Each sample included into the |opencv_android_bin_pack| is a regular Android project that already + references OpenCV library.Follow the steps below to import OpenCV and samples into the workspace: - * Right click on the :guilabel:`Package Explorer` window and choose :guilabel:`Import...` option from the context menu: + * Right click on the :guilabel:`Package Explorer` window and choose :guilabel:`Import...` option + from the context menu: .. image:: images/eclipse_5_import_command.png :alt: Select Import... from context menu :align: center - * In the main panel select :menuselection:`General --> Existing Projects into Workspace` and press :guilabel:`Next` button: + * In the main panel select :menuselection:`General --> Existing Projects into Workspace` and + press :guilabel:`Next` button: .. image:: images/eclipse_6_import_existing_projects.png :alt: General > Existing Projects into Workspace :align: center - * In the :guilabel:`Select root directory` field locate your OpenCV package folder. Eclipse should automatically locate OpenCV library and samples: + * In the :guilabel:`Select root directory` field locate your OpenCV package folder. Eclipse + should automatically locate OpenCV library and samples: .. image:: images/eclipse_7_select_projects.png :alt: Locate OpenCV library and samples @@ -187,34 +209,20 @@ Open OpenCV library and samples in Eclipse * Click :guilabel:`Finish` button to complete the import operation. - After clicking :guilabel:`Finish` button Eclipse will load all selected projects into workspace. Numerous errors will be indicated: + After clicking :guilabel:`Finish` button Eclipse will load all selected projects into workspace, + and you have to wait some time while it is building OpenCV samples. Just give a minute to + Eclipse to complete initialization. - .. image:: images/eclipse_8_false_alarm.png - :alt: Confusing Eclipse screen with numerous errors - :align: center + .. note :: After the initial import, on a non-Windows (Linux and Mac OS) operating system Eclipse + will still show build errors for applications with native C++ code. To resolve the + issues, please do the following: - However, **all these errors are only false-alarms**! + Open :guilabel:`Project Properties -> C/C++ Build`, and replace "Build command" text + to ``"${NDKROOT}/ndk-build"`` (remove .cmd at the end). - Just give a minute to Eclipse to complete initialization. - - In some cases these errors disappear after :menuselection:`Project --> Clean... --> Clean all --> OK` - or after pressing :kbd:`F5` (for Refresh action) when selecting error-label-marked projects in :guilabel:`Package Explorer`. - - Sometimes more advanced manipulations are required: - - The provided projects are configured for ``API 11`` target (and ``API 9`` for the library) that can be missing platform in your Android SDK. - After right click on any project select :guilabel:`Properties` and then :guilabel:`Android` on the left pane. - Click some target with `API Level` 11 or higher: - - .. image:: images/eclipse_8a_target.png - :alt: Updating target - :align: center - - Eclipse will rebuild your workspace and error icons will disappear one by one: - - .. image:: images/eclipse_9_errors_dissapearing.png - :alt: After small help Eclipse removes error icons! - :align: center + .. image:: images/eclipse_cdt_cfg4.png + :alt: Configure CDT + :align: center Once Eclipse completes build you will have the clean workspace without any build errors: @@ -227,13 +235,17 @@ Open OpenCV library and samples in Eclipse Running OpenCV Samples ---------------------- -At this point you should be able to build and run the samples. Keep in mind, that ``face-detection``, ``Tutorial 3`` and ``Tutorial 4`` include some native code and require Android NDK and CDT plugin for Eclipse to build working applications. -If you haven't installed these tools see the corresponding section of :ref:`Android_Dev_Intro`. +At this point you should be able to build and run the samples. Keep in mind, that ``face-detection``, +``Tutorial 3`` and ``Tutorial 4`` include some native code and require Android NDK and CDT plugin +for Eclipse to build working applications. If you haven't installed these tools see the corresponding +section of :ref:`Android_Dev_Intro`. -Also, please consider that ``Tutorial 0`` and ``Tutorial 1`` samples use Java Camera API that definitelly accessible on emulator from the Android SDK. +Also, please consider that ``Tutorial 0`` and ``Tutorial 1`` samples use Java Camera API that +definitelly accessible on emulator from the Android SDK. Other samples use OpenCV Native Camera which may not work with emulator. -.. note:: Recent *Android SDK tools, revision 19+* can run ARM v7a OS images but they available not for all Android versions. +.. note:: Recent *Android SDK tools, revision 19+* can run ARM v7a OS images but they available not + for all Android versions. Well, running samples from Eclipse is very simple: @@ -245,7 +257,8 @@ Well, running samples from Eclipse is very simple: `_ for help with real devices (not emulators). -* Select project you want to start in :guilabel:`Package Explorer` and just press :kbd:`Ctrl + F11` or select option :menuselection:`Run --> Run` from the main menu, or click :guilabel:`Run` button on the toolbar. +* Select project you want to start in :guilabel:`Package Explorer` and just press :kbd:`Ctrl + F11` + or select option :menuselection:`Run --> Run` from the main menu, or click :guilabel:`Run` button on the toolbar. .. note:: Android Emulator can take several minutes to start. So, please, be patient. diff --git a/doc/tutorials/introduction/android_binary_package/android_dev_intro.rst b/doc/tutorials/introduction/android_binary_package/android_dev_intro.rst index 5dd1c40f62..d004132d0f 100644 --- a/doc/tutorials/introduction/android_binary_package/android_dev_intro.rst +++ b/doc/tutorials/introduction/android_binary_package/android_dev_intro.rst @@ -5,47 +5,63 @@ Introduction into Android Development ************************************* -This guide was designed to help you in learning Android development basics and seting up your working environment quickly. +This guide was designed to help you in learning Android development basics and seting up your +working environment quickly. It was written with Windows 7 in mind, though it would work with Linux +(Ubuntu), Mac OS X and any other OS supported by Android SDK. -This guide was written with Windows 7 in mind, though it would work with Linux (Ubuntu), Mac OS X and any other OS supported by Android SDK. - -If you encounter any error after thoroughly following these steps, feel free to contact us via `OpenCV4Android `_ discussion group or OpenCV `Q&A forum `_. We'll do our best to help you out. +If you encounter any error after thoroughly following these steps, feel free to contact us via +`OpenCV4Android `_ discussion group or +OpenCV `Q&A forum `_. We'll do our best to help you out. Preface ======= -Android is a Linux-based, open source mobile operating system developed by Open Handset Alliance led by Google. See the `Android home site `_ for general details. +Android is a Linux-based, open source mobile operating system developed by Open Handset Alliance +led by Google. See the `Android home site `_ for general details. Development for Android significantly differs from development for other platforms. -So before starting programming for Android we recommend you make sure that you are familiar with the following key topis: +So before starting programming for Android we recommend you make sure that you are familiar with the +following key topis: + +#. `Java `_ programming language that is + the primary development technology for Android OS. Also, you can find + `Oracle docs on Java `_ useful. +#. `Java Native Interface (JNI) `_ that is a + technology of running native code in Java virtual machine. Also, you can find + `Oracle docs on JNI `_ useful. +#. `Android Activity `_ + and its lifecycle, that is an essential Android API class. +#. OpenCV development will certainly require some knowlege of the + `Android Camera `_ specifics. -#. `Java `_ programming language that is the primary development technology for Android OS. Also, you can find `Oracle docs on Java `_ useful. -#. `Java Native Interface (JNI) `_ that is a technology of running native code in Java virtual machine. Also, you can find `Oracle docs on JNI `_ useful. -#. `Android Activity `_ and its lifecycle, that is an essential Android API class. -#. OpenCV development will certainly require some knowlege of the `Android Camera `_ specifics. Quick environment setup for Android development =============================================== -If you are making a clean environment install, then you can try `Tegra Android Development Pack `_ +If you are making a clean environment install, then you can try `Tegra Android Development Pack `_ (**TADP**) released by **NVIDIA**. + .. note:: Starting the *version 2.0* the TADP package includes *OpenCV for Tegra* SDK that is a regular *OpenCV4Android SDK* extended with Tegra-specific stuff. + When unpacked, TADP will cover all of the environment setup automatically and you can skip the rest of the guide. If you are a beginner in Android development then we also recommend you to start with TADP. -.. note:: *NVIDIA*\ 's Tegra Android Development Pack includes some special features for |Nvidia_Tegra_Platform|_ but its use is not limited to *Tegra* devices only. + .. note:: *NVIDIA*\ 's Tegra Android Development Pack includes some special features for + |Nvidia_Tegra_Platform|_ but its use is not limited to *Tegra* devices only. - * You need at least *1.6 Gb* free disk space for the install. +* You need at least *1.6 Gb* free disk space for the install. - * TADP will download Android SDK platforms and Android NDK from Google's server, so Internet connection is required for the installation. +* TADP will download Android SDK platforms and Android NDK from Google's server, so Internet + connection is required for the installation. - * TADP may ask you to flash your development kit at the end of installation process. Just skip this step if you have no |Tegra_Development_Kit|_\ . +* TADP may ask you to flash your development kit at the end of installation process. Just skip + this step if you have no |Tegra_Development_Kit|_\ . - * (``UNIX``) TADP will ask you for *root* in the middle of installation, so you need to be a member of *sudo* group. +* (``UNIX``) TADP will ask you for *root* in the middle of installation, so you need to be a + member of *sudo* group. .. - .. |Nvidia_Tegra_Platform| replace:: *NVIDIA*\ ’s Tegra platform .. _Nvidia_Tegra_Platform: http://www.nvidia.com/object/tegra-3-processor.html .. |Tegra_Development_Kit| replace:: Tegra Development Kit @@ -53,6 +69,7 @@ If you are a beginner in Android development then we also recommend you to start .. _Android_Environment_Setup_Lite: + Manual environment setup for Android development ================================================ @@ -63,19 +80,22 @@ You need the following software to be installed in order to develop for Android #. **Sun JDK 6** - Visit `Java SE Downloads page `_ and download an installer for your OS. + Visit `Java SE Downloads page `_ + and download an installer for your OS. - Here is a detailed :abbr:`JDK (Java Development Kit)` `installation guide `_ + Here is a detailed :abbr:`JDK (Java Development Kit)` + `installation guide `_ for Ubuntu and Mac OS (only JDK sections are applicable for OpenCV) .. note:: OpenJDK is not suitable for Android development, since Android SDK supports only Sun JDK. - If you use Ubuntu, after installation of Sun JDK you should run the following command to set Sun java environment: + If you use Ubuntu, after installation of Sun JDK you should run the following command to set + Sun java environment: .. code-block:: bash sudo update-java-alternatives --set java-6-sun -.. **TODO:** add a note on Sun/Oracle Java installation on Ubuntu 12. + .. TODO: Add a note on Sun/Oracle Java installation on Ubuntu 12. #. **Android SDK** @@ -83,9 +103,13 @@ You need the following software to be installed in order to develop for Android Here is Google's `install guide `_ for the SDK. - .. note:: If you choose SDK packed into a Windows installer, then you should have 32-bit JRE installed. It is not a prerequisite for Android development, but installer is a x86 application and requires 32-bit Java runtime. + .. note:: If you choose SDK packed into a Windows installer, then you should have 32-bit JRE + installed. It is not a prerequisite for Android development, but installer is a x86 + application and requires 32-bit Java runtime. - .. note:: If you are running x64 version of Ubuntu Linux, then you need ia32 shared libraries for use on amd64 and ia64 systems to be installed. You can install them with the following command: + .. note:: If you are running x64 version of Ubuntu Linux, then you need ia32 shared libraries + for use on amd64 and ia64 systems to be installed. You can install them with the + following command: .. code-block:: bash @@ -101,51 +125,70 @@ You need the following software to be installed in order to develop for Android You need the following SDK components to be installed: - * *Android SDK Tools, revision14* or newer. + * *Android SDK Tools, revision 20* or newer. Older revisions should also work, but they are not recommended. - * *SDK Platform Android 3.0*, ``API 11`` and *Android 2.3.1*, ``API 9``. + * *SDK Platform Android 3.0* (``API 11``). - The minimal platform supported by OpenCV Java API is **Android 2.2** (``API 8``). This is also the minimum API Level required for the provided samples to run. + The minimal platform supported by OpenCV Java API is **Android 2.2** (``API 8``). This is also + the minimum API Level required for the provided samples to run. See the ```` tag in their **AndroidManifest.xml** files. - But for successful compilation of some samples the **target** platform should be set to Android 3.0 (API 11) or higher. It will not prevent them from running on Android 2.2. + But for successful compilation the **target** platform should be set to Android 3.0 (API 11) or higher. It will not prevent them from running on Android 2.2. .. image:: images/android_sdk_and_avd_manager.png - :height: 500px :alt: Android SDK Manager :align: center - See `Adding Platforms and Packages `_ for help with installing/updating SDK components. + See `Adding Platforms and Packages `_ + for help with installing/updating SDK components. #. **Eclipse IDE** - Check the `Android SDK System Requirements `_ document for a list of Eclipse versions that are compatible with the Android SDK. - For OpenCV 2.4.x we recommend **Eclipse 3.7 (Indigo)** or later versions. They work well for OpenCV under both Windows and Linux. + Check the `Android SDK System Requirements `_ + document for a list of Eclipse versions that are compatible with the Android SDK. + For OpenCV 2.4.x we recommend **Eclipse 3.7 (Indigo)** or later versions. They work well for + OpenCV under both Windows and Linux. If you have no Eclipse installed, you can get it from the `official site `_. #. **ADT plugin for Eclipse** - These instructions are copied from `Android Developers site `_, check it out in case of any ADT-related problem. + These instructions are copied from + `Android Developers site `_, + check it out in case of any ADT-related problem. - Assuming that you have Eclipse IDE installed, as described above, follow these steps to download and install the ADT plugin: + Assuming that you have Eclipse IDE installed, as described above, follow these steps to download + and install the ADT plugin: #. Start Eclipse, then select :menuselection:`Help --> Install New Software...` #. Click :guilabel:`Add` (in the top-right corner). - #. In the :guilabel:`Add Repository` dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: + #. In the :guilabel:`Add Repository` dialog that appears, enter "ADT Plugin" for the Name and the + following URL for the Location: https://dl-ssl.google.com/android/eclipse/ #. Click :guilabel:`OK` - .. note:: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons). + .. note:: If you have trouble acquiring the plugin, try using "http" in the Location URL, + instead of "https" (https is preferred for security reasons). - #. In the :guilabel:`Available Software` dialog, select the checkbox next to :guilabel:`Developer Tools` and click :guilabel:`Next`. + #. In the :guilabel:`Available Software` dialog, select the checkbox next to + :guilabel:`Developer Tools` and click :guilabel:`Next`. #. In the next window, you'll see a list of the tools to be downloaded. Click :guilabel:`Next`. + + .. note:: If you also plan to develop native C++ code with Android NDK don't forget to + enable `NDK Plugins` installations as well. + + .. image:: images/eclipse_inst_adt.png + :alt: ADT installation + :align: center + + #. Read and accept the license agreements, then click :guilabel:`Finish`. - .. note:: If you get a security warning saying that the authenticity or validity of the software can't be established, click :guilabel:`OK`. + .. note:: If you get a security warning saying that the authenticity or validity of the software + can't be established, click :guilabel:`OK`. #. When the installation completes, restart Eclipse. @@ -158,27 +201,47 @@ You need the following software to be installed in order to develop for Android To compile C++ code for Android platform you need ``Android Native Development Kit`` (*NDK*). - You can get the latest version of NDK from the `download page `_. To install Android NDK just extract the archive to some folder on your computer. Here are `installation instructions `_. + You can get the latest version of NDK from the + `download page `_. + To install Android NDK just extract the archive to some folder on your computer. Here are + `installation instructions `_. - .. note:: Before start you can read official Android NDK documentation which is in the Android NDK archive, in the folder :file:`docs/`. - - The main article about using Android NDK build system is in the :file:`ANDROID-MK.html` file. - - Some additional information you can find in the :file:`APPLICATION-MK.html`, :file:`NDK-BUILD.html` files, and :file:`CPU-ARM-NEON.html`, :file:`CPLUSPLUS-SUPPORT.html`, :file:`PREBUILTS.html`. + .. note:: Before start you can read official Android NDK documentation which is in the Android + NDK archive, in the folder :file:`docs/`. + The main article about using Android NDK build system is in the :file:`ANDROID-MK.html` file. + Some additional information you can find in the :file:`APPLICATION-MK.html`, + :file:`NDK-BUILD.html` files, and :file:`CPU-ARM-NEON.html`, :file:`CPLUSPLUS-SUPPORT.html`, + :file:`PREBUILTS.html`. #. **CDT plugin for Eclipse** - There are several possible ways to integrate compilation of C++ code by Android NDK into Eclipse compilation process. - We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling)` Builder. + There are several possible ways to integrate compilation of C++ code by Android NDK into Eclipse + compilation process. We recommend the approach based on Eclipse + :abbr:`CDT(C/C++ Development Tooling)` Builder. + Make sure your Eclipse IDE has the :abbr:`CDT(C/C++ Development Tooling)` plugin + installed. Menu :guilabel:`Help -> About Eclipse SDK -> Installation Details`. - .. important:: Make sure your Eclipse IDE has the :abbr:`CDT(C/C++ Development Tooling)` plugin installed. Menu :guilabel:`Help -> About Eclipse SDK` and push :guilabel:`Installation Details` button. + .. image:: images/eclipse_about_cdt_0.png + :alt: CDT in Eclipse About + :align: center - .. image:: images/eclipse_inst_details.png - :alt: Configure builders + .. + + .. image:: images/eclipse_about_cdt_1.png + :alt: CDT in Eclipse About + :align: center + + .. note:: If you're using the latest ADT plugin for Eclipse (version 20 and above), most likely + you already have the CDT plugin and don't need to install it. + + .. image:: images/eclipse_about_cdt_1.png + :alt: CDT in Eclipse About :align: center - To install the `CDT plugin `_ use menu :guilabel:`Help -> Install New Software...`, - then paste the CDT 8.0 repository URL http://download.eclipse.org/tools/cdt/releases/indigo as shown in the picture below and click :guilabel:`Add...`, name it *CDT* and click :guilabel:`OK`. + To install the `CDT plugin `_ use menu + :guilabel:`Help -> Install New Software...`, then paste the CDT 8.0 repository URL + http://download.eclipse.org/tools/cdt/releases/indigo as shown in the picture below and click + :guilabel:`Add...`, name it *CDT* and click :guilabel:`OK`. .. image:: images/eclipse_inst_cdt.png :alt: Configure builders @@ -192,6 +255,7 @@ You need the following software to be installed in order to develop for Android That's it. Compilation of C++ code is fully integrated into Eclipse building process now. + Android application structure ============================= @@ -213,27 +277,32 @@ Usually source code of an Android application has the following structure: - :file:`... other files ...` -where: +Where: * the :file:`src` folder contains Java code of the application, -* the :file:`res` folder contains resources of the application (images, xml files describing UI layout, etc), +* the :file:`res` folder contains resources of the application (images, xml files describing UI + layout, etc), * the :file:`libs` folder will contain native libraries after a successful build, -* and the :file:`jni` folder contains C/C++ application source code and NDK's build scripts :file:`Android.mk` and :file:`Application.mk` - producing the native libraries, +* and the :file:`jni` folder contains C/C++ application source code and NDK's build scripts + :file:`Android.mk` and :file:`Application.mk` producing the native libraries, -* :file:`AndroidManifest.xml` file presents essential information about application to the Android system - (name of the Application, name of main application's package, components of the application, required permissions, etc). +* :file:`AndroidManifest.xml` file presents essential information about application to the Android + system (name of the Application, name of main application's package, components of the + application, required permissions, etc). It can be created using Eclipse wizard or :command:`android` tool from Android SDK. -* :file:`project.properties` is a text file containing information about target Android platform and other build details. - This file is generated by Eclipse or can be created with :command:`android` tool included in Android SDK. +* :file:`project.properties` is a text file containing information about target Android platform + and other build details. This file is generated by Eclipse or can be created with + :command:`android` tool included in Android SDK. + +.. note:: Both :file:`AndroidManifest.xml` and :file:`project.properties` files are required to + compile the C++ part of the application, since Android NDK build system relies on them. + If any of these files does not exist, compile the Java part of the project before the C++ part. -.. note:: Both files (:file:`AndroidManifest.xml` and :file:`project.properties`) are required to compile the C++ part of the application, - since Android NDK build system relies on them. If any of these files does not exist, compile the Java part of the project before the C++ part. :file:`Android.mk` and :file:`Application.mk` scripts ================================================================== @@ -254,9 +323,11 @@ The script :file:`Android.mk` usually has the following structure: include $(BUILD_SHARED_LIBRARY) -This is the minimal file :file:`Android.mk`, which builds C++ source code of an Android application. Note that the first two lines and the last line are mandatory for any :file:`Android.mk`. +This is the minimal file :file:`Android.mk`, which builds C++ source code of an Android application. +Note that the first two lines and the last line are mandatory for any :file:`Android.mk`. -Usually the file :file:`Application.mk` is optional, but in case of project using OpenCV, when STL and exceptions are used in C++, it also should be created. Example of the file :file:`Application.mk`: +Usually the file :file:`Application.mk` is optional, but in case of project using OpenCV, when STL +and exceptions are used in C++, it also should be created. Example of the file :file:`Application.mk`: .. code-block:: make :linenos: @@ -285,7 +356,8 @@ Here is the standard way to compile C++ part of an Android application: /ndk-build - .. note:: On Windows we recommend to use ``ndk-build.cmd`` in standard Windows console (``cmd.exe``) rather than the similar ``bash`` script in ``Cygwin`` shell. + .. note:: On Windows we recommend to use ``ndk-build.cmd`` in standard Windows console (``cmd.exe``) + rather than the similar ``bash`` script in ``Cygwin`` shell. .. image:: images/ndk_build.png :alt: NDK build @@ -314,22 +386,22 @@ After that the Java part of the application can be (re)compiled (using either *E Building application native part from *Eclipse* (CDT Builder) ============================================================= -There are several possible ways to integrate compilation of native C++ code by Android NDK into Eclipse build process. -We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling)` Builder. +There are several possible ways to integrate compilation of native C++ code by Android NDK into +Eclipse build process. We recommend the approach based on Eclipse +:abbr:`CDT(C/C++ Development Tooling)` Builder. -.. important:: Make sure your Eclipse IDE has the :abbr:`CDT(C/C++ Development Tooling)` plugin installed. Menu :guilabel:`Help -> About Eclipse SDK -> Installation Details`. +.. important:: OpenCV for Android package since version 2.4.2 contains sample projects + pre-configured CDT Builders. For your own projects follow the steps below. -.. image:: images/eclipse_inst_details.png - :alt: Eclipse About - :align: center +#. Define the ``NDKROOT`` environment variable containing the path to Android NDK in your system + (e.g. ``"X:\\Apps\\android-ndk-r8"`` or ``"/opt/android-ndk-r8"``). -.. important:: OpenCV for Android package since version 2.4.2 contains sample projects pre-configured CDT Builders. For your own projects follow the steps below. + **On Windows** an environment variable can be set via + :guilabel:`My Computer -> Properties -> Advanced -> Environment variables` and restarting Eclipse. + On Windows 7 it's also possible to use `setx `_ command in a console session. -#. Define the ``NDKROOT`` environment variable containing the path to Android NDK in your system (e.g. ``"X:\\Apps\\android-ndk-r8"`` or ``"/opt/android-ndk-r8"``). - **On Windows** an environment variable can be set via :guilabel:`My Computer -> Properties -> Advanced -> Environment variables` and restarting Eclipse. - On Windows 7 it's also possible to use `setx `_ command in a console session. - - **On Linux** and **MacOS** an environment variable can be set via appending a ``"export VAR_NAME=VAR_VALUE"`` line to the :file:`"~/.bashrc"` file and logging off and then on. + **On Linux** and **MacOS** an environment variable can be set via appending a + ``"export VAR_NAME=VAR_VALUE"`` line to the :file:`"~/.bashrc"` file and logging off and then on. #. Open Eclipse and load the Android app project to configure. @@ -345,13 +417,15 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling) :alt: Configure CDT :align: center -#. Select the project(s) to convert. Specify "Project type" = ``Makefile project``, "Toolchains" = ``Other Toolchain``. +#. Select the project(s) to convert. Specify "Project type" = ``Makefile project``, + "Toolchains" = ``Other Toolchain``. .. image:: images/eclipse_cdt_cfg3.png :alt: Configure CDT :align: center -#. Open :guilabel:`Project Properties -> C/C++ Build`, unckeck ``Use default build command``, replace "Build command" text from ``"make"`` to +#. Open :guilabel:`Project Properties -> C/C++ Build`, uncheck ``Use default build command``, + replace "Build command" text from ``"make"`` to ``"${NDKROOT}/ndk-build.cmd"`` on Windows, @@ -373,13 +447,15 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling) :alt: Configure CDT :align: center -#. If you open your C++ source file in Eclipse editor, you'll see syntax error notifications. They are not real errors, but additional CDT configuring is required. +#. If you open your C++ source file in Eclipse editor, you'll see syntax error notifications. + They are not real errors, but additional CDT configuring is required. .. image:: images/eclipse_cdt_cfg7.png :alt: Configure CDT :align: center -#. Open :guilabel:`Project Properties -> C/C++ General -> Paths and Symbols` and add the following **Include** paths for **C++**: +#. Open :guilabel:`Project Properties -> C/C++ General -> Paths and Symbols` and add the following + **Include** paths for **C++**: :: @@ -396,7 +472,8 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling) :alt: Configure CDT :align: center - .. note:: The latest Android NDK **r8b** uses different STL headers path. So if you use this NDK release add the following **Include** paths list instead: + .. note:: The latest Android NDK **r8b** uses different STL headers path. So if you use this NDK + release add the following **Include** paths list instead: :: @@ -408,46 +485,62 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling) Debugging and Testing ===================== -In this section we will give you some easy-to-follow instructions on how to set up an emulator or hardware device for testing and debugging an Android project. +In this section we will give you some easy-to-follow instructions on how to set up an emulator or +hardware device for testing and debugging an Android project. AVD --- -AVD (*Android Virtual Device*) is not probably the most convenient way to test an OpenCV-dependent application, but sure the most uncomplicated one to configure. +AVD (*Android Virtual Device*) is not probably the most convenient way to test an OpenCV-dependent +application, but sure the most uncomplicated one to configure. -#. Assuming you already have *Android SDK* and *Eclipse IDE* installed, in Eclipse go :guilabel:`Window -> AVD Manager`. +#. Assuming you already have *Android SDK* and *Eclipse IDE* installed, in Eclipse go + :guilabel:`Window -> AVD Manager`. - .. **TBD:** how to start AVD Manager without Eclipse... + .. TODO: how to start AVD Manager without Eclipse... #. Press the :guilabel:`New` button in :guilabel:`AVD Manager` window. -#. :guilabel:`Create new Android Virtual Device` window will let you select some properties for your new device, like target API level, size of SD-card and other. +#. :guilabel:`Create new Android Virtual Device` window will let you select some properties for your + new device, like target API level, size of SD-card and other. .. image:: images/AVD_create.png :alt: Configure builders :align: center #. When you click the :guilabel:`Create AVD` button, your new AVD will be availible in :guilabel:`AVD Manager`. -#. Press :guilabel:`Start` to launch the device. Be aware that any AVD (a.k.a. Emulator) is usually much slower than a hardware Android device, so it may take up to several minutes to start. -#. Go :guilabel:`Run -> Run/Debug` in Eclipse IDE to run your application in regular or debugging mode. :guilabel:`Device Chooser` will let you choose among the running devices or to start a new one. +#. Press :guilabel:`Start` to launch the device. Be aware that any AVD (a.k.a. Emulator) is usually + much slower than a hardware Android device, so it may take up to several minutes to start. +#. Go :guilabel:`Run -> Run/Debug` in Eclipse IDE to run your application in regular or debugging + mode. :guilabel:`Device Chooser` will let you choose among the running devices or to start a new one. Hardware Device --------------- -If you have an Android device, you can use it to test and debug your applications. This way is more authentic, though a little bit harder to set up. You need to make some actions for Windows and Linux operating systems to be able to work with Android devices. No extra actions are required for Mac OS. See detailed information on configuring hardware devices in subsections below. +If you have an Android device, you can use it to test and debug your applications. This way is more +authentic, though a little bit harder to set up. You need to make some actions for Windows and Linux +operating systems to be able to work with Android devices. No extra actions are required for Mac OS. +See detailed information on configuring hardware devices in subsections below. -You may also consult the official `Android Developers site instructions `_ for more information. +You may also consult the official +`Android Developers site instructions `_ +for more information. Windows host computer ^^^^^^^^^^^^^^^^^^^^^ #. Enable USB debugging on the Android device (via :guilabel:`Settings` menu). #. Attach the Android device to your PC with a USB cable. -#. Go to :guilabel:`Start Menu` and **right-click** on :guilabel:`Computer`. Select :guilabel:`Manage` in the context menu. You may be asked for Administrative permissions. -#. Select :guilabel:`Device Manager` in the left pane and find an unknown device in the list. You may try unplugging it and then plugging back in order to check whether it's your exact equipment appears in the list. +#. Go to :guilabel:`Start Menu` and **right-click** on :guilabel:`Computer`. + Select :guilabel:`Manage` in the context menu. You may be asked for Administrative permissions. +#. Select :guilabel:`Device Manager` in the left pane and find an unknown device in the list. + You may try unplugging it and then plugging back in order to check whether it's your exact + equipment appears in the list. .. image:: images/usb_device_connect_01.png :alt: Unknown device :align: center -#. Try your luck installing `Google USB drivers` without any modifications: **right-click** on the unknown device, select :guilabel:`Properties` menu item --> :guilabel:`Details` tab --> :guilabel:`Update Driver` button. +#. Try your luck installing `Google USB drivers` without any modifications: **right-click** on the + unknown device, select :guilabel:`Properties` menu item --> :guilabel:`Details` tab --> + :guilabel:`Update Driver` button. .. image:: images/usb_device_connect_05.png :alt: Device properties @@ -465,13 +558,15 @@ Windows host computer :alt: Browse for driver :align: center -#. If you get the prompt to install unverified drivers and report about success - you've finished with USB driver installation. +#. If you get the prompt to install unverified drivers and report about success - you've finished + with USB driver installation. .. image:: images/usb_device_connect_08.png :alt: Install prompt :align: center ` ` + .. FIXME: All such places should be replaced with something else! This is a bad separator. .. image:: images/usb_device_connect_09.png :alt: Installed OK @@ -483,13 +578,15 @@ Windows host computer :alt: No driver :align: center -#. Again **right-click** on the unknown device, select :guilabel:`Properties --> Details --> Hardware Ids` and copy the line like ``USB\VID_XXXX&PID_XXXX&MI_XX``. +#. Again **right-click** on the unknown device, select :guilabel:`Properties --> Details --> Hardware Ids` + and copy the line like ``USB\VID_XXXX&PID_XXXX&MI_XX``. .. image:: images/usb_device_connect_02.png :alt: Device properties details :align: center -#. Now open file :file:`/extras/google/usb_driver/android_winusb.inf`. Select either ``Google.NTx86`` or ``Google.NTamd64`` section depending on your host system architecture. +#. Now open file :file:`/extras/google/usb_driver/android_winusb.inf`. Select + either ``Google.NTx86`` or ``Google.NTamd64`` section depending on your host system architecture. .. image:: images/usb_device_connect_03.png :alt: "android_winusb.inf" @@ -543,17 +640,23 @@ Windows host computer :alt: "adb devices" :align: center -#. Now, in Eclipse go :guilabel:`Run -> Run/Debug` to run your application in regular or debugging mode. :guilabel:`Device Chooser` will let you choose among the devices. +#. Now, in Eclipse go :guilabel:`Run -> Run/Debug` to run your application in regular or debugging + mode. :guilabel:`Device Chooser` will let you choose among the devices. Linux host computer ^^^^^^^^^^^^^^^^^^^ -By default Linux doesn't recognize Android devices, but it's easy to fix this issue. On Ubuntu Linux you have to create a new **/etc/udev/rules.d/51-android.rules** configuration file that contains information about your Android device. You may find some Vendor ID's `here `_ or execute :command:`lsusb` command to view VendorID of plugged Android device. Here is an example of such file for LG device: +By default Linux doesn't recognize Android devices, but it's easy to fix this issue. On Ubuntu Linux +you have to create a new **/etc/udev/rules.d/51-android.rules** configuration file that contains +information about your Android device. You may find some Vendor ID's +`here `_ or execute :command:`lsusb` +command to view VendorID of plugged Android device. Here is an example of such file for LG device: .. code-block:: guess SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev" -Then restart your adb server (even better to restart the system), plug in your Android device and execute :command:`adb devices` command. You will see the list of attached devices: +Then restart your adb server (even better to restart the system), plug in your Android device and +execute :command:`adb devices` command. You will see the list of attached devices: .. image:: images/usb_device_connect_ubuntu.png :alt: List of attached devices @@ -566,4 +669,5 @@ No actions are required, just connect your device via USB and run ``adb devices` What's next =========== -Now, when you have your development environment set up and configured, you may want to proceed to installing OpenCV4Android SDK. You can learn how to do that in a separate :ref:`O4A_SDK` tutorial. \ No newline at end of file +Now, when you have your development environment set up and configured, you may want to proceed to +installing OpenCV4Android SDK. You can learn how to do that in a separate :ref:`O4A_SDK` tutorial. diff --git a/doc/tutorials/introduction/android_binary_package/images/android_sdk_and_avd_manager.png b/doc/tutorials/introduction/android_binary_package/images/android_sdk_and_avd_manager.png index 46ddebba7f..cf5eb7d1ab 100644 Binary files a/doc/tutorials/introduction/android_binary_package/images/android_sdk_and_avd_manager.png and b/doc/tutorials/introduction/android_binary_package/images/android_sdk_and_avd_manager.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_0.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_0.png new file mode 100644 index 0000000000..79e43690bf Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_0.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_1.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_1.png new file mode 100644 index 0000000000..9b2c9b136c Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_1.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_2.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_2.png new file mode 100644 index 0000000000..c061a2074c Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/eclipse_about_cdt_2.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg4.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg4.png index a9958dad8b..633e3d2943 100644 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg4.png and b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg4.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_adt.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_adt.png new file mode 100644 index 0000000000..94491e0a61 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_adt.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_details.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_details.png deleted file mode 100644 index 246d14c3e1..0000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_details.png and /dev/null differ diff --git a/ios/build_framework.py b/ios/build_framework.py index 11d9a21276..3f0e85f725 100755 --- a/ios/build_framework.py +++ b/ios/build_framework.py @@ -13,16 +13,16 @@ Script will create , if it's missing, and a few its subdirectories: build/ - iPhoneOS/ + iPhoneOS-*/ [cmake-generated build tree for an iOS device target] iPhoneSimulator/ [cmake-generated build tree for iOS simulator] - OpenCV.framework/ + opencv2.framework/ [the framework content] The script should handle minor OpenCV updates efficiently - it does not recompile the library from scratch each time. -However, OpenCV.framework directory is erased and recreated on each run. +However, opencv2.framework directory is erased and recreated on each run. """ import glob, re, os, os.path, shutil, string, sys diff --git a/ios/cmake/Modules/Platform/iOS.cmake b/ios/cmake/Modules/Platform/iOS.cmake index 9d6ab80913..4d196e65d9 100644 --- a/ios/cmake/Modules/Platform/iOS.cmake +++ b/ios/cmake/Modules/Platform/iOS.cmake @@ -40,7 +40,7 @@ set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") # Hidden visibilty is required for cxx on iOS set (CMAKE_C_FLAGS "") -set (CMAKE_CXX_FLAGS "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden") +set (CMAKE_CXX_FLAGS "-stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden") set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math") diff --git a/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake b/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake index aa3a67cdbd..67343253bd 100644 --- a/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake +++ b/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake @@ -8,8 +8,8 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/ios/cma # Force the compilers to gcc for iOS include (CMakeForceCompiler) -CMAKE_FORCE_C_COMPILER (gcc gcc) -CMAKE_FORCE_CXX_COMPILER (g++ g++) +#CMAKE_FORCE_C_COMPILER (gcc gcc) +#CMAKE_FORCE_CXX_COMPILER (g++ g++) set (CMAKE_C_SIZEOF_DATA_PTR 4) set (CMAKE_C_HAS_ISYSROOT 1) diff --git a/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake b/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake index 78d45bca18..7ef8113edb 100644 --- a/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake +++ b/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake @@ -8,8 +8,8 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/ios/cma # Force the compilers to gcc for iOS include (CMakeForceCompiler) -CMAKE_FORCE_C_COMPILER (gcc gcc) -CMAKE_FORCE_CXX_COMPILER (g++ g++) +#CMAKE_FORCE_C_COMPILER (gcc gcc) +#CMAKE_FORCE_CXX_COMPILER (g++ g++) set (CMAKE_C_SIZEOF_DATA_PTR 4) set (CMAKE_C_HAS_ISYSROOT 1) diff --git a/modules/calib3d/perf/perf_pnp.cpp b/modules/calib3d/perf/perf_pnp.cpp index 44d390ef77..fa8f5808db 100644 --- a/modules/calib3d/perf/perf_pnp.cpp +++ b/modules/calib3d/perf/perf_pnp.cpp @@ -55,7 +55,7 @@ PERF_TEST_P(PointsNum_Algo, solvePnP, } SANITY_CHECK(rvec, 1e-6); - SANITY_CHECK(tvec, 1e-6); + SANITY_CHECK(tvec, 1e-3); } PERF_TEST(PointsNum_Algo, solveP3P) diff --git a/modules/calib3d/perf/perf_precomp.hpp b/modules/calib3d/perf/perf_precomp.hpp index b13bd664c8..891d50e050 100644 --- a/modules/calib3d/perf/perf_precomp.hpp +++ b/modules/calib3d/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/calib3d/test/test_cameracalibration_artificial.cpp b/modules/calib3d/test/test_cameracalibration_artificial.cpp index e5585e98f6..733f0069c7 100644 --- a/modules/calib3d/test/test_cameracalibration_artificial.cpp +++ b/modules/calib3d/test/test_cameracalibration_artificial.cpp @@ -426,4 +426,4 @@ protected: } }; -TEST(Calib3d_CalibrateCamera_CPP, accuracy_on_artificial_data) { CV_CalibrateCameraArtificialTest test; test.safe_run(); } +TEST(Calib3d_CalibrateCamera_CPP, DISABLED_accuracy_on_artificial_data) { CV_CalibrateCameraArtificialTest test; test.safe_run(); } diff --git a/modules/calib3d/test/test_precomp.hpp b/modules/calib3d/test/test_precomp.hpp index a95fc1cdc5..2d1f35702e 100644 --- a/modules/calib3d/test/test_precomp.hpp +++ b/modules/calib3d/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/contrib/doc/contrib.rst b/modules/contrib/doc/contrib.rst index c3ceb20f51..798d38d5bb 100644 --- a/modules/contrib/doc/contrib.rst +++ b/modules/contrib/doc/contrib.rst @@ -10,3 +10,4 @@ The module contains some recently added functionality that has not been stabiliz stereo FaceRecognizer Documentation Retina Documentation + openfabmap diff --git a/modules/contrib/doc/openfabmap.rst b/modules/contrib/doc/openfabmap.rst index 6e8a9f6d54..2f2ad40745 100644 --- a/modules/contrib/doc/openfabmap.rst +++ b/modules/contrib/doc/openfabmap.rst @@ -1,4 +1,4 @@ -openFABMAP +OpenFABMAP ======================================== .. highlight:: cpp diff --git a/modules/contrib/test/test_precomp.hpp b/modules/contrib/test/test_precomp.hpp index 03e1cfe29d..2a7a3d44b8 100644 --- a/modules/contrib/test/test_precomp.hpp +++ b/modules/contrib/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/core/doc/operations_on_arrays.rst b/modules/core/doc/operations_on_arrays.rst index 371c5413bb..d08a07193a 100644 --- a/modules/core/doc/operations_on_arrays.rst +++ b/modules/core/doc/operations_on_arrays.rst @@ -13,17 +13,17 @@ Calculates an absolute value of each matrix element. :param m: matrix. :param e: matrix expression. -``abs`` is a meta-function that is expanded to one of :ocv:func:`absdiff` forms: +``abs`` is a meta-function that is expanded to one of :ocv:func:`absdiff` or :ocv:func:`convertScaleAbs` forms: * ``C = abs(A-B)`` is equivalent to ``absdiff(A, B, C)`` * ``C = abs(A)`` is equivalent to ``absdiff(A, Scalar::all(0), C)`` - * ``C = Mat_ >(abs(A*alpha + beta))`` is equivalent to :ocv:funcx:`convertScaleAbs` (A, C, alpha, beta) + * ``C = Mat_ >(abs(A*alpha + beta))`` is equivalent to ``convertScaleAbs(A, C, alpha, beta)`` The output matrix has the same size and the same type as the input one except for the last case, where ``C`` is ``depth=CV_8U`` . - .. seealso:: :ref:`MatrixExpressions`, :ocv:func:`absdiff` + .. seealso:: :ref:`MatrixExpressions`, :ocv:func:`absdiff`, :ocv:func:`convertScaleAbs` absdiff diff --git a/modules/core/include/opencv2/core/internal.hpp b/modules/core/include/opencv2/core/internal.hpp index b1d8cf8486..93e56c3ab3 100644 --- a/modules/core/include/opencv2/core/internal.hpp +++ b/modules/core/include/opencv2/core/internal.hpp @@ -59,16 +59,7 @@ # endif #endif -#if defined WIN32 || defined WINCE -# ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?) -# define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx -# endif -# include -# undef small -# undef min -# undef max -# undef abs -#else +#if !defined WIN32 && !defined WINCE # include #endif diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 2f5f9205cf..4b6e606165 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -56,7 +56,13 @@ #define CV_XADD(addr,delta) _InterlockedExchangeAdd(const_cast(reinterpret_cast(addr)), delta) #elif defined __GNUC__ - #if __GNUC__*10 + __GNUC_MINOR__ >= 42 + #if defined __clang__ && __clang_major__ >= 3 + #ifdef __ATOMIC_SEQ_CST + #define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST) + #else + #define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), (delta), 5) + #endif + #elif __GNUC__*10 + __GNUC_MINOR__ >= 42 #if !defined WIN32 && (defined __i486__ || defined __i586__ || \ defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) @@ -2460,18 +2466,10 @@ dot(const Vector<_Tp>& v1, const Vector<_Tp>& v2) assert(v1.size() == v2.size()); _Tw s = 0; - if( n > 0 ) - { - const _Tp *ptr1 = &v1[0], *ptr2 = &v2[0]; - #if CV_ENABLE_UNROLLED - const size_t n2 = (n > 4) ? n : 4; - for(; i <= n2 - 4; i += 4 ) - s += (_Tw)ptr1[i]*ptr2[i] + (_Tw)ptr1[i+1]*ptr2[i+1] + - (_Tw)ptr1[i+2]*ptr2[i+2] + (_Tw)ptr1[i+3]*ptr2[i+3]; - #endif - for( ; i < n; i++ ) - s += (_Tw)ptr1[i]*ptr2[i]; - } + const _Tp *ptr1 = &v1[0], *ptr2 = &v2[0]; + for( ; i < n; i++ ) + s += (_Tw)ptr1[i]*ptr2[i]; + return s; } diff --git a/modules/core/perf/perf_addWeighted.cpp b/modules/core/perf/perf_addWeighted.cpp index 82ca45a027..fd1ac1ba13 100644 --- a/modules/core/perf/perf_addWeighted.cpp +++ b/modules/core/perf/perf_addWeighted.cpp @@ -25,12 +25,12 @@ PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED) if (CV_MAT_DEPTH(type) == CV_32S) { - //see ticket 1529: absdiff can be without saturation on 32S - src1 /= 8; - src2 /= 8; + // there might be not enough precision for integers + src1 /= 2048; + src2 /= 2048; } TEST_CYCLE() cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() ); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1); } diff --git a/modules/core/perf/perf_precomp.hpp b/modules/core/perf/perf_precomp.hpp index 184e84bc40..9417bc3641 100644 --- a/modules/core/perf/perf_precomp.hpp +++ b/modules/core/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/core/src/algorithm.cpp b/modules/core/src/algorithm.cpp index d1d15dbd7e..9001fcd121 100644 --- a/modules/core/src/algorithm.cpp +++ b/modules/core/src/algorithm.cpp @@ -430,7 +430,10 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const nestedAlgo->write(fs); } else - CV_Error( CV_StsUnsupportedFormat, "unknown/unsupported parameter type"); + { + string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type); + CV_Error( CV_StsUnsupportedFormat, msg.c_str()); + } } } @@ -486,7 +489,10 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const info->set(algo, pname.c_str(), p.type, &nestedAlgo, true); } else - CV_Error( CV_StsUnsupportedFormat, "unknown/unsupported parameter type"); + { + string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type); + CV_Error( CV_StsUnsupportedFormat, msg.c_str()); + } } } @@ -777,7 +783,10 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp *(Ptr*)((uchar*)algo + p->offset); } else - CV_Error(CV_StsBadArg, "Unknown/unsupported parameter type"); + { + string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType); + CV_Error(CV_StsBadArg, message); + } } diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 014b107106..2bc8a05880 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -42,6 +42,14 @@ #include "precomp.hpp" +#if defined WIN32 || defined WINCE + #include + #undef small + #undef min + #undef max + #undef abs +#endif + #if defined __linux__ || defined __APPLE__ #include #include diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index 8861b9ad20..bae8eae89d 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -48,8 +48,16 @@ #include "precomp.hpp" +#if defined WIN32 || defined WINCE + #include + #undef small + #undef min + #undef max + #undef abs +#endif + #if defined __SSE2__ || (defined _M_IX86_FP && 2 == _M_IX86_FP) -#include "emmintrin.h" + #include "emmintrin.h" #endif namespace cv diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index d463a84ef3..e0932a79f1 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -43,6 +43,14 @@ #include "precomp.hpp" #if defined WIN32 || defined _WIN32 || defined WINCE +#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?) + #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx +#endif +#include +#undef small +#undef min +#undef max +#undef abs #include #if defined _MSC_VER #if _MSC_VER >= 1400 diff --git a/modules/core/test/test_precomp.hpp b/modules/core/test/test_precomp.hpp index 1326195a51..6f1b188ccd 100644 --- a/modules/core/test/test_precomp.hpp +++ b/modules/core/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/features2d/perf/perf_fast.cpp b/modules/features2d/perf/perf_fast.cpp index f550f7b33e..a7793884f7 100644 --- a/modules/features2d/perf/perf_fast.cpp +++ b/modules/features2d/perf/perf_fast.cpp @@ -30,10 +30,14 @@ PERF_TEST_P(fast, detect, testing::Combine( declare.in(frame); - FastFeatureDetector fd(20, true, type); + Ptr fd = Algorithm::create("Feature2D.FAST"); + ASSERT_FALSE( fd == 0 ); + fd->set("threshold", 20); + fd->set("nonmaxSuppression", true); + fd->set("type", type); vector points; - TEST_CYCLE() fd.detect(frame, points); + TEST_CYCLE() fd->detect(frame, points); SANITY_CHECK_KEYPOINTS(points); } diff --git a/modules/features2d/perf/perf_orb.cpp b/modules/features2d/perf/perf_orb.cpp index 3a8b423f10..4c799ff7be 100644 --- a/modules/features2d/perf/perf_orb.cpp +++ b/modules/features2d/perf/perf_orb.cpp @@ -22,7 +22,7 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES)) Mat mask; declare.in(frame); - ORB detector(1500, 1.3f, 5); + ORB detector(1500, 1.3f, 1); vector points; TEST_CYCLE() detector(frame, mask, points); @@ -42,7 +42,7 @@ PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES)) Mat mask; declare.in(frame); - ORB detector(1500, 1.3f, 5); + ORB detector(1500, 1.3f, 1); vector points; detector(frame, mask, points); sort(points.begin(), points.end(), comparators::KeypointGreater()); @@ -64,7 +64,7 @@ PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES)) Mat mask; declare.in(frame); - ORB detector(1500, 1.3f, 5); + ORB detector(1500, 1.3f, 1); vector points; Mat descriptors; diff --git a/modules/features2d/perf/perf_precomp.hpp b/modules/features2d/perf/perf_precomp.hpp index 286852b546..1f3ad1fe99 100644 --- a/modules/features2d/perf/perf_precomp.hpp +++ b/modules/features2d/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index f37d51c471..c823856278 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -259,6 +259,10 @@ void FAST(InputArray _img, std::vector& keypoints, int threshold, bool FAST_t<12>(_img, keypoints, threshold, nonmax_suppression); break; case FastFeatureDetector::TYPE_9_16: +#ifdef HAVE_TEGRA_OPTIMIZATION + if(tegra::FAST(_img, keypoints, threshold, nonmax_suppression)) + break; +#endif FAST_t<16>(_img, keypoints, threshold, nonmax_suppression); break; } diff --git a/modules/features2d/src/precomp.hpp b/modules/features2d/src/precomp.hpp index 5b1babe699..c1e3ace7a5 100644 --- a/modules/features2d/src/precomp.hpp +++ b/modules/features2d/src/precomp.hpp @@ -52,4 +52,8 @@ #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/internal.hpp" +#ifdef HAVE_TEGRA_OPTIMIZATION +#include "opencv2/features2d/features2d_tegra.hpp" +#endif + #endif diff --git a/modules/features2d/test/test_precomp.hpp b/modules/features2d/test/test_precomp.hpp index e2daba111e..28985f944f 100644 --- a/modules/features2d/test/test_precomp.hpp +++ b/modules/features2d/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/gpu/doc/image_processing.rst b/modules/gpu/doc/image_processing.rst index 69b171e74e..cc5f4ddc97 100644 --- a/modules/gpu/doc/image_processing.rst +++ b/modules/gpu/doc/image_processing.rst @@ -886,7 +886,7 @@ gpu::FastNonLocalMeansDenoising The class implements fast approximate Non Local Means Denoising algorithm. gpu::FastNonLocalMeansDenoising::simpleMethod() -------------------------------------- +----------------------------------------------- Perform image denoising using Non-local Means Denoising algorithm http://www.ipol.im/pub/algo/bcm_non_local_means_denoising with several computational optimizations. Noise expected to be a gaussian white noise .. ocv:function:: void gpu::FastNonLocalMeansDenoising::simpleMethod(const GpuMat& src, GpuMat& dst, float h, int search_window = 21, int block_size = 7, Stream& s = Stream::Null()) @@ -910,7 +910,7 @@ This function expected to be applied to grayscale images. For colored images loo :ocv:func:`fastNlMeansDenoising` gpu::FastNonLocalMeansDenoising::labMethod() -------------------------------------- +-------------------------------------------- Modification of ``FastNonLocalMeansDenoising::simpleMethod`` for color images .. ocv:function:: void gpu::FastNonLocalMeansDenoising::labMethod(const GpuMat& src, GpuMat& dst, float h_luminance, float h_color, int search_window = 21, int block_size = 7, Stream& s = Stream::Null()) diff --git a/modules/gpu/perf/perf_precomp.hpp b/modules/gpu/perf/perf_precomp.hpp index ab35148f24..04ccfdef37 100644 --- a/modules/gpu/perf/perf_precomp.hpp +++ b/modules/gpu/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/gpu/src/precomp.hpp b/modules/gpu/src/precomp.hpp index f8782b379a..c37332ae45 100644 --- a/modules/gpu/src/precomp.hpp +++ b/modules/gpu/src/precomp.hpp @@ -73,6 +73,14 @@ #include "opencv2/core/internal.hpp" #include "opencv2/video/video.hpp" +#if defined WIN32 || defined WINCE + #include + #undef small + #undef min + #undef max + #undef abs +#endif + #define OPENCV_GPU_UNUSED(x) (void)x #ifdef HAVE_CUDA diff --git a/modules/gpu/test/test_labeling.cpp b/modules/gpu/test/test_labeling.cpp index 4eccbf93d6..c56fc0ef83 100644 --- a/modules/gpu/test/test_labeling.cpp +++ b/modules/gpu/test/test_labeling.cpp @@ -135,7 +135,7 @@ namespace { int outliers = 0; for (int j = 0; j < image.rows; ++j) - for (int i = 0; i < image.cols; ++i) + for (int i = 0; i < image.cols - 1; ++i) { if ( (_labels.at(j,i) == gpu.at(j,i + 1)) && (diff.at(j, i) != diff.at(j,i + 1))) { diff --git a/modules/gpu/test/test_precomp.hpp b/modules/gpu/test/test_precomp.hpp index 46701f52cf..3e6abef82b 100644 --- a/modules/gpu/test/test_precomp.hpp +++ b/modules/gpu/test/test_precomp.hpp @@ -41,7 +41,10 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/highgui/doc/reading_and_writing_images_and_video.rst b/modules/highgui/doc/reading_and_writing_images_and_video.rst index 5911b3f807..42e3eea807 100644 --- a/modules/highgui/doc/reading_and_writing_images_and_video.rst +++ b/modules/highgui/doc/reading_and_writing_images_and_video.rst @@ -75,11 +75,11 @@ Loads an image from a file. :param flags: Flags specifying the color type of a loaded image: - * 1 - - * CV_LOAD_IMAGE_ANYDEPTH - - CV_LOAD_IMAGE_COLOR - CV_LOAD_IMAGE_GRAYSCALE + * CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit. + * CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one + + * CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one * **>0** Return a 3-channel color image. .. note:: In the current implementation the alpha channel, if any, is stripped from the output image. Use negative value if you need the alpha channel. diff --git a/modules/highgui/perf/perf_input.cpp b/modules/highgui/perf/perf_input.cpp index 06e3c2c928..a2ce1fe910 100644 --- a/modules/highgui/perf/perf_input.cpp +++ b/modules/highgui/perf/perf_input.cpp @@ -6,6 +6,8 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; +#ifndef ANDROID + typedef perf::TestBaseWithParam VideoCapture_Reading; PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi", @@ -23,3 +25,5 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_ bool dummy = cap.isOpened(); SANITY_CHECK(dummy); } + +#endif //ANDROID \ No newline at end of file diff --git a/modules/highgui/perf/perf_output.cpp b/modules/highgui/perf/perf_output.cpp index 851a2a6a0f..95f993803f 100644 --- a/modules/highgui/perf/perf_output.cpp +++ b/modules/highgui/perf/perf_output.cpp @@ -6,6 +6,8 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; +#ifndef ANDROID + typedef std::tr1::tuple VideoWriter_Writing_t; typedef perf::TestBaseWithParam VideoWriter_Writing; @@ -28,3 +30,5 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame, bool dummy = writer.isOpened(); SANITY_CHECK(dummy); } + +#endif //ANDROID \ No newline at end of file diff --git a/modules/highgui/perf/perf_precomp.hpp b/modules/highgui/perf/perf_precomp.hpp index f7fb98da1b..fc9c3b8b22 100644 --- a/modules/highgui/perf/perf_precomp.hpp +++ b/modules/highgui/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index 7ad292b63e..0cef4e77ae 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -49,11 +49,6 @@ #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/core/internal.hpp" -#if defined WIN32 || defined _WIN32 -//required windows.h has to be included by the opencv2/core/internal.hpp -void FillBitmapInfo( BITMAPINFO* bmi, int width, int height, int bpp, int origin ); -#endif - #include #include #include @@ -61,6 +56,14 @@ void FillBitmapInfo( BITMAPINFO* bmi, int width, int height, int bpp, int origi #include #include +#if defined WIN32 || defined WINCE + #include + #undef small + #undef min + #undef max + #undef abs +#endif + #ifdef HAVE_TEGRA_OPTIMIZATION #include "opencv2/highgui/highgui_tegra.hpp" #endif diff --git a/modules/highgui/src/window_w32.cpp b/modules/highgui/src/window_w32.cpp index 02c69115cc..348420afdb 100644 --- a/modules/highgui/src/window_w32.cpp +++ b/modules/highgui/src/window_w32.cpp @@ -106,7 +106,7 @@ static const char* trackbar_text = #endif -void FillBitmapInfo( BITMAPINFO* bmi, int width, int height, int bpp, int origin ) +static void FillBitmapInfo( BITMAPINFO* bmi, int width, int height, int bpp, int origin ) { assert( bmi && width >= 0 && height >= 0 && (bpp == 8 || bpp == 24 || bpp == 32)); diff --git a/modules/highgui/test/test_precomp.hpp b/modules/highgui/test/test_precomp.hpp index 5c2c0f004a..6941a0c6e6 100644 --- a/modules/highgui/test/test_precomp.hpp +++ b/modules/highgui/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/highgui/test/test_video_io.cpp b/modules/highgui/test/test_video_io.cpp index 63797372ad..b0c2e53ba5 100644 --- a/modules/highgui/test/test_video_io.cpp +++ b/modules/highgui/test/test_video_io.cpp @@ -143,7 +143,7 @@ void CV_HighGuiTest::ImageTest(const string& dir) #ifdef HAVE_JASPER "jp2", #endif -#if defined HAVE_OPENEXR && !defined __APPLE__ +#if 0 /*defined HAVE_OPENEXR && !defined __APPLE__*/ "exr", #endif "bmp", diff --git a/modules/imgproc/perf/perf_precomp.hpp b/modules/imgproc/perf/perf_precomp.hpp index 57e630051e..9120beec8b 100644 --- a/modules/imgproc/perf/perf_precomp.hpp +++ b/modules/imgproc/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/imgproc/perf/perf_warp.cpp b/modules/imgproc/perf/perf_warp.cpp index a79768e762..b84e7ca982 100644 --- a/modules/imgproc/perf/perf_warp.cpp +++ b/modules/imgproc/perf/perf_warp.cpp @@ -43,7 +43,7 @@ PERF_TEST_P( TestWarpAffine, WarpAffine, TEST_CYCLE() warpAffine( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) ); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1); } @@ -78,7 +78,7 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective, TEST_CYCLE() warpPerspective( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) ); - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1); } PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear, @@ -119,7 +119,7 @@ PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear, resize(src, src, size); - int shift = src.cols*0.04; + int shift = static_cast(src.cols*0.04); Mat srcVertices = (Mat_(1, 4) << Vec2f(0, 0), Vec2f(static_cast(size.width-1), 0), Vec2f(static_cast(size.width-1), static_cast(size.height-1)), @@ -139,7 +139,7 @@ PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear, warpPerspective( src, dst, warpMat, size, interType, borderMode, Scalar::all(150) ); } - SANITY_CHECK(dst); + SANITY_CHECK(dst, 1); } PERF_TEST_P( TestRemap, remap, diff --git a/modules/imgproc/test/test_precomp.hpp b/modules/imgproc/test/test_precomp.hpp index f83a864550..493a09d366 100644 --- a/modules/imgproc/test/test_precomp.hpp +++ b/modules/imgproc/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java index 3de8e46a1a..fcc389fd77 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java @@ -84,11 +84,11 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { matSize = 100; truth = new DMatch[] { - new DMatch(0, 0, 0, 1.049694f), - new DMatch(1, 0, 0, 1.066820f), - new DMatch(2, 1, 0, 0.494587f), - new DMatch(3, 0, 0, 1.141826f), - new DMatch(4, 0, 0, 1.084099f) + new DMatch(0, 0, 0, 1.0496940f), + new DMatch(1, 0, 0, 1.0984558f), + new DMatch(2, 1, 0, 0.4945875f), + new DMatch(3, 1, 0, 0.48435235f), + new DMatch(4, 0, 0, 1.0836693f) }; super.setUp(); @@ -206,6 +206,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { matcher.add(Arrays.asList(train)); matcher.match(query, matches); + assertArrayDMatchEquals(truth, matches.toArray(), EPS); } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java index 571227aeff..c15e937d79 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java @@ -84,11 +84,11 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase { matSize = 100; truth = new DMatch[] { - new DMatch(0, 1, 0, 6.9202332f), - new DMatch(1, 0, 0, 6.0567350f), - new DMatch(2, 1, 0, 2.6798587f), - new DMatch(3, 0, 0, 5.8991642f), - new DMatch(4, 0, 0, 6.1321812f) + new DMatch(0, 1, 0, 6.9202340f), + new DMatch(1, 1, 0, 6.1675916f), + new DMatch(2, 1, 0, 2.6798590f), + new DMatch(3, 1, 0, 2.6545324f), + new DMatch(4, 0, 0, 6.1294870f) }; super.setUp(); } @@ -183,6 +183,7 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase { matcher.add(Arrays.asList(train)); matcher.match(query, matches); + assertArrayDMatchEquals(truth, matches.toArray(), EPS); } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java index 8cf6285a00..7c886c15db 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java @@ -89,11 +89,11 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase { matSize = 100; truth = new DMatch[] { - new DMatch(0, 0, 0, 1.1018578f), - new DMatch(1, 0, 0, 1.1381058f), + new DMatch(0, 0, 0, 1.1018573f), + new DMatch(1, 0, 0, 1.2066052f), new DMatch(2, 1, 0, 0.2446168f), - new DMatch(3, 0, 0, 1.3037685f), - new DMatch(4, 0, 0, 1.1752719f) + new DMatch(3, 1, 0, 0.23459719f), + new DMatch(4, 0, 0, 1.174339f) }; super.setUp(); @@ -189,9 +189,10 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase { matcher.add(Arrays.asList(train)); matcher.match(query, matches); -OpenCVTestRunner.Log(matches); -OpenCVTestRunner.Log(matches); -OpenCVTestRunner.Log(matches); + OpenCVTestRunner.Log(matches); + OpenCVTestRunner.Log(matches); + OpenCVTestRunner.Log(matches); + assertArrayDMatchEquals(truth, matches.toArray(), EPS); } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java index 6c1bd8376a..35ffd6477e 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java @@ -128,7 +128,9 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase { detector.write(filename); String truth = "\n\nFeature2D.FAST\n1\n10\n\n"; - assertEquals(truth, readFile(filename)); + String data = readFile(filename); + + assertEquals(truth, data); } public void testWriteYml() { @@ -137,7 +139,8 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase { detector.write(filename); String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\n"; - assertEquals(truth, readFile(filename)); - } + String data = readFile(filename); + assertEquals(truth, data); + } } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java index 7170d5257b..6eb20eec12 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java @@ -159,10 +159,10 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase { truth = new DMatch[] { new DMatch(0, 0, 0, 1.049694f), - new DMatch(1, 0, 0, 1.066820f), - new DMatch(2, 1, 0, 0.494587f), - new DMatch(3, 0, 0, 1.141826f), - new DMatch(4, 0, 0, 1.084099f) + new DMatch(1, 0, 0, 1.0984558f), + new DMatch(2, 1, 0, 0.4945875f), + new DMatch(3, 1, 0, 0.48435235f), + new DMatch(4, 0, 0, 1.0836693f) }; super.setUp(); diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java index 76cbd8d083..33029251a3 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java @@ -34,11 +34,14 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase { truth = new Mat(1, 128, CvType.CV_32FC1) { { put(0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 16, 12, 17, 28, 26, 0, 0, 2, 23, 14, 12, 9, 6, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14, 88, 23, 17, 24, 29, 0, 117, 54, 117, 116, 117, 22, 29, 27, 117, 59, 76, 19, 30, 2, 9, 26, 2, 7, 6, 0, 0, - 0, 0, 0, 0, 8, 50, 16, 30, 58, 89, 0, 117, 49, 95, 75, 117, 112, 117, 93, 81, 86, 117, 5, 5, 39, 117, 71, 20, - 20, 12, 0, 0, 1, 20, 19, 0, 0, 0, 2, 14, 4, 1, 0, 69, 0, 0, 14, 90, 31, 35, 56, 25, 0, 0, 0, 0, 2, 12, 16, 0, - 0, 0, 0, 0, 0, 2, 1); + 0, 0, 0, 1, 3, 0, 0, 0, 15, 23, 22, 20, 24, 2, 0, 0, 7, 8, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 16, 13, 2, 0, 0, 117, + 86, 79, 68, 117, 42, 5, 5, 79, 60, 117, 25, 9, 2, 28, 19, 11, 13, + 20, 2, 0, 0, 5, 8, 0, 0, 76, 58, 34, 31, 97, 16, 95, 49, 117, 92, + 117, 112, 117, 76, 117, 54, 117, 25, 29, 22, 117, 117, 16, 11, 14, + 1, 0, 0, 22, 26, 0, 0, 0, 0, 1, 4, 15, 2, 47, 8, 0, 0, 82, 56, 31, + 17, 81, 12, 0, 0, 26, 23, 18, 23, 0, 0, 0, 0, 0, 0, 0, 0 + ); } }; @@ -76,18 +79,7 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase { } public void testRead() { - MatOfKeyPoint keypoints =new MatOfKeyPoint(keypoint); - Mat img = getTestImg(); - Mat descriptors = new Mat(); - - String filename = OpenCVTestRunner.getTempFileName("yml"); - writeFile(filename, - "%YAML:1.0\nmagnification: 3.\nisNormalize: 1\nrecalculateAngles: 1\nnOctaves: 6\nnOctaveLayers: 4\nfirstOctave: -1\nangleMode: 0\n"); - - extractor.read(filename); - - extractor.compute(img, keypoints, descriptors); - assertMatNotEqual(truth, descriptors, EPS); + fail("Not yet implemented"); } public void testWrite() { diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java index 80cad8e093..56fcd28de8 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java @@ -47,19 +47,20 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase { Mat truth = new Mat(1, 128, CvType.CV_32FC1) { { put(0, 0, - -0.0041138371, 0.0041138371, 0, 0, 0, 0, 0.0014427509, 0.0014427509, -0.0081971241, 0.034624498, 0.032569118, - 0.032569118, -0.007222258, 0.0076424959, 0.0033254174, 0.0033254174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.10815519, 0.38033518, 0.24314292, 0.24314292, -0.068393648, 0.068393648, - 0.039715949, 0.039715949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8.7263528e-05, 8.7263528e-05, -6.0081031e-05, - 6.0081031e-05, -0.00012158759, 0.00012158759, 0.0033254174, 0.0033254174, -0.007222258, 0.0076424964, - 0.0081971241, 0.034624498, -0.032569118, 0.032569118, -0.077379324, 0.27552885, 0.14366581, 0.31175563, - -0.013609707, 0.24329227, -0.091054246, 0.17476201, 0.022970313, 0.022970313, -0.035123408, 0.035771687, - 0.1907353, 0.3838968, -0.31571922, 0.31571922, 0.0092833797, 0.0092833797, -0.012892088, 0.012957365, - 0.029558292, 0.073337689, -0.043703932, 0.043703932, 0.0014427509, 0.0014427509, 0, 0, 0.0041138371, - 0.0041138371, 0, 0, -0.02955829, 0.073337704, 0.043703932, 0.043703932, -0.012892087, 0.012957364, - 0.0092833797,0.0092833797, 6.0081031e-05, 6.0081031e-05, 0.00012158759, 0.00012158759, -8.7263528e-05, - 8.7263528e-05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ); + 0, 0, 0, 0, 0, 0, 0, 0, 0.045382127, 0.075976953, -0.031969212, 0.035002094, 0.012224297, + 0.012286193, -0.0088025155, 0.0088025155, 0.00017225844, 0.00017225844, 0, 0, 8.2743405e-05, + 8.2743405e-05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8.2743405e-05, 8.2743405e-05, -0.00017225844, + 0.00017225844, 0, 0, 0.31723264, 0.42715758, -0.19872268, 0.23621935, 0.033304065, 0.033918764, + -0.021780485, 0.021780485, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0088025145, + 0.0088025145, 0.012224296, 0.012286192, -0.045382123, 0.075976953, 0.031969212, 0.035002094, + 0.10047197, 0.21463872, -0.0012294546, 0.18176091, -0.075555265, 0.35627601, 0.01270232, + 0.20058797, -0.037658721, 0.037658721, 0.064850949, 0.064850949, -0.27688536, 0.44229308, + 0.14888979, 0.14888979, -0.0031531656, 0.0031531656, 0.0068481555, 0.0072466261, -0.034193151, + 0.040314503, 0.01108359, 0.023398584, -0.00071876607, 0.00071876607, -0.0031819802, + 0.0031819802, 0, 0, -0.0013680183, 0.0013680183, 0.034193147, 0.040314503, -0.01108359, + 0.023398584, 0.006848156, 0.0072466265, -0.0031531656, 0.0031531656, 0, 0, 0, 0, 0, 0, 0, 0, + -0.0013680183, 0.0013680183, 0, 0, 0.00071876607, 0.00071876607, 0.0031819802, 0.0031819802 + ); } }; diff --git a/modules/java/generator/src/java/android+AsyncServiceHelper.java b/modules/java/generator/src/java/android+AsyncServiceHelper.java index 6e86f7541c..adf0e41a1b 100644 --- a/modules/java/generator/src/java/android+AsyncServiceHelper.java +++ b/modules/java/generator/src/java/android+AsyncServiceHelper.java @@ -41,7 +41,7 @@ class AsyncServiceHelper } protected static final String TAG = "OpenCVManager/Helper"; - protected static final int MINIMUM_ENGINE_VERSION = 1; + protected static final int MINIMUM_ENGINE_VERSION = 2; protected OpenCVEngineInterface mEngineService; protected LoaderCallbackInterface mUserAppCallback; protected String mOpenCVersion; diff --git a/modules/java/generator/src/java/android+BaseLoaderCallback.java b/modules/java/generator/src/java/android+BaseLoaderCallback.java index edc94875ba..6d6a9b8dad 100644 --- a/modules/java/generator/src/java/android+BaseLoaderCallback.java +++ b/modules/java/generator/src/java/android+BaseLoaderCallback.java @@ -52,7 +52,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface { Log.d(TAG, "OpenCV Manager Service is uncompatible with this app!"); AlertDialog IncomatibilityMessage = new AlertDialog.Builder(mAppContext).create(); IncomatibilityMessage.setTitle("OpenCV Manager"); - IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Update it!"); + IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Try to update it via Google Play."); IncomatibilityMessage.setCancelable(false); // This blocks the 'BACK' button IncomatibilityMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { @@ -60,7 +60,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface { } }); IncomatibilityMessage.show(); - } + } break; /** Other status, i.e. INIT_FAILED. **/ default: { @@ -113,7 +113,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface { { AlertDialog WaitMessage = new AlertDialog.Builder(mAppContext).create(); WaitMessage.setTitle("OpenCV is not ready"); - WaitMessage.setMessage("Installation is in progeress. Wait or exit?"); + WaitMessage.setMessage("Installation is in progress. Wait or exit?"); WaitMessage.setCancelable(false); // This blocks the 'BACK' button WaitMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Wait", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { diff --git a/modules/java/generator/src/java/android+CameraBridgeViewBase.java b/modules/java/generator/src/java/android+CameraBridgeViewBase.java index 1231eeb359..cbcd78b35e 100644 --- a/modules/java/generator/src/java/android+CameraBridgeViewBase.java +++ b/modules/java/generator/src/java/android+CameraBridgeViewBase.java @@ -23,10 +23,10 @@ import android.view.SurfaceView; * The main responsibility of it - is to control when camera can be enabled, process the frame, * call external listener to make any adjustments to the frame and then draw the resulting * frame to the screen. - * The clients shall implement CvCameraViewListener - * TODO: add method to control the format in which the frames will be delivered to CvCameraViewListener + * The clients shall implement CvCameraViewListener. */ public abstract class CameraBridgeViewBase extends SurfaceView implements SurfaceHolder.Callback { +//TODO: add method to control the format in which the frames will be delivered to CvCameraViewListener private static final int MAX_UNSPECIFIED = -1; diff --git a/modules/java/generator/src/java/android+JavaCameraView.java b/modules/java/generator/src/java/android+JavaCameraView.java index 6e2b6cadef..f8b3787819 100644 --- a/modules/java/generator/src/java/android+JavaCameraView.java +++ b/modules/java/generator/src/java/android+JavaCameraView.java @@ -1,6 +1,5 @@ package org.opencv.android; -import java.io.IOException; import java.util.List; import android.annotation.TargetApi; @@ -21,7 +20,7 @@ import org.opencv.highgui.Highgui; import org.opencv.imgproc.Imgproc; /** - * This class is an implementation of the Bridge View between OpenCv and JAVA Camera. + * This class is an implementation of the Bridge View between OpenCV and Java Camera. * This class relays on the functionality available in base class and only implements * required functions: * connectCamera - opens Java camera and sets the PreviewCallback to be delivered. @@ -36,7 +35,8 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb private Mat mBaseMat; private byte mBuffer[]; - + private Mat[] mFrameChain; + private int mChainIdx = 0; private Thread mThread; private boolean mStopThread; @@ -65,6 +65,7 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb @TargetApi(11) protected boolean initializeCamera(int width, int height) { Log.d(TAG, "Initialize java camera"); + boolean result = true; synchronized (this) { mCamera = null; @@ -99,59 +100,76 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb Log.d(TAG, "getSupportedPreviewSizes()"); List sizes = params.getSupportedPreviewSizes(); - /* Select the size that fits surface considering maximum size allowed */ - Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height); + if (sizes != null) { + /* Select the size that fits surface considering maximum size allowed */ + Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height); - params.setPreviewFormat(ImageFormat.NV21); - Log.d(TAG, "Set preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height)); - params.setPreviewSize((int)frameSize.width, (int)frameSize.height); + params.setPreviewFormat(ImageFormat.NV21); + Log.d(TAG, "Set preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height)); + params.setPreviewSize((int)frameSize.width, (int)frameSize.height); - List FocusModes = params.getSupportedFocusModes(); - if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) - { - params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); + List FocusModes = params.getSupportedFocusModes(); + if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) + { + params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); + } + + mCamera.setParameters(params); + params = mCamera.getParameters(); + + mFrameWidth = params.getPreviewSize().width; + mFrameHeight = params.getPreviewSize().height; + + int size = mFrameWidth * mFrameHeight; + size = size * ImageFormat.getBitsPerPixel(params.getPreviewFormat()) / 8; + mBuffer = new byte[size]; + + mCamera.addCallbackBuffer(mBuffer); + mCamera.setPreviewCallbackWithBuffer(this); + + mBaseMat = new Mat(mFrameHeight + (mFrameHeight/2), mFrameWidth, CvType.CV_8UC1); + + mFrameChain = new Mat[2]; + mFrameChain[0] = new Mat(); + mFrameChain[1] = new Mat(); + + AllocateCache(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + mSurfaceTexture = new SurfaceTexture(MAGIC_TEXTURE_ID); + getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + mCamera.setPreviewTexture(mSurfaceTexture); + } else + mCamera.setPreviewDisplay(null); + + /* Finally we are ready to start the preview */ + Log.d(TAG, "startPreview"); + mCamera.startPreview(); } - - mCamera.setParameters(params); - params = mCamera.getParameters(); - - mFrameWidth = params.getPreviewSize().width; - mFrameHeight = params.getPreviewSize().height; - - int size = mFrameWidth * mFrameHeight; - size = size * ImageFormat.getBitsPerPixel(params.getPreviewFormat()) / 8; - mBuffer = new byte[size]; - - mCamera.addCallbackBuffer(mBuffer); - mCamera.setPreviewCallbackWithBuffer(this); - - mBaseMat = new Mat(mFrameHeight + (mFrameHeight/2), mFrameWidth, CvType.CV_8UC1); - - AllocateCache(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - mSurfaceTexture = new SurfaceTexture(MAGIC_TEXTURE_ID); - getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - mCamera.setPreviewTexture(mSurfaceTexture); - } else - mCamera.setPreviewDisplay(null); - } catch (IOException e) { + else + result = false; + } catch (Exception e) { + result = false; e.printStackTrace(); } - - /* Finally we are ready to start the preview */ - Log.d(TAG, "startPreview"); - mCamera.startPreview(); } - return true; + return result; } protected void releaseCamera() { synchronized (this) { - mCamera.stopPreview(); - mCamera.release(); + if (mCamera != null) { + mCamera.stopPreview(); + mCamera.release(); + } mCamera = null; + if (mBaseMat != null) + mBaseMat.release(); + if (mFrameChain != null) { + mFrameChain[0].release(); + mFrameChain[1].release(); + } } } @@ -187,7 +205,8 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb this.notify(); } Log.d(TAG, "Wating for thread"); - mThread.join(); + if (mThread != null) + mThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } finally { @@ -224,19 +243,19 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb } if (!mStopThread) { - Mat frameMat = new Mat(); switch (mPreviewFormat) { case Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA: - Imgproc.cvtColor(mBaseMat, frameMat, Imgproc.COLOR_YUV2RGBA_NV21, 4); + Imgproc.cvtColor(mBaseMat, mFrameChain[mChainIdx], Imgproc.COLOR_YUV2RGBA_NV21, 4); break; case Highgui.CV_CAP_ANDROID_GREY_FRAME: - frameMat = mBaseMat.submat(0, mFrameHeight, 0, mFrameWidth); + mFrameChain[mChainIdx] = mBaseMat.submat(0, mFrameHeight, 0, mFrameWidth); break; default: Log.e(TAG, "Invalid frame format! Only RGBA and Gray Scale are supported!"); }; - deliverAndDrawFrame(frameMat); - frameMat.release(); + if (!mFrameChain[mChainIdx].empty()) + deliverAndDrawFrame(mFrameChain[mChainIdx]); + mChainIdx = 1 - mChainIdx; } } while (!mStopThread); Log.d(TAG, "Finish processing thread"); diff --git a/modules/legacy/test/test_precomp.hpp b/modules/legacy/test/test_precomp.hpp index dd9dd0e7ed..f40c7d406c 100644 --- a/modules/legacy/test/test_precomp.hpp +++ b/modules/legacy/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/ml/doc/statistical_models.rst b/modules/ml/doc/statistical_models.rst index 49ac58e278..75ecd5c055 100644 --- a/modules/ml/doc/statistical_models.rst +++ b/modules/ml/doc/statistical_models.rst @@ -156,7 +156,7 @@ CvStatModel::predict -------------------- Predicts the response for a sample. -.. ocv:function:: float CvStatModel::predict( const Mat& sample[, ] ) const +.. ocv:function:: float CvStatModel::predict( const Mat& sample, ) const The method is used to predict the response for a new sample. In case of a classification, the method returns the class label. In case of a regression, the method returns the output function value. The input sample must have as many components as the ``train_data`` passed to ``train`` contains. If the ``var_idx`` parameter is passed to ``train``, it is remembered and then is used to extract only the necessary components from the input sample in the method ``predict``. diff --git a/modules/ml/test/test_precomp.hpp b/modules/ml/test/test_precomp.hpp index 8cda65f831..46334d5277 100644 --- a/modules/ml/test/test_precomp.hpp +++ b/modules/ml/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/nonfree/perf/perf_precomp.hpp b/modules/nonfree/perf/perf_precomp.hpp index 62b601e95f..3afb5b4c35 100644 --- a/modules/nonfree/perf/perf_precomp.hpp +++ b/modules/nonfree/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/nonfree/test/test_precomp.hpp b/modules/nonfree/test/test_precomp.hpp index 39ac7ecdeb..cbf5253abe 100644 --- a/modules/nonfree/test/test_precomp.hpp +++ b/modules/nonfree/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/objdetect/perf/perf_cascadeclassifier.cpp b/modules/objdetect/perf/perf_cascadeclassifier.cpp index df8b5ae207..98007e45d3 100644 --- a/modules/objdetect/perf/perf_cascadeclassifier.cpp +++ b/modules/objdetect/perf/perf_cascadeclassifier.cpp @@ -12,13 +12,10 @@ typedef perf::TestBaseWithParam ImageName_MinSize; PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace, testing::Combine(testing::Values( std::string("cv/shared/lena.png"), - std::string("cv/shared/1_itseez-0000247.png"), std::string("cv/shared/1_itseez-0000289.png"), std::string("cv/shared/1_itseez-0000492.png"), std::string("cv/shared/1_itseez-0000573.png"), - std::string("cv/shared/1_itseez-0000803.png"), std::string("cv/shared/1_itseez-0000892.png"), - std::string("cv/shared/1_itseez-0000984.png"), std::string("cv/shared/1_itseez-0001238.png"), std::string("cv/shared/1_itseez-0001438.png"), std::string("cv/shared/1_itseez-0002524.png")), @@ -53,5 +50,5 @@ PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace, } std::sort(faces.begin(), faces.end(), comparators::RectLess()); - SANITY_CHECK(faces); + SANITY_CHECK(faces, 3.001 * faces.size()); } diff --git a/modules/objdetect/perf/perf_precomp.hpp b/modules/objdetect/perf/perf_precomp.hpp index 234cb83a39..c5ae36cf94 100644 --- a/modules/objdetect/perf/perf_precomp.hpp +++ b/modules/objdetect/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index 92da4ac25d..96bc7603b6 100644 --- a/modules/objdetect/src/haar.cpp +++ b/modules/objdetect/src/haar.cpp @@ -728,8 +728,14 @@ double icvEvalHidHaarClassifierAVX( CvHidHaarClassifier* classifier, sum = _mm256_add_ps(sum,_mm256_load_ps(tmp)); - __m256 left = _mm256_set_ps(nodes[7]->left, nodes[6]->left, nodes[5]->left, nodes[4]->left, nodes[3]->left, nodes[2]->left, nodes[1]->left, nodes[0]->left ); - __m256 right = _mm256_set_ps(nodes[7]->right,nodes[6]->right,nodes[5]->right,nodes[4]->right,nodes[3]->right,nodes[2]->right,nodes[1]->right,nodes[0]->right); + __m256 left = _mm256_set_ps(static_cast(nodes[7]->left), static_cast(nodes[6]->left), + static_cast(nodes[5]->left), static_cast(nodes[4]->left), + static_cast(nodes[3]->left), static_cast(nodes[2]->left), + static_cast(nodes[1]->left), static_cast(nodes[0]->left)); + __m256 right = _mm256_set_ps(static_cast(nodes[7]->right),static_cast(nodes[6]->right), + static_cast(nodes[5]->right),static_cast(nodes[4]->right), + static_cast(nodes[3]->right),static_cast(nodes[2]->right), + static_cast(nodes[1]->right),static_cast(nodes[0]->right)); _mm256_store_si256((__m256i*)idxV, _mm256_cvttps_epi32(_mm256_blendv_ps(right, left, _mm256_cmp_ps(sum, t, _CMP_LT_OQ)))); diff --git a/modules/objdetect/test/test_latentsvmdetector.cpp b/modules/objdetect/test/test_latentsvmdetector.cpp index 8800f09174..b595d7ac51 100644 --- a/modules/objdetect/test/test_latentsvmdetector.cpp +++ b/modules/objdetect/test/test_latentsvmdetector.cpp @@ -307,5 +307,5 @@ void LatentSVMDetectorTest::run( int /* start_from */) ts->set_failed_test_info( cvtest::TS::OK); } -TEST(Objdetect_LatentSVMDetector_c, regression) { CV_LatentSVMDetectorTest test; test.safe_run(); } -TEST(Objdetect_LatentSVMDetector_cpp, regression) { LatentSVMDetectorTest test; test.safe_run(); } +TEST(Objdetect_LatentSVMDetector_c, DISABLED_regression) { CV_LatentSVMDetectorTest test; test.safe_run(); } +TEST(Objdetect_LatentSVMDetector_cpp, DISABLED_regression) { LatentSVMDetectorTest test; test.safe_run(); } diff --git a/modules/objdetect/test/test_precomp.hpp b/modules/objdetect/test/test_precomp.hpp index 041fa24c5f..cb7ac0f157 100644 --- a/modules/objdetect/test/test_precomp.hpp +++ b/modules/objdetect/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/ocl/doc/data_structures.rst b/modules/ocl/doc/data_structures.rst new file mode 100644 index 0000000000..a9c24906eb --- /dev/null +++ b/modules/ocl/doc/data_structures.rst @@ -0,0 +1,189 @@ +Data Structures +============================= + +.. ocv:class:: oclMat + +OpenCV C++ 1-D or 2-D dense array class :: + + class CV_EXPORTS oclMat + { + public: + //! default constructor + oclMat(); + //! constructs oclMatrix of the specified size and type (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) + oclMat(int rows, int cols, int type); + oclMat(Size size, int type); + //! constucts oclMatrix and fills it with the specified value _s. + oclMat(int rows, int cols, int type, const Scalar &s); + oclMat(Size size, int type, const Scalar &s); + //! copy constructor + oclMat(const oclMat &m); + + //! constructor for oclMatrix headers pointing to user-allocated data + oclMat(int rows, int cols, int type, void *data, size_t step = Mat::AUTO_STEP); + oclMat(Size size, int type, void *data, size_t step = Mat::AUTO_STEP); + + //! creates a matrix header for a part of the bigger matrix + oclMat(const oclMat &m, const Range &rowRange, const Range &colRange); + oclMat(const oclMat &m, const Rect &roi); + + //! builds oclMat from Mat. Perfom blocking upload to device. + explicit oclMat (const Mat &m); + + //! destructor - calls release() + ~oclMat(); + + //! assignment operators + oclMat &operator = (const oclMat &m); + //! assignment operator. Perfom blocking upload to device. + oclMat &operator = (const Mat &m); + + + //! pefroms blocking upload data to oclMat. + void upload(const cv::Mat &m); + + + //! downloads data from device to host memory. Blocking calls. + operator Mat() const; + void download(cv::Mat &m) const; + + + //! returns a new oclMatrix header for the specified row + oclMat row(int y) const; + //! returns a new oclMatrix header for the specified column + oclMat col(int x) const; + //! ... for the specified row span + oclMat rowRange(int startrow, int endrow) const; + oclMat rowRange(const Range &r) const; + //! ... for the specified column span + oclMat colRange(int startcol, int endcol) const; + oclMat colRange(const Range &r) const; + + //! returns deep copy of the oclMatrix, i.e. the data is copied + oclMat clone() const; + //! copies the oclMatrix content to "m". + // It calls m.create(this->size(), this->type()). + // It supports any data type + void copyTo( oclMat &m ) const; + //! copies those oclMatrix elements to "m" that are marked with non-zero mask elements. + //It supports 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 + void copyTo( oclMat &m, const oclMat &mask ) const; + //! converts oclMatrix to another datatype with optional scalng. See cvConvertScale. + //It supports 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 + void convertTo( oclMat &m, int rtype, double alpha = 1, double beta = 0 ) const; + + void assignTo( oclMat &m, int type = -1 ) const; + + //! sets every oclMatrix element to s + //It supports 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 + oclMat &operator = (const Scalar &s); + //! sets some of the oclMatrix elements to s, according to the mask + //It supports 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 + oclMat &setTo(const Scalar &s, const oclMat &mask = oclMat()); + //! creates alternative oclMatrix header for the same data, with different + // number of channels and/or different number of rows. see cvReshape. + oclMat reshape(int cn, int rows = 0) const; + + //! allocates new oclMatrix data unless the oclMatrix already has specified size and type. + // previous data is unreferenced if needed. + void create(int rows, int cols, int type); + void create(Size size, int type); + //! decreases reference counter; + // deallocate the data when reference counter reaches 0. + void release(); + + //! swaps with other smart pointer + void swap(oclMat &mat); + + //! locates oclMatrix header within a parent oclMatrix. See below + void locateROI( Size &wholeSize, Point &ofs ) const; + //! moves/resizes the current oclMatrix ROI inside the parent oclMatrix. + oclMat &adjustROI( int dtop, int dbottom, int dleft, int dright ); + //! extracts a rectangular sub-oclMatrix + // (this is a generalized form of row, rowRange etc.) + oclMat operator()( Range rowRange, Range colRange ) const; + oclMat operator()( const Rect &roi ) const; + + //! returns true if the oclMatrix data is continuous + // (i.e. when there are no gaps between successive rows). + // similar to CV_IS_oclMat_CONT(cvoclMat->type) + bool isContinuous() const; + //! returns element size in bytes, + // similar to CV_ELEM_SIZE(cvMat->type) + size_t elemSize() const; + //! returns the size of element channel in bytes. + size_t elemSize1() const; + //! returns element type, similar to CV_MAT_TYPE(cvMat->type) + int type() const; + //! returns element type, i.e. 8UC3 returns 8UC4 because in ocl + //! 3 channels element actually use 4 channel space + int ocltype() const; + //! returns element type, similar to CV_MAT_DEPTH(cvMat->type) + int depth() const; + //! returns element type, similar to CV_MAT_CN(cvMat->type) + int channels() const; + //! returns element type, return 4 for 3 channels element, + //!becuase 3 channels element actually use 4 channel space + int oclchannels() const; + //! returns step/elemSize1() + size_t step1() const; + //! returns oclMatrix size: + // width == number of columns, height == number of rows + Size size() const; + //! returns true if oclMatrix data is NULL + bool empty() const; + + //! returns pointer to y-th row + uchar *ptr(int y = 0); + const uchar *ptr(int y = 0) const; + + //! template version of the above method + template _Tp *ptr(int y = 0); + template const _Tp *ptr(int y = 0) const; + + //! matrix transposition + oclMat t() const; + + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + //! the number of rows and columns + int rows, cols; + //! a distance between successive rows in bytes; includes the gap if any + size_t step; + //! pointer to the data(OCL memory object) + uchar *data; + + //! pointer to the reference counter; + // when oclMatrix points to user-allocated data, the pointer is NULL + int *refcount; + + //! helper fields used in locateROI and adjustROI + //datastart and dataend are not used in current version + uchar *datastart; + uchar *dataend; + + //! OpenCL context associated with the oclMat object. + Context *clCxt; + //add offset for handle ROI, calculated in byte + int offset; + //add wholerows and wholecols for the whole matrix, datastart and dataend are no longer used + int wholerows; + int wholecols; + }; + +Basically speaking, the oclMat is the mirror of Mat with the extension of ocl feature, the members have the same meaning and useage of Mat except following: + +datastart and dataend are replaced with wholerows and wholecols + +add clCxt for oclMat + +Only basic flags are supported in oclMat(i.e. depth number of channels) + +All the 3-channel matrix(i.e. RGB image) are represented by 4-channel matrix in oclMat. It means 3-channel image have 4-channel space with the last channel unused. We provide a transparent interface to handle the difference between OpenCV Mat and oclMat. + +For example: If a oclMat has 3 channels, channels() returns 3 and oclchannels() returns 4 \ No newline at end of file diff --git a/modules/ocl/doc/feature_detection_and_description.rst b/modules/ocl/doc/feature_detection_and_description.rst new file mode 100644 index 0000000000..aa2ed857c8 --- /dev/null +++ b/modules/ocl/doc/feature_detection_and_description.rst @@ -0,0 +1,502 @@ +Feature Detection And Description +================================= + +.. highlight:: cpp + +ocl::Canny +------------------- +Finds edges in an image using the [Canny86]_ algorithm. + +.. ocv:function:: void ocl::Canny(const oclMat& image, oclMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false) + +.. ocv:function:: void ocl::Canny(const oclMat& image, CannyBuf& buf, oclMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false) + +.. ocv:function:: void ocl::Canny(const oclMat& dx, const oclMat& dy, oclMat& edges, double low_thresh, double high_thresh, bool L2gradient = false) + +.. ocv:function:: void ocl::Canny(const oclMat& dx, const oclMat& dy, CannyBuf& buf, oclMat& edges, double low_thresh, double high_thresh, bool L2gradient = false) + + :param image: Single-channel 8-bit input image. + + :param dx: First derivative of image in the vertical direction. Support only ``CV_32S`` type. + + :param dy: First derivative of image in the horizontal direction. Support only ``CV_32S`` type. + + :param edges: Output edge map. It has the same size and type as ``image`` . + + :param low_thresh: First threshold for the hysteresis procedure. + + :param high_thresh: Second threshold for the hysteresis procedure. + + :param apperture_size: Aperture size for the :ocv:func:`Sobel` operator. + + :param L2gradient: Flag indicating whether a more accurate :math:`L_2` norm :math:`=\sqrt{(dI/dx)^2 + (dI/dy)^2}` should be used to compute the image gradient magnitude ( ``L2gradient=true`` ), or a faster default :math:`L_1` norm :math:`=|dI/dx|+|dI/dy|` is enough ( ``L2gradient=false`` ). + + :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). + +.. seealso:: :ocv:func:`Canny` + + +ocl::BruteForceMatcher_OCL +-------------------------- +.. ocv:class:: ocl::BruteForceMatcher_OCL_base + +Brute-force descriptor matcher. For each descriptor in the first set, this matcher finds the closest descriptor in the second set by trying each one. This descriptor matcher supports masking permissible matches between descriptor sets. :: + + class BruteForceMatcher_OCL_base + { + public: + enum DistType {L1Dist = 0, L2Dist, HammingDist}; + + // Add descriptors to train descriptor collection. + void add(const std::vector& descCollection); + + // Get train descriptors collection. + const std::vector& getTrainDescriptors() const; + + // Clear train descriptors collection. + void clear(); + + // Return true if there are no train descriptors in collection. + bool empty() const; + + // Return true if the matcher supports mask in match methods. + bool isMaskSupported() const; + + void matchSingle(const oclMat& query, const oclMat& train, + oclMat& trainIdx, oclMat& distance, + const oclMat& mask = oclMat()); + + static void matchDownload(const oclMat& trainIdx, + const oclMat& distance, std::vector& matches); + static void matchConvert(const Mat& trainIdx, + const Mat& distance, std::vector& matches); + + void match(const oclMat& query, const oclMat& train, + std::vector& matches, const oclMat& mask = oclMat()); + + void makeGpuCollection(oclMat& trainCollection, oclMat& maskCollection, + const vector& masks = std::vector()); + + void matchCollection(const oclMat& query, const oclMat& trainCollection, + oclMat& trainIdx, oclMat& imgIdx, oclMat& distance, + const oclMat& maskCollection); + + static void matchDownload(const oclMat& trainIdx, oclMat& imgIdx, + const oclMat& distance, std::vector& matches); + static void matchConvert(const Mat& trainIdx, const Mat& imgIdx, + const Mat& distance, std::vector& matches); + + void match(const oclMat& query, std::vector& matches, + const std::vector& masks = std::vector()); + + void knnMatchSingle(const oclMat& query, const oclMat& train, + oclMat& trainIdx, oclMat& distance, oclMat& allDist, int k, + const oclMat& mask = oclMat()); + + static void knnMatchDownload(const oclMat& trainIdx, const oclMat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + static void knnMatchConvert(const Mat& trainIdx, const Mat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + + void knnMatch(const oclMat& query, const oclMat& train, + std::vector< std::vector >& matches, int k, + const oclMat& mask = oclMat(), bool compactResult = false); + + void knnMatch2Collection(const oclMat& query, const oclMat& trainCollection, + oclMat& trainIdx, oclMat& imgIdx, oclMat& distance, + const oclMat& maskCollection = oclMat()); + + static void knnMatch2Download(const oclMat& trainIdx, const oclMat& imgIdx, const oclMat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + static void knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + + void knnMatch(const oclMat& query, std::vector< std::vector >& matches, int k, + const std::vector& masks = std::vector(), + bool compactResult = false); + + void radiusMatchSingle(const oclMat& query, const oclMat& train, + oclMat& trainIdx, oclMat& distance, oclMat& nMatches, float maxDistance, + const oclMat& mask = oclMat()); + + static void radiusMatchDownload(const oclMat& trainIdx, const oclMat& distance, const oclMat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + static void radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + + void radiusMatch(const oclMat& query, const oclMat& train, + std::vector< std::vector >& matches, float maxDistance, + const oclMat& mask = oclMat(), bool compactResult = false); + + void radiusMatchCollection(const oclMat& query, oclMat& trainIdx, oclMat& imgIdx, oclMat& distance, oclMat& nMatches, float maxDistance, + const std::vector& masks = std::vector()); + + static void radiusMatchDownload(const oclMat& trainIdx, const oclMat& imgIdx, const oclMat& distance, const oclMat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + static void radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + + void radiusMatch(const oclMat& query, std::vector< std::vector >& matches, float maxDistance, + const std::vector& masks = std::vector(), bool compactResult = false); + + DistType distType; + + private: + std::vector trainDescCollection; + }; + + +The class ``BruteForceMatcher_OCL_base`` has an interface similar to the class :ocv:class:`DescriptorMatcher`. It has two groups of ``match`` methods: for matching descriptors of one image with another image or with an image set. Also, all functions have an alternative to save results either to the GPU memory or to the CPU memory. ``BruteForceMatcher_OCL_base`` supports only the ``L1``, ``L2``, and ``Hamming`` distance types. + +.. seealso:: :ocv:class:`DescriptorMatcher`, :ocv:class:`BruteForceMatcher` + + + +ocl::BruteForceMatcher_OCL_base::match +-------------------------------------- +Finds the best match for each descriptor from a query set with train descriptors. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::match(const oclMat& query, const oclMat& train, std::vector& matches, const oclMat& mask = oclMat()) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::matchSingle(const oclMat& query, const oclMat& train, oclMat& trainIdx, oclMat& distance, const oclMat& mask = oclMat()) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::match(const oclMat& query, std::vector& matches, const std::vector& masks = std::vector()) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::matchCollection(const oclMat& query, const oclMat& trainCollection, oclMat& trainIdx, oclMat& imgIdx, oclMat& distance, const oclMat& masks) + +.. seealso:: :ocv:func:`DescriptorMatcher::match` + + + +ocl::BruteForceMatcher_OCL_base::makeGpuCollection +-------------------------------------------------- +Performs a GPU collection of train descriptors and masks in a suitable format for the :ocv:func:`ocl::BruteForceMatcher_OCL_base::matchCollection` function. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::makeGpuCollection(oclMat& trainCollection, oclMat& maskCollection, const vector& masks = std::vector()) + + + +ocl::BruteForceMatcher_OCL_base::matchDownload +---------------------------------------------- +Downloads matrices obtained via :ocv:func:`ocl::BruteForceMatcher_OCL_base::matchSingle` or :ocv:func:`ocl::BruteForceMatcher_OCL_base::matchCollection` to vector with :ocv:class:`DMatch`. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat& trainIdx, const oclMat& distance, std::vector&matches) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat& trainIdx, oclMat& imgIdx, const oclMat& distance, std::vector&matches) + + + +ocl::BruteForceMatcher_OCL_base::matchConvert +--------------------------------------------- +Converts matrices obtained via :ocv:func:`ocl::BruteForceMatcher_OCL_base::matchSingle` or :ocv:func:`ocl::BruteForceMatcher_OCL_base::matchCollection` to vector with :ocv:class:`DMatch`. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat& trainIdx, const Mat& distance, std::vector&matches) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector&matches) + + + +ocl::BruteForceMatcher_OCL_base::knnMatch +----------------------------------------- +Finds the ``k`` best matches for each descriptor from a query set with train descriptors. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat& query, const oclMat& train, std::vector< std::vector >&matches, int k, const oclMat& mask = oclMat(), bool compactResult = false) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatchSingle(const oclMat& query, const oclMat& train, oclMat& trainIdx, oclMat& distance, oclMat& allDist, int k, const oclMat& mask = oclMat()) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat& query, std::vector< std::vector >&matches, int k, const std::vector&masks = std::vector(), bool compactResult = false ) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatch2Collection(const oclMat& query, const oclMat& trainCollection, oclMat& trainIdx, oclMat& imgIdx, oclMat& distance, const oclMat& maskCollection = oclMat()) + + :param query: Query set of descriptors. + + :param train: Training set of descriptors. It is not be added to train descriptors collection stored in the class object. + + :param k: Number of the best matches per each query descriptor (or less if it is not possible). + + :param mask: Mask specifying permissible matches between the input query and train matrices of descriptors. + + :param compactResult: If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors. + + +The function returns detected ``k`` (or less if not possible) matches in the increasing order by distance. + +The third variant of the method stores the results in GPU memory. + +.. seealso:: :ocv:func:`DescriptorMatcher::knnMatch` + + + +ocl::BruteForceMatcher_OCL_base::knnMatchDownload +------------------------------------------------- +Downloads matrices obtained via :ocv:func:`ocl::BruteForceMatcher_OCL_base::knnMatchSingle` or :ocv:func:`ocl::BruteForceMatcher_OCL_base::knnMatch2Collection` to vector with :ocv:class:`DMatch`. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatchDownload(const oclMat& trainIdx, const oclMat& distance, std::vector< std::vector >&matches, bool compactResult = false) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatch2Download(const oclMat& trainIdx, const oclMat& imgIdx, const oclMat& distance, std::vector< std::vector >& matches, bool compactResult = false) + +If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors. + + + +ocl::BruteForceMatcher_OCL_base::knnMatchConvert +------------------------------------------------ +Converts matrices obtained via :ocv:func:`ocl::BruteForceMatcher_OCL_base::knnMatchSingle` or :ocv:func:`ocl::BruteForceMatcher_OCL_base::knnMatch2Collection` to CPU vector with :ocv:class:`DMatch`. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatchConvert(const Mat& trainIdx, const Mat& distance, std::vector< std::vector >&matches, bool compactResult = false) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector< std::vector >& matches, bool compactResult = false) + +If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors. + + + +ocl::BruteForceMatcher_OCL_base::radiusMatch +-------------------------------------------- +For each query descriptor, finds the best matches with a distance less than a given threshold. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatch(const oclMat& query, const oclMat& train, std::vector< std::vector >&matches, float maxDistance, const oclMat& mask = oclMat(), bool compactResult = false) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatchSingle(const oclMat& query, const oclMat& train, oclMat& trainIdx, oclMat& distance, oclMat& nMatches, float maxDistance, const oclMat& mask = oclMat()) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatch(const oclMat& query, std::vector< std::vector >&matches, float maxDistance, const std::vector& masks = std::vector(), bool compactResult = false) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatchCollection(const oclMat& query, oclMat& trainIdx, oclMat& imgIdx, oclMat& distance, oclMat& nMatches, float maxDistance, const std::vector& masks = std::vector()) + + :param query: Query set of descriptors. + + :param train: Training set of descriptors. It is not added to train descriptors collection stored in the class object. + + :param maxDistance: Distance threshold. + + :param mask: Mask specifying permissible matches between the input query and train matrices of descriptors. + + :param compactResult: If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors. + + +The function returns detected matches in the increasing order by distance. + +The methods work only on devices with the compute capability :math:`>=` 1.1. + +The third variant of the method stores the results in GPU memory and does not store the points by the distance. + +.. seealso:: :ocv:func:`DescriptorMatcher::radiusMatch` + + + +ocl::BruteForceMatcher_OCL_base::radiusMatchDownload +---------------------------------------------------- +Downloads matrices obtained via :ocv:func:`ocl::BruteForceMatcher_OCL_base::radiusMatchSingle` or :ocv:func:`ocl::BruteForceMatcher_OCL_base::radiusMatchCollection` to vector with :ocv:class:`DMatch`. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatchDownload(const oclMat& trainIdx, const oclMat& distance, const oclMat& nMatches, std::vector< std::vector >&matches, bool compactResult = false) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatchDownload(const oclMat& trainIdx, const oclMat& imgIdx, const oclMat& distance, const oclMat& nMatches, std::vector< std::vector >& matches, bool compactResult = false) + +If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors. + + + + +ocl::BruteForceMatcher_OCL_base::radiusMatchConvert +--------------------------------------------------- +Converts matrices obtained via :ocv:func:`ocl::BruteForceMatcher_OCL_base::radiusMatchSingle` or :ocv:func:`ocl::BruteForceMatcher_OCL_base::radiusMatchCollection` to vector with :ocv:class:`DMatch`. + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches, std::vector< std::vector >&matches, bool compactResult = false) + +.. ocv:function:: void ocl::BruteForceMatcher_OCL_base::radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, std::vector< std::vector >& matches, bool compactResult = false) + +If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors. + +ocl::HOGDescriptor +------------------ + +.. ocv:class:: ocl::HOGDescriptor + +The class implements Histogram of Oriented Gradients ([Dalal2005]_) object detector. :: + + struct CV_EXPORTS HOGDescriptor + { + enum { DEFAULT_WIN_SIGMA = -1 }; + enum { DEFAULT_NLEVELS = 64 }; + enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL }; + + HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16), + Size block_stride=Size(8, 8), Size cell_size=Size(8, 8), + int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA, + double threshold_L2hys=0.2, bool gamma_correction=true, + int nlevels=DEFAULT_NLEVELS); + + size_t getDescriptorSize() const; + size_t getBlockHistogramSize() const; + + void setSVMDetector(const vector& detector); + + static vector getDefaultPeopleDetector(); + static vector getPeopleDetector48x96(); + static vector getPeopleDetector64x128(); + + void detect(const oclMat& img, vector& found_locations, + double hit_threshold=0, Size win_stride=Size(), + Size padding=Size()); + + void detectMultiScale(const oclMat& img, vector& found_locations, + double hit_threshold=0, Size win_stride=Size(), + Size padding=Size(), double scale0=1.05, + int group_threshold=2); + + void getDescriptors(const oclMat& img, Size win_stride, + oclMat& descriptors, + int descr_format=DESCR_FORMAT_COL_BY_COL); + + Size win_size; + Size block_size; + Size block_stride; + Size cell_size; + int nbins; + double win_sigma; + double threshold_L2hys; + bool gamma_correction; + int nlevels; + + private: + // Hidden + } + + +Interfaces of all methods are kept similar to the ``CPU HOG`` descriptor and detector analogues as much as possible. + + + +ocl::HOGDescriptor::HOGDescriptor +------------------------------------- +Creates the ``HOG`` descriptor and detector. + +.. ocv:function:: ocl::HOGDescriptor::HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16), Size block_stride=Size(8, 8), Size cell_size=Size(8, 8), int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA, double threshold_L2hys=0.2, bool gamma_correction=true, int nlevels=DEFAULT_NLEVELS) + + :param win_size: Detection window size. Align to block size and block stride. + + :param block_size: Block size in pixels. Align to cell size. Only (16,16) is supported for now. + + :param block_stride: Block stride. It must be a multiple of cell size. + + :param cell_size: Cell size. Only (8, 8) is supported for now. + + :param nbins: Number of bins. Only 9 bins per cell are supported for now. + + :param win_sigma: Gaussian smoothing window parameter. + + :param threshold_L2hys: L2-Hys normalization method shrinkage. + + :param gamma_correction: Flag to specify whether the gamma correction preprocessing is required or not. + + :param nlevels: Maximum number of detection window increases. + + + +ocl::HOGDescriptor::getDescriptorSize +----------------------------------------- +Returns the number of coefficients required for the classification. + +.. ocv:function:: size_t ocl::HOGDescriptor::getDescriptorSize() const + + + +ocl::HOGDescriptor::getBlockHistogramSize +--------------------------------------------- +Returns the block histogram size. + +.. ocv:function:: size_t ocl::HOGDescriptor::getBlockHistogramSize() const + + + +ocl::HOGDescriptor::setSVMDetector +-------------------------------------- +Sets coefficients for the linear SVM classifier. + +.. ocv:function:: void ocl::HOGDescriptor::setSVMDetector(const vector& detector) + + + +ocl::HOGDescriptor::getDefaultPeopleDetector +------------------------------------------------ +Returns coefficients of the classifier trained for people detection (for default window size). + +.. ocv:function:: static vector ocl::HOGDescriptor::getDefaultPeopleDetector() + + + +ocl::HOGDescriptor::getPeopleDetector48x96 +---------------------------------------------- +Returns coefficients of the classifier trained for people detection (for 48x96 windows). + +.. ocv:function:: static vector ocl::HOGDescriptor::getPeopleDetector48x96() + + + +ocl::HOGDescriptor::getPeopleDetector64x128 +----------------------------------------------- +Returns coefficients of the classifier trained for people detection (for 64x128 windows). + +.. ocv:function:: static vector ocl::HOGDescriptor::getPeopleDetector64x128() + + + +ocl::HOGDescriptor::detect +------------------------------ +Performs object detection without a multi-scale window. + +.. ocv:function:: void ocl::HOGDescriptor::detect(const oclMat& img, vector& found_locations, double hit_threshold=0, Size win_stride=Size(), Size padding=Size()) + + :param img: Source image. ``CV_8UC1`` and ``CV_8UC4`` types are supported for now. + + :param found_locations: Left-top corner points of detected objects boundaries. + + :param hit_threshold: Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specfied in the detector coefficients (as the last free coefficient). But if the free coefficient is omitted (which is allowed), you can specify it manually here. + + :param win_stride: Window stride. It must be a multiple of block stride. + + :param padding: Mock parameter to keep the CPU interface compatibility. It must be (0,0). + + + +ocl::HOGDescriptor::detectMultiScale +---------------------------------------- +Performs object detection with a multi-scale window. + +.. ocv:function:: void ocl::HOGDescriptor::detectMultiScale(const oclMat& img, vector& found_locations, double hit_threshold=0, Size win_stride=Size(), Size padding=Size(), double scale0=1.05, int group_threshold=2) + + :param img: Source image. See :ocv:func:`ocl::HOGDescriptor::detect` for type limitations. + + :param found_locations: Detected objects boundaries. + + :param hit_threshold: Threshold for the distance between features and SVM classifying plane. See :ocv:func:`ocl::HOGDescriptor::detect` for details. + + :param win_stride: Window stride. It must be a multiple of block stride. + + :param padding: Mock parameter to keep the CPU interface compatibility. It must be (0,0). + + :param scale0: Coefficient of the detection window increase. + + :param group_threshold: Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping. See :ocv:func:`groupRectangles` . + + + +ocl::HOGDescriptor::getDescriptors +-------------------------------------- +Returns block descriptors computed for the whole image. + +.. ocv:function:: void ocl::HOGDescriptor::getDescriptors(const oclMat& img, Size win_stride, oclMat& descriptors, int descr_format=DESCR_FORMAT_COL_BY_COL) + + :param img: Source image. See :ocv:func:`ocl::HOGDescriptor::detect` for type limitations. + + :param win_stride: Window stride. It must be a multiple of block stride. + + :param descriptors: 2D array of descriptors. + + :param descr_format: Descriptor storage format: + + * **DESCR_FORMAT_ROW_BY_ROW** - Row-major order. + + * **DESCR_FORMAT_COL_BY_COL** - Column-major order. + +The function is mainly used to learn the classifier. \ No newline at end of file diff --git a/modules/ocl/doc/image_filtering.rst b/modules/ocl/doc/image_filtering.rst new file mode 100644 index 0000000000..20e90c3d90 --- /dev/null +++ b/modules/ocl/doc/image_filtering.rst @@ -0,0 +1,283 @@ +Image Filtering +============================= + +.. highlight:: cpp + +ocl::Sobel +------------------ +Returns void + +.. ocv:function:: void Sobel(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1, double delta = 0.0, int bordertype = BORDER_DEFAULT) + + :param src: The source image + + :param dst: The destination image; It will have the same size as src + + :param ddepth: The destination image depth + + :param dx: Order of the derivative x + + :param dy: Order of the derivative y + + :param ksize: Size of the extended Sobel kernel + + :param scale: The optional scale factor for the computed derivative values(by default, no scaling is applied) + + :param delta: The optional delta value, added to the results prior to storing them in dst + + :param bordertype: Pixel extrapolation method. + +The function computes the first x- or y- spatial image derivative using Sobel operator. Surpport 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data type. + +ocl::Scharr +------------------ +Returns void + +.. ocv:function:: void Scharr(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, double scale = 1, double delta = 0.0, int bordertype = BORDER_DEFAULT) + + :param src: The source image + + :param dst: The destination image; It will have the same size as src + + :param ddepth: The destination image depth + + :param dx: Order of the derivative x + + :param dy: Order of the derivative y + + :param scale: The optional scale factor for the computed derivative values(by default, no scaling is applied) + + :param delta: The optional delta value, added to the results prior to storing them in dst + + :param bordertype: Pixel extrapolation method. + +The function computes the first x- or y- spatial image derivative using Scharr operator. Surpport 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data type. + +ocl::GaussianBlur +------------------ +Returns void + +.. ocv:function:: void GaussianBlur(const oclMat &src, oclMat &dst, Size ksize, double sigma1, double sigma2 = 0, int bordertype = BORDER_DEFAULT) + + :param src: The source image + + :param dst: The destination image; It will have the same size and the same type as src + + :param ksize: The Gaussian kernel size; ksize.width and ksize.height can differ, but they both must be positive and odd. Or, they can be zero's, then they are computed from sigma + + :param sigma1sigma2: The Gaussian kernel standard deviations in X and Y direction. If sigmaY is zero, it is set to be equal to sigmaX. If they are both zeros, they are computed from ksize.width and ksize.height. To fully control the result regardless of possible future modification of all this semantics, it is recommended to specify all of ksize, sigmaX and sigmaY + + :param bordertype: Pixel extrapolation method. + +The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported. Surpport 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data type. + +ocl::boxFilter +------------------ +Returns void + +.. ocv:function:: void boxFilter(const oclMat &src, oclMat &dst, int ddepth, Size ksize, Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT) + + :param src: The source image + + :param dst: The destination image; It will have the same size and the same type as src + + :param ddepth: The desired depth of the destination image + + :param ksize: The smoothing kernel size. It must be positive and odd + + :param anchor: The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center. + + :param bordertype: Pixel extrapolation method. + +Smoothes image using box filter.Supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4. + +ocl::Laplacian +------------------ +Returns void + +.. ocv:function:: void Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize = 1, double scale = 1) + + :param src: The source image + + :param dst: The destination image; It will have the same size and the same type as src + + :param ddepth: The desired depth of the destination image + + :param ksize: The aperture size used to compute the second-derivative filters. It must be positive and odd + + :param scale: The optional scale factor for the computed Laplacian values (by default, no scaling is applied + +The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator. + +ocl::convolve +------------------ +Returns void + +.. ocv:function:: void convolve(const oclMat &image, const oclMat &temp1, oclMat &result) + + :param image: The source image + + :param temp1: Convolution kernel, a single-channel floating point matrix. + + :param result: The destination image + +Convolves an image with the kernel. Supports only CV_32FC1 data types and do not support ROI. + +ocl::bilateralFilter +-------------------- +Returns void + +.. ocv:function:: void bilateralFilter(const oclMat &src, oclMat &dst, int d, double sigmaColor, double sigmaSpave, int borderType=BORDER_DEFAULT) + + :param src: The source image + + :param dst: The destination image; will have the same size and the same type as src + + :param d: The diameter of each pixel neighborhood, that is used during filtering. If it is non-positive, it's computed from sigmaSpace + + :param sigmaColor: Filter sigma in the color space. Larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color + + :param sigmaSpave: Filter sigma in the coordinate space. Larger value of the parameter means that farther pixels will influence each other (as long as their colors are close enough; see sigmaColor). Then d>0, it specifies the neighborhood size regardless of sigmaSpace, otherwise d is proportional to sigmaSpace. + + :param borderType: Pixel extrapolation method. + +Applies bilateral filter to the image. Supports 8UC1 8UC4 data types. + +ocl::copyMakeBorder +-------------------- +Returns void + +.. ocv:function:: void copyMakeBorder(const oclMat &src, oclMat &dst, int top, int bottom, int left, int right, int boardtype, const Scalar &value = Scalar()) + + :param src: The source image + + :param dst: The destination image; will have the same type as src and the size size(src.cols+left+right, src.rows+top+bottom) + + :param topbottomleftright: Specify how much pixels in each direction from the source image rectangle one needs to extrapolate, e.g. top=1, bottom=1, left=1, right=1mean that 1 pixel-wide border needs to be built + + :param bordertype: Pixel extrapolation method. + + :param value: The border value if borderType==BORDER CONSTANT + +Forms a border around the image. Supports 8UC1 8UC4 32SC1 32SC4 32FC1 32FC4 data types. + +ocl::dilate +------------------ +Returns void + +.. ocv:function:: void dilate( const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor = Point(-1, -1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar &borderValue = morphologyDefaultBorderValue()) + + :param src: The source image + + :param dst: The destination image; It will have the same size and the same type as src + + :param kernel: The structuring element used for dilation. If element=Mat(), a 3times 3 rectangular structuring element is used + + :param anchor: Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center, only default value is supported + + :param iterations: The number of times dilation is applied + + :param bordertype: Pixel extrapolation method. + + :param value: The border value if borderType==BORDER CONSTANT + +The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken. Supports 8UC1 8UC4 data types. + +ocl::erode +------------------ +Returns void + +.. ocv:function:: void erode( const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor = Point(-1, -1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar &borderValue = morphologyDefaultBorderValue()) + + :param src: The source image + + :param dst: The destination image; It will have the same size and the same type as src + + :param kernel: The structuring element used for dilation. If element=Mat(), a 3times 3 rectangular structuring element is used + + :param anchor: Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center, only default value is supported + + :param iterations: The number of times dilation is applied + + :param bordertype: Pixel extrapolation method. + + :param value: The border value if borderType==BORDER CONSTANT + +The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken. Supports 8UC1 8UC4 data types. + +ocl::morphologyEx +------------------ +Returns void + +.. ocv:function:: void morphologyEx( const oclMat &src, oclMat &dst, int op, const Mat &kernel, Point anchor = Point(-1, -1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar &borderValue = morphologyDefaultBorderValue()) + + :param src: The source image + + :param dst: The destination image; It will have the same size and the same type as src + + :param op: Type of morphological operation, one of the following: ERODE DILTATE OPEN CLOSE GRADIENT TOPHAT BLACKHAT + + :param kernel: The structuring element used for dilation. If element=Mat(), a 3times 3 rectangular structuring element is used + + :param anchor: Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center, only default value is supported + + :param iterations: The number of times dilation is applied + + :param bordertype: Pixel extrapolation method. + + :param value: The border value if borderType==BORDER CONSTANT + +A wrapper for erode and dilate. Supports 8UC1 8UC4 data types. + +ocl::pyrDown +------------------- +Smoothes an image and downsamples it. + +.. ocv:function:: void ocl::pyrDown(const oclMat& src, oclMat& dst) + + :param src: Source image. + + :param dst: Destination image. Will have ``Size((src.cols+1)/2, (src.rows+1)/2)`` size and the same type as ``src`` . + +.. seealso:: :ocv:func:`pyrDown` + + + +ocl::pyrUp +------------------- +Upsamples an image and then smoothes it. + +.. ocv:function:: void ocl::pyrUp(const oclMat& src, oclMat& dst) + + :param src: Source image. + + :param dst: Destination image. Will have ``Size(src.cols*2, src.rows*2)`` size and the same type as ``src`` . + +.. seealso:: :ocv:func:`pyrUp` + +ocl::columnSum +------------------ +Computes a vertical (column) sum. + +.. ocv:function:: void ocl::columnSum(const oclMat& src, oclMat& sum) + + :param src: Source image. Only ``CV_32FC1`` images are supported for now. + + :param sum: Destination image of the ``CV_32FC1`` type. + + +ocl::blendLinear +------------------- +Performs linear blending of two images. + +.. ocv:function:: void ocl::blendLinear(const oclMat& img1, const oclMat& img2, const oclMat& weights1, const oclMat& weights2, oclMat& result) + + :param img1: First image. Supports only ``CV_8U`` and ``CV_32F`` depth. + + :param img2: Second image. Must have the same size and the same type as ``img1`` . + + :param weights1: Weights for first image. Must have tha same size as ``img1`` . Supports only ``CV_32F`` type. + + :param weights2: Weights for second image. Must have tha same size as ``img2`` . Supports only ``CV_32F`` type. + + :param result: Destination image. \ No newline at end of file diff --git a/modules/ocl/doc/image_processing.rst b/modules/ocl/doc/image_processing.rst new file mode 100644 index 0000000000..461fb98a5d --- /dev/null +++ b/modules/ocl/doc/image_processing.rst @@ -0,0 +1,331 @@ +Image Processing +============================= + +.. highlight:: cpp + +ocl::cornerHarris +------------------ +Returns void + +.. ocv:function:: void cornerHarris(const oclMat &src, oclMat &dst, int blockSize, int ksize, double k, int bordertype = cv::BORDER_DEFAULT) + + :param src: Source image. Only CV_8UC1 and CV_32FC1 images are supported now. + + :param dst: Destination image containing cornerness values. It has the same size as src and CV_32FC1 type. + + :param blockSize: Neighborhood size + + :param ksize: Aperture parameter for the Sobel operator + + :param k: Harris detector free parameter + + :param bordertype: Pixel extrapolation method. Only BORDER_REFLECT101, BORDER_REFLECT, BORDER_CONSTANT and BORDER_REPLICATE are supported now. + +Calculate Harris corner. + +ocl::cornerMinEigenVal +------------------------ +Returns void + +.. ocv:function:: void cornerMinEigenVal(const oclMat &src, oclMat &dst, int blockSize, int ksize, int bordertype = cv::BORDER_DEFAULT) + + :param src: Source image. Only CV_8UC1 and CV_32FC1 images are supported now. + + :param dst: Destination image containing cornerness values. It has the same size as src and CV_32FC1 type. + + :param blockSize: Neighborhood size + + :param ksize: Aperture parameter for the Sobel operator + + :param bordertype: Pixel extrapolation method. Only BORDER_REFLECT101, BORDER_REFLECT, BORDER_CONSTANT and BORDER_REPLICATE are supported now. + +Calculate MinEigenVal. + +ocl::calcHist +------------------ +Returns void + +.. ocv:function:: void calcHist(const oclMat &mat_src, oclMat &mat_hist) + + :param src: Source arrays. They all should have the same depth, CV 8U, and the same size. Each of them can have an arbitrary number of channels. + + :param dst: The output histogram, a dense or sparse dims-dimensional + +Calculates histogram of one or more arrays. Supports only 8UC1 data type. + +ocl::remap +------------------ +Returns void + +.. ocv:function:: void remap(const oclMat &src, oclMat &dst, oclMat &map1, oclMat &map2, int interpolation, int bordertype, const Scalar &value = Scalar()) + + :param src: Source image. Only CV_8UC1 and CV_32FC1 images are supported now. + + :param dst: Destination image containing cornerness values. It has the same size as src and CV_32FC1 type. + + :param map1: The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1 , or CV_32FC2 . See covertMaps() for details on converting a floating point representation to fixed-point for speed. + + :param map2: The second map of y values having the type CV_32FC1 , or none (empty map if map1 is (x,y) points), respectively. + + :param interpolation: The interpolation method + + :param bordertype: Pixel extrapolation method. Only BORDER_CONSTANT are supported now. + + :param value: The border value if borderType==BORDER CONSTANT + +The function remap transforms the source image using the specified map: dst (x ,y) = src (map1(x , y) , map2(x , y)) where values of pixels with non-integer coordinates are computed using one of available interpolation methods. map1 and map2 can be encoded as separate floating-point maps in map1 and map2 respectively, or interleaved floating-point maps of (x,y) in map1. Supports CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1 , CV_32FC3 and CV_32FC4 data types. + +ocl::resize +------------------ +Returns void + +.. ocv:function:: void resize(const oclMat &src, oclMat &dst, Size dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR) + + :param src: Source image. + + :param dst: Destination image. + + :param dsize: he destination image size. If it is zero, then it is computed as: dsize = Size(round(fx*src.cols), round(fy*src.rows)). Either dsize or both fx or fy must be non-zero. + + :param fx: The scale factor along the horizontal axis. When 0, it is computed as (double)dsize.width/src.cols + + :param fy: The scale factor along the vertical axis. When 0, it is computed as (double)dsize.height/src.rows + + :param interpolation: The interpolation method: INTER NEAREST or INTER LINEAR + +Resizes an image. Supports CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1 , CV_32FC3 and CV_32FC4 data types. + +ocl::warpAffine +------------------ +Returns void + +.. ocv:function:: void warpAffine(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags = INTER_LINEAR) + + :param src: Source image. + + :param dst: Destination image. + + :param M: 2times 3 transformation matrix + + :param dsize: Size of the destination image + + :param flags: A combination of interpolation methods, see cv::resize, and the optional flag WARP INVERSE MAP that means that M is the inverse transformation (dst to $src) + +The function warpAffine transforms the source image using the specified matrix. Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC types. + +ocl::warpPerspective +--------------------- +Returns void + +.. ocv:function:: void warpPerspective(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags = INTER_LINEAR) + + :param src: Source image. + + :param dst: Destination image. + + :param M: 2times 3 transformation matrix + + :param dsize: Size of the destination image + + :param flags: A combination of interpolation methods, see cv::resize, and the optional flag WARP INVERSE MAP that means that M is the inverse transformation (dst to $src) + +Applies a perspective transformation to an image. Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC types. + +ocl::cvtColor +------------------ +Returns void + +.. ocv:function:: void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0) + + :param src: Source image. + + :param dst: Destination image. + + :param code:The color space conversion code + + :param dcn: The number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from src and the code + +Converts image from one color space to another.For now, only RGB2GRAY is supportted. Supports.CV_8UC1,CV_8UC4,CV_32SC1,CV_32SC4,CV_32FC1,CV_32FC4 + +ocl::threshold +------------------ +Returns Threshold value + +.. ocv:function:: double threshold(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type = THRESH_TRUNC) + + :param src: The source array + + :param dst: Destination array; will have the same size and the same type as src + + :param thresh: Threshold value + + :param maxVal: Maximum value to use with THRESH BINARY and THRESH BINARY INV thresholding types + + :param type: Thresholding type + +The function applies fixed-level thresholding to a single-channel array. The function is typically used to get a bi-level (binary) image out of a grayscale image or for removing a noise, i.e. filtering out pixels with too small or too large values. There are several types of thresholding that the function supports that are determined by thresholdType. Supports only CV_32FC1 and CV_8UC1 data type. + +ocl::buildWarpPlaneMaps +----------------------- +Builds plane warping maps. + +.. ocv:function:: void ocl::buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s, double dist, oclMat& map_x, oclMat& map_y) + + + +ocl::buildWarpCylindricalMaps +----------------------------- +Builds cylindrical warping maps. + +.. ocv:function:: void ocl::buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s, oclMat& map_x, oclMat& map_y) + + + + +ocl::buildWarpSphericalMaps +--------------------------- +Builds spherical warping maps. + +.. ocv:function:: void ocl::buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s, oclMat& map_x, oclMat& map_y) + + +ocl::buildWarpPerspectiveMaps +----------------------------- +Builds transformation maps for perspective transformation. + +.. ocv:function:: void buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, oclMat& xmap, oclMat& ymap) + + :param M: *3x3* transformation matrix. + + :param inverse: Flag specifying that ``M`` is an inverse transformation ( ``dst=>src`` ). + + :param dsize: Size of the destination image. + + :param xmap: X values with ``CV_32FC1`` type. + + :param ymap: Y values with ``CV_32FC1`` type. + +.. seealso:: :ocv:func:`ocl::warpPerspective` , :ocv:func:`ocl::remap` + + +ocl::buildWarpAffineMaps +------------------------ +Builds transformation maps for affine transformation. + +.. ocv:function:: void buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, oclMat& xmap, oclMat& ymap) + + :param M: *2x3* transformation matrix. + + :param inverse: Flag specifying that ``M`` is an inverse transformation ( ``dst=>src`` ). + + :param dsize: Size of the destination image. + + :param xmap: X values with ``CV_32FC1`` type. + + :param ymap: Y values with ``CV_32FC1`` type. + +.. seealso:: :ocv:func:`ocl::warpAffine` , :ocv:func:`ocl::remap` + +ocl::PyrLKOpticalFlow +--------------------- +.. ocv:class:: ocl::PyrLKOpticalFlow + +Class used for calculating an optical flow. :: + + class PyrLKOpticalFlow + { + public: + PyrLKOpticalFlow(); + + void sparse(const oclMat& prevImg, const oclMat& nextImg, const oclMat& prevPts, oclMat& nextPts, + oclMat& status, oclMat* err = 0); + + void dense(const oclMat& prevImg, const oclMat& nextImg, oclMat& u, oclMat& v, oclMat* err = 0); + + Size winSize; + int maxLevel; + int iters; + double derivLambda; + bool useInitialFlow; + float minEigThreshold; + bool getMinEigenVals; + + void releaseMemory(); + }; + +The class can calculate an optical flow for a sparse feature set or dense optical flow using the iterative Lucas-Kanade method with pyramids. + +.. seealso:: :ocv:func:`calcOpticalFlowPyrLK` + + + +ocl::PyrLKOpticalFlow::sparse +----------------------------- +Calculate an optical flow for a sparse feature set. + +.. ocv:function:: void ocl::PyrLKOpticalFlow::sparse(const oclMat& prevImg, const oclMat& nextImg, const oclMat& prevPts, oclMat& nextPts, oclMat& status, oclMat* err = 0) + + :param prevImg: First 8-bit input image (supports both grayscale and color images). + + :param nextImg: Second input image of the same size and the same type as ``prevImg`` . + + :param prevPts: Vector of 2D points for which the flow needs to be found. It must be one row matrix with CV_32FC2 type. + + :param nextPts: Output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image. When ``useInitialFlow`` is true, the vector must have the same size as in the input. + + :param status: Output status vector (CV_8UC1 type). Each element of the vector is set to 1 if the flow for the corresponding features has been found. Otherwise, it is set to 0. + + :param err: Output vector (CV_32FC1 type) that contains the difference between patches around the original and moved points or min eigen value if ``getMinEigenVals`` is checked. It can be NULL, if not needed. + +.. seealso:: :ocv:func:`calcOpticalFlowPyrLK` + + + +ocl::PyrLKOpticalFlow::dense +----------------------------- +Calculate dense optical flow. + +.. ocv:function:: void ocl::PyrLKOpticalFlow::dense(const oclMat& prevImg, const oclMat& nextImg, oclMat& u, oclMat& v, oclMat* err = 0) + + :param prevImg: First 8-bit grayscale input image. + + :param nextImg: Second input image of the same size and the same type as ``prevImg`` . + + :param u: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel + + :param v: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel + + :param err: Output vector (CV_32FC1 type) that contains the difference between patches around the original and moved points or min eigen value if ``getMinEigenVals`` is checked. It can be NULL, if not needed. + + + +ocl::PyrLKOpticalFlow::releaseMemory +------------------------------------ +Releases inner buffers memory. + +.. ocv:function:: void ocl::PyrLKOpticalFlow::releaseMemory() + + +ocl::interpolateFrames +---------------------- +Interpolate frames (images) using provided optical flow (displacement field). + +.. ocv:function:: void ocl::interpolateFrames(const oclMat& frame0, const oclMat& frame1, const oclMat& fu, const oclMat& fv, const oclMat& bu, const oclMat& bv, float pos, oclMat& newFrame, oclMat& buf) + + :param frame0: First frame (32-bit floating point images, single channel). + + :param frame1: Second frame. Must have the same type and size as ``frame0`` . + + :param fu: Forward horizontal displacement. + + :param fv: Forward vertical displacement. + + :param bu: Backward horizontal displacement. + + :param bv: Backward vertical displacement. + + :param pos: New frame position. + + :param newFrame: Output image. + + :param buf: Temporary buffer, will have width x 6*height size, CV_32FC1 type and contain 6 oclMat: occlusion masks for first frame, occlusion masks for second, interpolated forward horizontal flow, interpolated forward vertical flow, interpolated backward horizontal flow, interpolated backward vertical flow. diff --git a/modules/ocl/doc/introduction.rst b/modules/ocl/doc/introduction.rst index ef6d4c37e7..006b43942f 100644 --- a/modules/ocl/doc/introduction.rst +++ b/modules/ocl/doc/introduction.rst @@ -6,14 +6,39 @@ OpenCL Module Introduction General Information ------------------- -The OpenCV OCL module is a set of classes and functions to utilize OpenCL compatible device. It should support any device compatible with OpenCL 1.1. The module includes utility functions, low-level vision primitives, and a few high-level algorithms ready to be used in the end-user applications. +The OpenCV OCL module is a set of classes and functions to utilize OpenCL compatible device. In theroy, it supports any OpenCL 1.1 compatible device, but we only test it on AMD's, Intel's and NVIDIA's GPU at this stage. The compatibility, correctness and performance on CPU is not guaranteed. The OpenCV OCL module includes utility functions, low-level vision primitives, and high-level algorithms. The utility functions and low-level primitives provide a powerful infrastructure for developing fast vision algorithms taking advangtage of OCL whereas the high-level functionality includes some state-of-the-art algorithms(such as surf detector, face detector) ready to be used by the application developers. -The OpenCV OCL module is designed as a host-level API plus device-level kernels. The device-level kernels are converted to text string and are compiled at runtime, so it need OpenCL runtime support. To correctly run the OpenCV OCL module, make sure you have OpenCL runtime provided by your device vendor, which is device driver normally. +The OpenCV OCL module is designed as a host-level API plus device-level kernels. The device-level kernels are collected as strings at OpenCV compile time and are compiled at runtime, so it need OpenCL runtime support. To correctly build the OpenCV OCL module, make sure you have OpenCL SDK provided your device vendor. To correctly run the OpenCV OCL module, make sure you have OpenCL runtime provided by your device vendor, which is device driver normally. -The OpenCV OCL module is designed for ease of use and does not require any knowledge of OpenCL. Though, such a knowledge will certainly be useful to handle non-trivial cases or achieve the highest performance. It is helpful to understand the cost of various operations, what the module does, what the preferred data formats are, and so on. Since there is data transfer between OpenCL host and OpenCL device, for better performance it's recommended to copy data once to the OpenCL host memory (i.e. copy ``cv::Mat`` to ``cv::ocl::OclMat``), then call several ``cv::ocl`` functions and then copy the result back to CPU memory, rather than do forward and backward transfer for each OCL function. +The OpenCV OCL module is designed for ease of use and does not require any knowledge of OpenCL. Though, such a knowledge will certainly be useful to handle non-trivial cases or achieve the highest performance. It is helpful to understand the cost of various operations, what the OCL does, what the preferred data formats are, and so on. Since there is data transfer between OpenCL host and OpenCL device, for better performance it's recommended to copy data once to the OpenCL host memory (i.e. copy ``cv::Mat`` to ``cv::ocl::OclMat``), then call several ``cv::ocl`` functions and then copy the result back to CPU memory, rather than do forward and backward transfer for each OCL function. -To enable OCL support, configure OpenCV using CMake with the option ``WITH\_OPENCL=ON``. If the option is passed and if OpenCL SDK is installed (e.g. on MacOSX it's always the case), the full-featured OpenCV OCL module will be built. Otherwise, the module will not be built. +To enable OCL support, configure OpenCV using CMake with WIHT\_OPENCL=ON. When the flag is set and if OpenCL SDK is installed, the full-featured OpenCV OCL module is built. Otherwise, the module may be not built. If you have AMD'S FFT and BLAS library, you can select it with WITH\_OPENCLAMDFFT=ON, WIHT\_OPENCLAMDBLAS=ON. -Right now, the user should define the ``cv::ocl::Info`` class in the application and call ``cv::ocl::getDevice`` before any ``cv::ocl::``. This operation initialize OpenCL runtime and set the first found device as computing device. If there is more than one device and you want to use non-default device, you should call ``cv::ocl::setDevice``. +Right now, the user should define the cv::ocl::Info class in the application and call cv::ocl::getDevice before any cv::ocl::func. This operation initialize OpenCL runtime and set the first found device as computing device. If there are more than one device and you want to use undefault device, you can call cv::ocl::setDevice then. -In the current version, all the threads share the same context and device so the multi-devices are not supported. This is to be fixed in future releases. +In the current version, all the thread share the same context and device so the multi-devices are not supported. We will add this feature soon. If a function support 4-channel operator, it should support 3-channel operator as well, because All the 3-channel matrix(i.e. RGB image) are represented by 4-channel matrix in oclMat. It means 3-channel image have 4-channel space with the last channel unused. We provide a transparent interface to handle the difference between OpenCV Mat and oclMat. + +Developer Notes +------------------- + +This section descripe the design details of ocl module for who are interested in the detail of this module or want to contribute this module. User who isn't interested the details, can safely ignore it. + +1. OpenCL version should be larger than 1.1 with FULL PROFILE. + +2. There's only one OpenCL context and commandqueue and generated as a singleton. So now it only support one device with single commandqueue. + +3. All the functions use 256 as its workgroup size if possible, so the max work group size of the device must larger than 256. + +4. If the device support double, we will use double in kernel if OpenCV cpu version use double, otherwise, we use float instead. + +5. The oclMat use buffer object, not image object. + +6. All the 3-channel matrix(i.e. RGB image) are represented by 4-channel matrix in oclMat. It means 3-channel image have 4-channel space with the last channel unused. We provide a transparent interface to handle the difference between OpenCV Mat and oclMat. + +7. All the matrix in oclMat is aligned in column(now the alignment factor is 32 byte). It means, if a matrix is n columns m rows with the element size x byte, we will assign ALIGNMENT(x*n) bytes for each column with the last ALIGNMENT(x*n) - x*n bytes unused, so there's small holes after each column if its size is not the multiply of ALIGN. + +8. Data transfer between Mat and oclMat. If the CPU matrix is aligned in column, we will use faster API to transfer between Mat and oclMat, otherwise, we will use clEnqueueRead/WriteBufferRect to transfer data to guarantee the alignment. 3-channel matrix is an exception, it's directly transferred to a temp buffer and then padded to 4-channel matrix(also aligned) when uploading and do the reverse operation when downloading. + +9. Data transfer between Mat and oclMat. ROI is a feature of OpenCV, which allow users process a sub rectangle of a matrix. When a CPU matrix which has ROI will be transfered to GPU, the whole matrix will be transfered and set ROI as CPU's. In a word, we always transfer the whole matrix despite whether it has ROI or not. + +10. All the kernel file should locate in ocl/src/kernels/ with the extension ".cl". ALL the kernel files are transformed to pure characters at compilation time in kernels.cpp, and the file name without extension is the name of the characters. diff --git a/modules/ocl/doc/matrix_reductions.rst b/modules/ocl/doc/matrix_reductions.rst new file mode 100644 index 0000000000..6eb889a038 --- /dev/null +++ b/modules/ocl/doc/matrix_reductions.rst @@ -0,0 +1,70 @@ +Matrix Reductions +============================= + +.. highlight:: cpp + +ocl::countNonZero +------------------ +Returns the number of non-zero elements in src + +.. ocv:function:: int countNonZero(const oclMat &src) + + :param src: Single-channel array + +Counts non-zero array elements. + +ocl::minMax +------------------ +Returns void + +.. ocv:function:: void minMax(const oclMat &src, double *minVal, double *maxVal = 0, const oclMat &mask = oclMat()) + + :param src: Single-channel array + + :param minVal: Pointer to returned minimum value, should not be NULL + + :param maxVal: Pointer to returned maximum value, should not be NULL + + :param mask: The optional mask used to select a sub-array + +Finds global minimum and maximum in a whole array or sub-array. Supports all data types. + +ocl::minMaxLoc +------------------ +Returns void + +.. ocv:function:: void minMaxLoc(const oclMat &src, double *minVal, double *maxVal = 0, Point *minLoc = 0, Point *maxLoc = 0,const oclMat &mask = oclMat()) + + :param src: Single-channel array + + :param minVal: Pointer to returned minimum value, should not be NULL + + :param maxVal: Pointer to returned maximum value, should not be NULL + + :param minLoc: Pointer to returned minimum location (in 2D case), should not be NULL + + :param maxLoc: Pointer to returned maximum location (in 2D case) should not be NULL + + :param mask: The optional mask used to select a sub-array + +The functions minMaxLoc find minimum and maximum element values and their positions. The extremums are searched across the whole array, or, if mask is not an empty array, in the specified array region. The functions do not work with multi-channel arrays. + +ocl::Sum +------------------ +Returns the sum of matrix elements for each channel + +.. ocv:function:: Scalar sum(const oclMat &m) + + :param m: The Source image of all depth + +Counts the sum of matrix elements for each channel. + +ocl::sqrSum +------------------ +Returns the squared sum of matrix elements for each channel + +.. ocv:function:: Scalar sqrSum(const oclMat &m) + + :param m: The Source image of all depth + +Counts the squared sum of matrix elements for each channel. \ No newline at end of file diff --git a/modules/ocl/doc/object_detection.rst b/modules/ocl/doc/object_detection.rst new file mode 100644 index 0000000000..cbbcd78d1a --- /dev/null +++ b/modules/ocl/doc/object_detection.rst @@ -0,0 +1,188 @@ +Object Detection +============================= + +.. highlight:: cpp + +ocl::oclCascadeClassifier +------------------------- + +Cascade classifier class used for object detection. Supports HAAR cascade classifier in the form of cross link :: + + class CV_EXPORTS OclCascadeClassifier : public cv::CascadeClassifier + { + public: + OclCascadeClassifier() {}; + ~OclCascadeClassifier() {}; + CvSeq *oclHaarDetectObjects(oclMat &gimg, CvMemStorage *storage, + double scaleFactor,int minNeighbors, + int flags, CvSize minSize = cvSize(0, 0), + CvSize maxSize = cvSize(0, 0)); + }; + +ocl::oclCascadeClassifier::oclHaarDetectObjects +------------------------------------------------------ +Returns the detected objects by a list of rectangles + +.. ocv:function:: CvSeq *OclCascadeClassifier::oclHaarDetectObjects(oclMat &gimg, CvMemStorage *storage, double scaleFactor,int minNeighbors, int flags, CvSize minSize = cvSize(0, 0), CvSize maxSize = cvSize(0, 0)) + + :param image: Matrix of type CV_8U containing an image where objects should be detected. + + :param imageobjectsBuff: Buffer to store detected objects (rectangles). If it is empty, it is allocated with the defaultsize. If not empty, the function searches not more than N objects, where N = sizeof(objectsBufers data)/sizeof(cv::Rect). + + :param scaleFactor: Parameter specifying how much the image size is reduced at each image scale. + + :param minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it. + + :param minSize: Minimum possible object size. Objects smaller than that are ignored. + +Detects objects of different sizes in the input image,only tested for face detection now. The function returns the number of detected objects. + +ocl::MatchTemplateBuf +--------------------- +.. ocv:class:: ocl::MatchTemplateBuf + +Class providing memory buffers for :ocv:func:`ocl::matchTemplate` function, plus it allows to adjust some specific parameters. :: + + struct CV_EXPORTS MatchTemplateBuf + { + Size user_block_size; + oclMat imagef, templf; + std::vector images; + std::vector image_sums; + std::vector image_sqsums; + }; + +You can use field `user_block_size` to set specific block size for :ocv:func:`ocl::matchTemplate` function. If you leave its default value `Size(0,0)` then automatic estimation of block size will be used (which is optimized for speed). By varying `user_block_size` you can reduce memory requirements at the cost of speed. + +ocl::matchTemplate +---------------------- +Computes a proximity map for a raster template and an image where the template is searched for. + +.. ocv:function:: void ocl::matchTemplate(const oclMat& image, const oclMat& templ, oclMat& result, int method) + +.. ocv:function:: void ocl::matchTemplate(const oclMat& image, const oclMat& templ, oclMat& result, int method, MatchTemplateBuf &buf) + + :param image: Source image. ``CV_32F`` and ``CV_8U`` depth images (1..4 channels) are supported for now. + + :param templ: Template image with the size and type the same as ``image`` . + + :param result: Map containing comparison results ( ``CV_32FC1`` ). If ``image`` is *W x H* and ``templ`` is *w x h*, then ``result`` must be *W-w+1 x H-h+1*. + + :param method: Specifies the way to compare the template with the image. + + :param buf: Optional buffer to avoid extra memory allocations and to adjust some specific parameters. See :ocv:class:`ocl::MatchTemplateBuf`. + + The following methods are supported for the ``CV_8U`` depth images for now: + + * ``CV_TM_SQDIFF`` + * ``CV_TM_SQDIFF_NORMED`` + * ``CV_TM_CCORR`` + * ``CV_TM_CCORR_NORMED`` + * ``CV_TM_CCOEFF`` + * ``CV_TM_CCOEFF_NORMED`` + + The following methods are supported for the ``CV_32F`` images for now: + + * ``CV_TM_SQDIFF`` + * ``CV_TM_CCORR`` + +.. seealso:: :ocv:func:`matchTemplate` + + +ocl::SURF_OCL +------------- +.. ocv:class:: ocl::SURF_OCL + +Class used for extracting Speeded Up Robust Features (SURF) from an image. :: + + class SURF_OCL + { + public: + enum KeypointLayout + { + X_ROW = 0, + Y_ROW, + LAPLACIAN_ROW, + OCTAVE_ROW, + SIZE_ROW, + ANGLE_ROW, + HESSIAN_ROW, + ROWS_COUNT + }; + + //! the default constructor + SURF_OCL(); + //! the full constructor taking all the necessary parameters + explicit SURF_OCL(double _hessianThreshold, int _nOctaves=4, + int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f, bool _upright = false); + + //! returns the descriptor size in float's (64 or 128) + int descriptorSize() const; + + //! upload host keypoints to device memory + void uploadKeypoints(const vector& keypoints, + oclMat& keypointsocl); + //! download keypoints from device to host memory + void downloadKeypoints(const oclMat& keypointsocl, + vector& keypoints); + + //! download descriptors from device to host memory + void downloadDescriptors(const oclMat& descriptorsocl, + vector& descriptors); + + void operator()(const oclMat& img, const oclMat& mask, + oclMat& keypoints); + + void operator()(const oclMat& img, const oclMat& mask, + oclMat& keypoints, oclMat& descriptors, + bool useProvidedKeypoints = false); + + void operator()(const oclMat& img, const oclMat& mask, + std::vector& keypoints); + + void operator()(const oclMat& img, const oclMat& mask, + std::vector& keypoints, oclMat& descriptors, + bool useProvidedKeypoints = false); + + void operator()(const oclMat& img, const oclMat& mask, + std::vector& keypoints, + std::vector& descriptors, + bool useProvidedKeypoints = false); + + void releaseMemory(); + + // SURF parameters + double hessianThreshold; + int nOctaves; + int nOctaveLayers; + bool extended; + bool upright; + + //! max keypoints = min(keypointsRatio * img.size().area(), 65535) + float keypointsRatio; + + oclMat sum, mask1, maskSum, intBuffer; + + oclMat det, trace; + + oclMat maxPosBuffer; + }; + + +The class ``SURF_OCL`` implements Speeded Up Robust Features descriptor. There is a fast multi-scale Hessian keypoint detector that can be used to find the keypoints (which is the default option). But the descriptors can also be computed for the user-specified keypoints. Only 8-bit grayscale images are supported. + +The class ``SURF_OCL`` can store results in the GPU and CPU memory. It provides functions to convert results between CPU and GPU version ( ``uploadKeypoints``, ``downloadKeypoints``, ``downloadDescriptors`` ). The format of CPU results is the same as ``SURF`` results. GPU results are stored in ``oclMat``. The ``keypoints`` matrix is :math:`\texttt{nFeatures} \times 7` matrix with the ``CV_32FC1`` type. + +* ``keypoints.ptr(X_ROW)[i]`` contains x coordinate of the i-th feature. +* ``keypoints.ptr(Y_ROW)[i]`` contains y coordinate of the i-th feature. +* ``keypoints.ptr(LAPLACIAN_ROW)[i]`` contains the laplacian sign of the i-th feature. +* ``keypoints.ptr(OCTAVE_ROW)[i]`` contains the octave of the i-th feature. +* ``keypoints.ptr(SIZE_ROW)[i]`` contains the size of the i-th feature. +* ``keypoints.ptr(ANGLE_ROW)[i]`` contain orientation of the i-th feature. +* ``keypoints.ptr(HESSIAN_ROW)[i]`` contains the response of the i-th feature. + +The ``descriptors`` matrix is :math:`\texttt{nFeatures} \times \texttt{descriptorSize}` matrix with the ``CV_32FC1`` type. + +The class ``SURF_OCL`` uses some buffers and provides access to it. All buffers can be safely released between function calls. + +.. seealso:: :ocv:class:`SURF` \ No newline at end of file diff --git a/modules/ocl/doc/ocl.rst b/modules/ocl/doc/ocl.rst index 3f3d8bccf2..d6d79e187a 100644 --- a/modules/ocl/doc/ocl.rst +++ b/modules/ocl/doc/ocl.rst @@ -6,15 +6,13 @@ ocl. OpenCL-accelerated Computer Vision :maxdepth: 1 introduction - structures_and_functions -.. initalization_and_information -.. data_structures -.. operations_on_matrices -.. per_element_operations -.. image_processing -.. matrix_reductions -.. object_detection -.. feature_detection_and_description -.. image_filtering + structures_and_utility_functions + data_structures + operations_on_matrices + matrix_reductions + image_filtering + image_processing + object_detection + feature_detection_and_description .. camera_calibration_and_3d_reconstruction .. video diff --git a/modules/ocl/doc/operations_on_matrices.rst b/modules/ocl/doc/operations_on_matrices.rst new file mode 100644 index 0000000000..27696ca136 --- /dev/null +++ b/modules/ocl/doc/operations_on_matrices.rst @@ -0,0 +1,474 @@ +Operations on Matrics +============================= + +.. highlight:: cpp + +ocl::convertTo +------------------ +Returns void + +.. ocv:function:: void convertTo( oclMat &m, int rtype, double alpha = 1, double beta = 0 ) const + + :param m: The destination matrix. If it does not have a proper size or type before the operation, it will be reallocated + + :param rtype: The desired destination matrix type, or rather, the depth(since the number of channels will be the same with the source one). If rtype is negative, the destination matrix will have the same type as the source. + + :param alpha: must be default now + + :param beta: must be default now + +The method converts source pixel values to the target datatype. saturate cast is applied in the end to avoid possible overflows. Supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32SC4, CV_32FC1, CV_32FC4. + +ocl::copyTo +------------------ +Returns void + +.. ocv:function:: void copyTo( oclMat &m, const oclMat &mask ) const + + :param m: The destination matrix. If it does not have a proper size or type before the operation, it will be reallocated + + :param mask(optional): The operation mask. Its non-zero elements indicate, which matrix elements need to be copied + +Copies the matrix to another one. Supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32SC4, CV_32FC1, CV_32FC4 + +ocl::setTo +------------------ +Returns oclMat + +.. ocv:function:: oclMat &setTo(const Scalar &s, const oclMat &mask = oclMat()) + + :param s: Assigned scalar, which is converted to the actual array type + + :param mask: The operation mask of the same size as ``*this`` + +Sets all or some of the array elements to the specified value. This is the advanced variant of Mat::operator=(const Scalar s) operator. Supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32SC4, CV_32FC1, CV_32FC4. + +ocl::absdiff +------------------ +Returns void + +.. ocv:function:: void absdiff(const oclMat &a, const oclMat &b, oclMat &c) + +.. ocv:function:: void absdiff(const oclMat &a, const Scalar& sc, oclMat &c) + + :param a: The first input array + + :param b: The second input array, must be the same size and same type as a + + :param sc: Scalar, the second input parameter + + :param c: The destination array, it will have the same size and same type as a + +Computes per-element absolute difference between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::add +------------------ +Returns void + +.. ocv:function:: void add(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat& mask=oclMat()) + +.. ocv:function:: void add(const oclMat &src1, const Scalar &sc, oclMat &dst, const oclMat& mask=oclMat()) + + :param src1: The first input array + + :param src2: The second input array, must be the same size and same type as src1 + + :param sc: Scalar, the second input parameter + + :param dst: The destination array, it will have the same size and same type as src1 + + :param mask: he optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed + +Computes per-element additon between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::subtract +------------------ +Returns void + +.. ocv:function:: void subtract(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat& mask=oclMat()) + +.. ocv:function:: void subtract(const oclMat &src1, const Scalar &sc, oclMat &dst, const oclMat& mask=oclMat()) + + :param src1: The first input array + + :param src2: The second input array, must be the same size and same type as src1 + + :param sc: Scalar, the second input parameter + + :param dst: The destination array, it will have the same size and same type as src1 + + :param mask: he optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed + +Computes per-element subtract between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::multiply +------------------ +Returns void + +.. ocv:function:: void multiply(const oclMat &src1, const oclMat &src2, oclMat &dst, double scale = 1) + + :param src1: The first input array + + :param src2: The second input array, must be the same size and same type as src1 + + :param dst: The destination array, it will have the same size and same type as src1 + + :param scale: must be 1 now + +Computes per-element multiply between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::divide +------------------ +Returns void + +.. ocv:function:: void divide(const oclMat &src1, const oclMat &src2, oclMat &dst, double scale = 1) + + :param src1: The first input array + + :param src2: The second input array, must be the same size and same type as src1 + + :param dst: The destination array, it will have the same size and same type as src1 + + :param scale: must be 1 now + +Computes per-element divide between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::bitwise_and +------------------ +Returns void + +.. ocv:function:: void bitwise_and(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat& mask=oclMat()) + +.. ocv:function:: void bitwise_and(const oclMat &src1, const Scalar &sc, oclMat &dst, const oclMat& mask=oclMat()) + + :param src1: The first input array + + :param src2: The second input array, must be the same size and same type as src1 + + :param sc: Scalar, the second input parameter + + :param dst: The destination array, it will have the same size and same type as src1 + + :param mask: The optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed + +Computes per-element bitwise_and between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::bitwise_or +------------------ +Returns void + +.. ocv:function:: void bitwise_or(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat& mask=oclMat()) + +.. ocv:function:: void bitwise_or(const oclMat &src1, const Scalar &sc, oclMat &dst, const oclMat& mask=oclMat()) + + :param src1: The first input array + + :param src2: The second input array, must be the same size and same type as src1 + + :param sc: Scalar, the second input parameter + + :param dst: The destination array, it will have the same size and same type as src1 + + :param mask: The optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed + +Computes per-element bitwise_or between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::bitwise_xor +------------------ +Returns void + +.. ocv:function:: void bitwise_xor(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat& mask=oclMat()) + +.. ocv:function:: void bitwise_xor(const oclMat &src1, const Scalar &sc, oclMat &dst, const oclMat& mask=oclMat()) + + :param src1: The first input array + + :param src2: The second input array, must be the same size and same type as src1 + + :param sc: Scalar, the second input parameter + + :param dst: The destination array, it will have the same size and same type as src1 + + :param mask: The optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed + +Computes per-element bitwise_xor between two arrays or between array and a scalar. Supports all data types except CV_8S. + +ocl::bitwise_not +------------------ +Returns void + +.. ocv:function:: void bitwise_not(const oclMat &src, oclMat &dst) + + :param src: The input array + + :param dst: The destination array, it will have the same size and same type as src1 + +The functions bitwise not compute per-element bit-wise inversion of the source array:. Supports all data types except CV_8S. + +ocl::cartToPolar +------------------ +Returns void + +.. ocv:function:: void cartToPolar(const oclMat &x, const oclMat &y, oclMat &magnitude, oclMat &angle, bool angleInDegrees = false) + + :param x: The array of x-coordinates; must be single-precision or double-precision floating-point array + + :param y: The array of y-coordinates; it must have the same size and same type as x + + :param magnitude: The destination array of magnitudes of the same size and same type as x + + :param angle: The destination array of angles of the same size and same type as x. The angles are measured in radians (0 to 2pi ) or in degrees (0 to 360 degrees). + + :param angleInDegrees: The flag indicating whether the angles are measured in radians, which is default mode, or in degrees + +Calculates the magnitude and angle of 2d vectors. Supports only CV_32F and CV_64F data types. + +ocl::polarToCart +------------------ +Returns void + +.. ocv:function:: void polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat &x, oclMat &y, bool angleInDegrees = false) + + :param magnitude: The source floating-point array of magnitudes of 2D vectors. It can be an empty matrix (=Mat()) - in this case the function assumes that all the magnitudes are =1. If it's not empty, it must have the same size and same type as angle + + :param angle: The source floating-point array of angles of the 2D vectors + + :param x: The destination array of x-coordinates of 2D vectors; will have the same size and the same type as angle + + :param y: The destination array of y-coordinates of 2D vectors; will have the same size and the same type as angle + + :param angleInDegrees: The flag indicating whether the angles are measured in radians, which is default mode, or in degrees + +The function polarToCart computes the cartesian coordinates of each 2D vector represented by the corresponding elements of magnitude and angle. Supports only CV_32F and CV_64F data types. + +ocl::compare +------------------ +Returns void + +.. ocv:function:: void compare(const oclMat &a, const oclMat &b, oclMat &c, int cmpop) + + :param a: The first source array + + :param b: The second source array; must have the same size and same type as a + + :param c: The destination array; will have the same size as a + + :param cmpop: The flag specifying the relation between the elements to be checked + +Performs per-element comparison of two arrays or an array and scalar value. Supports all the 1 channel data types except CV_8S. + +ocl::exp +------------------ +Returns void + +.. ocv:function:: void exp(const oclMat &a, oclMat &b) + + :param a: The first source array + + :param b: The dst array; must have the same size and same type as a + +The function exp calculates the exponent of every element of the input array. Supports only CV_32FC1 data type. + +ocl::log +------------------ +Returns void + +.. ocv:function:: void log(const oclMat &a, oclMat &b) + + :param a: The first source array + + :param b: The dst array; must have the same size and same type as a + +The function log calculates the log of every element of the input array. Supports only CV_32FC1 data type. + +ocl::LUT +------------------ +Returns void + +.. ocv:function:: void LUT(const oclMat &src, const oclMat &lut, oclMat &dst) + + :param src: Source array of 8-bit elements + + :param lut: Look-up table of 256 elements. In the case of multi-channel source array, the table should either have a single channel (in this case the same table is used for all channels) or the same number of channels as in the source array + + :param dst: Destination array; will have the same size and the same number of channels as src, and the same depth as lut + +Performs a look-up table transform of an array. Supports only CV_8UC1 and CV_8UC4 data type. + +ocl::magnitude +------------------ +Returns void + +.. ocv:function:: void magnitude(const oclMat &x, const oclMat &y, oclMat &magnitude) + + :param x: The floating-point array of x-coordinates of the vectors + + :param y: he floating-point array of y-coordinates of the vectors; must have the same size as x + + :param magnitude: The destination array; will have the same size and same type as x + +The function magnitude calculates magnitude of 2D vectors formed from the corresponding elements of x and y arrays. Supports only CV_32F and CV_64F data type. + +ocl::flip +------------------ +Returns void + +.. ocv:function:: void flip(const oclMat &src, oclMat &dst, int flipCode) + + :param src: Source image. + + :param dst: Destination image + + :param flipCode: Specifies how to flip the array: 0 means flipping around the x-axis, positive (e.g., 1) means flipping around y-axis, and negative (e.g., -1) means flipping around both axes. + +The function flip flips the array in one of three different ways (row and column indices are 0-based). Supports all data types. + +ocl::meanStdDev +------------------ +Returns void + +.. ocv:function:: void meanStdDev(const oclMat &mtx, Scalar &mean, Scalar &stddev) + + :param mtx: Source image. + + :param mean: The output parameter: computed mean value + + :param stddev: The output parameter: computed standard deviation + +The functions meanStdDev compute the mean and the standard deviation M of array elements, independently for each channel, and return it via the output parameters. Supports all data types except CV_32F,CV_64F + +ocl::merge +------------------ +Returns void + +.. ocv:function:: void merge(const vector &src, oclMat &dst) + + :param src: The source array or vector of the single-channel matrices to be merged. All the matrices in src must have the same size and the same type + + :param dst: The destination array; will have the same size and the same depth as src, the number of channels will match the number of source matrices + +Composes a multi-channel array from several single-channel arrays. Supports all data types. + +ocl::split +------------------ +Returns void + +.. ocv:function:: void split(const oclMat &src, vector &dst) + + :param src: The source multi-channel array + + :param dst: The destination array or vector of arrays; The number of arrays must match src.channels(). The arrays themselves will be reallocated if needed + +The functions split split multi-channel array into separate single-channel arrays. Supports all data types. + +ocl::norm +------------------ +Returns the calculated norm + +.. ocv:function:: double norm(const oclMat &src1, int normType = NORM_L2) + +.. ocv:function:: double norm(const oclMat &src1, const oclMat &src2, int normType = NORM_L2) + + :param src1: The first source array + + :param src2: The second source array of the same size and the same type as src1 + + :param normType: Type of the norm + +Calculates absolute array norm, absolute difference norm, or relative difference norm. Supports only CV_8UC1 data type. + +ocl::phase +------------------ +Returns void + +.. ocv:function:: void phase(const oclMat &x, const oclMat &y, oclMat &angle, bool angleInDegrees = false) + + :param x: The source floating-point array of x-coordinates of 2D vectors + + :param y: The source array of y-coordinates of 2D vectors; must have the same size and the same type as x + + :param angle: The destination array of vector angles; it will have the same size and same type as x + + :param angleInDegrees: When it is true, the function will compute angle in degrees, otherwise they will be measured in radians + +The function phase computes the rotation angle of each 2D vector that is formed from the corresponding elements of x and y. Supports only CV_32FC1 and CV_64FC1 data type. + +ocl::pow +------------------ +Returns void + +.. ocv:function:: void pow(const oclMat &x, double p, oclMat &y) + + :param x: The source array + + :param power: The exponent of power;The source floating-point array of angles of the 2D vectors + + :param y: The destination array, should be the same type as the source + +The function pow raises every element of the input array to p. Supports only CV_32FC1 and CV_64FC1 data type. + +ocl::transpose +------------------ +Returns void + +.. ocv:function:: void transpose(const oclMat &src, oclMat &dst) + + :param src: The source array + + :param dst: The destination array of the same type as src + +Transposes a matrix. Supports 8UC1, 8UC4, 8SC4, 16UC2, 16SC2, 32SC1 and 32FC1 data types. + + +ocl::dft +------------ +Performs a forward or inverse discrete Fourier transform (1D or 2D) of the floating point matrix. + +.. ocv:function:: void ocl::dft(const oclMat& src, oclMat& dst, Size dft_size, int flags=0) + + :param src: Source matrix (real or complex). + + :param dst: Destination matrix (real or complex). + + :param dft_size: Size of original input, which is used for transformation from complex to real. + + :param flags: Optional flags: + + * **DFT_ROWS** transforms each individual row of the source matrix. + + * **DFT_COMPLEX_OUTPUT** performs a forward transformation of 1D or 2D real array. The result, though being a complex array, has complex-conjugate symmetry (*CCS*, see the function description below for details). Such an array can be packed into a real array of the same size as input, which is the fastest option and which is what the function does by default. However, you may wish to get a full complex array (for simpler spectrum analysis, and so on). Pass the flag to enable the function to produce a full-size complex output array. + + * **DFT_INVERSE** inverts DFT. Use for complex-complex cases (real-complex and complex-real cases are always forward and inverse, respectively). + + * **DFT_REAL_OUTPUT** specifies the output as real. The source matrix is the result of real-complex transform, so the destination matrix must be real. + +Use to handle real matrices ( ``CV32FC1`` ) and complex matrices in the interleaved format ( ``CV32FC2`` ). + +The dft_size must be powers of 2, 3 and 5. Real to complex dft output is not the same with cpu version. real to complex and complex to real does not support DFT_ROWS + +.. seealso:: :ocv:func:`dft` + +ocl::gemm +------------------ +Performs generalized matrix multiplication. + +.. ocv:function:: void gemm(const oclMat& src1, const oclMat& src2, double alpha, const oclMat& src3, double beta, oclMat& dst, int flags = 0) + + :param src1: First multiplied input matrix that should be ``CV_32FC1`` type. + + :param src2: Second multiplied input matrix of the same type as ``src1`` . + + :param alpha: Weight of the matrix product. + + :param src3: Third optional delta matrix added to the matrix product. It should have the same type as ``src1`` and ``src2`` . + + :param beta: Weight of ``src3`` . + + :param dst: Destination matrix. It has the proper size and the same type as input matrices. + + :param flags: Operation flags: + + * **GEMM_1_T** transpose ``src1`` + * **GEMM_2_T** transpose ``src2`` + +.. seealso:: :ocv:func:`gemm` \ No newline at end of file diff --git a/modules/ocl/doc/structures_and_functions.rst b/modules/ocl/doc/structures_and_functions.rst deleted file mode 100644 index 7ac30b6430..0000000000 --- a/modules/ocl/doc/structures_and_functions.rst +++ /dev/null @@ -1,23 +0,0 @@ -Data Structures and Functions -============================= - -.. highlight:: cpp - -ocl::Info ---------- -.. ocv:class:: ocl::Info - -this class should be maintained by the user and be passed to getDevice - -ocl::getDevice ------------------- -Returns the list of devices - -.. ocv:function:: int ocl::getDevice( std::vector & oclinfo, int devicetype=CVCL_DEVICE_TYPE_GPU ) - - :param oclinfo: Output vector of ``ocl::Info`` structures - - :param devicetype: One of ``CVCL_DEVICE_TYPE_GPU``, ``CVCL_DEVICE_TYPE_CPU`` or ``CVCL_DEVICE_TYPE_DEFAULT``. - -the function must be called before any other ``cv::ocl`` functions; it initializes ocl runtime. - diff --git a/modules/ocl/doc/structures_and_utility_functions.rst b/modules/ocl/doc/structures_and_utility_functions.rst new file mode 100644 index 0000000000..df19a3c1d9 --- /dev/null +++ b/modules/ocl/doc/structures_and_utility_functions.rst @@ -0,0 +1,58 @@ +Data Structures and Utility Functions +======================================== + +.. highlight:: cpp + +ocl::Info +--------- +.. ocv:class:: ocl::Info + +this class should be maintained by the user and be passed to getDevice + +ocl::getDevice +------------------ +Returns the list of devices + +.. ocv:function:: int ocl::getDevice( std::vector & oclinfo, int devicetype=CVCL_DEVICE_TYPE_GPU ) + + :param oclinfo: Output vector of ``ocl::Info`` structures + + :param devicetype: One of ``CVCL_DEVICE_TYPE_GPU``, ``CVCL_DEVICE_TYPE_CPU`` or ``CVCL_DEVICE_TYPE_DEFAULT``. + +the function must be called before any other ``cv::ocl`` functions; it initializes ocl runtime. + +ocl::setDevice +------------------ +Returns void + +.. ocv:function:: void ocl::setDevice( Info &oclinfo, int devnum = 0 ) + + :param oclinfo: Output vector of ``ocl::Info`` structures + + :param devnum: the selected OpenCL device under this platform. + +ocl::setBinpath +------------------ +Returns void + +.. ocv:function:: void setBinpath(const char *path) + + :param path: the path of OpenCL kernel binaries + +If you call this function and set a valid path, the OCL module will save the compiled kernel to the address in the first time and reload the binary since that. It can save compilation time at the runtime. + +ocl::getoclContext +------------------ +Returns the pointer to the opencl context + +.. ocv:function:: void *getoclContext() + +Thefunction are used to get opencl context so that opencv can interactive with other opencl program. + +ocl::getoclCommandQueue +-------------------------- +Returns the pointer to the opencl command queue + +.. ocv:function:: void *getoclCommandQueue() + +Thefunction are used to get opencl command queue so that opencv can interactive with other opencl program. \ No newline at end of file diff --git a/modules/ocl/src/brute_force_matcher.cpp b/modules/ocl/src/brute_force_matcher.cpp index d2122bb6b1..20c9ebf57c 100644 --- a/modules/ocl/src/brute_force_matcher.cpp +++ b/modules/ocl/src/brute_force_matcher.cpp @@ -300,7 +300,7 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.cols )); + args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.cols )); args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.step )); args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); @@ -338,7 +338,7 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c args.push_back( make_pair( sizeof(cl_int), (void *)&query.cols )); args.push_back( make_pair( sizeof(cl_int), (void *)&train.rows )); args.push_back( make_pair( sizeof(cl_int), (void *)&train.cols )); - args.push_back( make_pair( sizeof(cl_mem), (void *)&trainIdx.cols )); + args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.cols )); args.push_back( make_pair( sizeof(cl_int), (void *)&query.step )); args.push_back( make_pair( sizeof(cl_int), (void *)&trainIdx.step )); args.push_back( make_pair( sizeof(cl_int), (void *)&distType )); diff --git a/modules/ocl/src/initialization.cpp b/modules/ocl/src/initialization.cpp index ebc202858a..a8814c72d2 100644 --- a/modules/ocl/src/initialization.cpp +++ b/modules/ocl/src/initialization.cpp @@ -338,7 +338,8 @@ namespace cv EXT_LEN, (void *)extends_set, &extends_size)); CV_Assert(extends_size < EXT_LEN); extends_set[EXT_LEN - 1] = 0; - //oclinfo.extra_options = NULL; + memset(oclinfo.impl->extra_options, 0, 512); + oclinfo.impl->double_support = 0; int fp64_khr = string(extends_set).find("cl_khr_fp64"); if(fp64_khr >= 0 && fp64_khr < EXT_LEN) diff --git a/modules/photo/perf/perf_precomp.hpp b/modules/photo/perf/perf_precomp.hpp index 49ab24809b..3c40b2921f 100644 --- a/modules/photo/perf/perf_precomp.hpp +++ b/modules/photo/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/photo/test/test_precomp.hpp b/modules/photo/test/test_precomp.hpp index 4496ac889d..877f215323 100644 --- a/modules/photo/test/test_precomp.hpp +++ b/modules/photo/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/stitching/perf/perf_precomp.hpp b/modules/stitching/perf/perf_precomp.hpp index dddeb07caa..f6cdae81e1 100644 --- a/modules/stitching/perf/perf_precomp.hpp +++ b/modules/stitching/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_PERF_PRECOMP_HPP__ diff --git a/modules/stitching/test/test_precomp.hpp b/modules/stitching/test/test_precomp.hpp index 62dba4037c..e703850bf0 100644 --- a/modules/stitching/test/test_precomp.hpp +++ b/modules/stitching/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 3b75ee9ee6..0af6718085 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -478,7 +478,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os); #define CV_PERF_TEST_MAIN(testsuitname, ...) \ int main(int argc, char **argv)\ {\ - __VA_ARGS__;\ + while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/\ ::perf::Regression::Init(#testsuitname);\ ::perf::TestBase::Init(argc, argv);\ ::testing::InitGoogleTest(&argc, argv);\ diff --git a/modules/video/perf/perf_precomp.hpp b/modules/video/perf/perf_precomp.hpp index 18f4144695..bbee05eb74 100644 --- a/modules/video/perf/perf_precomp.hpp +++ b/modules/video/perf/perf_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_VIDEO_PRECOMP_HPP__ diff --git a/modules/video/test/test_precomp.hpp b/modules/video/test/test_precomp.hpp index bef6bf6654..6b528bb5a2 100644 --- a/modules/video/test/test_precomp.hpp +++ b/modules/video/test/test_precomp.hpp @@ -1,6 +1,9 @@ #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" -# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif #endif #ifndef __OPENCV_TEST_PRECOMP_HPP__ diff --git a/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java b/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java index c6cb1a1b2f..a74b0b4d73 100644 --- a/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java +++ b/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java @@ -63,7 +63,8 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener, @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } @@ -76,7 +77,8 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener, public void onDestroy() { super.onDestroy(); - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); } @Override diff --git a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetectionActivity.java b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetectionActivity.java index be736b9380..73a48a16f2 100644 --- a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetectionActivity.java +++ b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetectionActivity.java @@ -78,7 +78,8 @@ public class ColorBlobDetectionActivity extends Activity implements OnTouchListe @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } @@ -91,7 +92,8 @@ public class ColorBlobDetectionActivity extends Activity implements OnTouchListe public void onDestroy() { super.onDestroy(); - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); } public void onCameraViewStarted(int width, int height) { @@ -100,7 +102,7 @@ public class ColorBlobDetectionActivity extends Activity implements OnTouchListe mSpectrum = new Mat(); mBlobColorRgba = new Scalar(255); mBlobColorHsv = new Scalar(255); - SPECTRUM_SIZE = new Size(200, 32); + SPECTRUM_SIZE = new Size(200, 64); CONTOUR_COLOR = new Scalar(255,0,0,255); } @@ -152,6 +154,9 @@ public class ColorBlobDetectionActivity extends Activity implements OnTouchListe mIsColorSelected = true; + touchedRegionRgba.release(); + touchedRegionHsv.release(); + return false; // don't need subsequent touch events } @@ -162,12 +167,12 @@ public class ColorBlobDetectionActivity extends Activity implements OnTouchListe mDetector.process(mRgba); List contours = mDetector.getContours(); Log.e(TAG, "Contours count: " + contours.size()); - Imgproc.drawContours(mRgba, contours, -1, CONTOUR_COLOR); + Core.drawContours(mRgba, contours, -1, CONTOUR_COLOR); - Mat colorLabel = mRgba.submat(2, 34, 2, 34); + Mat colorLabel = mRgba.submat(4, 68, 4, 68); colorLabel.setTo(mBlobColorRgba); - Mat spectrumLabel = mRgba.submat(2, 2 + mSpectrum.rows(), 38, 38 + mSpectrum.cols()); + Mat spectrumLabel = mRgba.submat(4, 4 + mSpectrum.rows(), 70, 70 + mSpectrum.cols()); mSpectrum.copyTo(spectrumLabel); } diff --git a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java index 08c499a581..21988a81a1 100644 --- a/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java +++ b/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetector.java @@ -22,6 +22,13 @@ public class ColorBlobDetector { private Mat mSpectrum = new Mat(); private List mContours = new ArrayList(); + // Cache + Mat mPyrDownMat = new Mat(); + Mat mHsvMat = new Mat(); + Mat mMask = new Mat(); + Mat mDilatedMask = new Mat(); + Mat mHierarchy = new Mat(); + public void setColorRadius(Scalar radius) { mColorRadius = radius; } @@ -61,23 +68,17 @@ public class ColorBlobDetector { } public void process(Mat rgbaImage) { - Mat pyrDownMat = new Mat(); + Imgproc.pyrDown(rgbaImage, mPyrDownMat); + Imgproc.pyrDown(mPyrDownMat, mPyrDownMat); - Imgproc.pyrDown(rgbaImage, pyrDownMat); - Imgproc.pyrDown(pyrDownMat, pyrDownMat); + Imgproc.cvtColor(mPyrDownMat, mHsvMat, Imgproc.COLOR_RGB2HSV_FULL); - Mat hsvMat = new Mat(); - Imgproc.cvtColor(pyrDownMat, hsvMat, Imgproc.COLOR_RGB2HSV_FULL); - - Mat Mask = new Mat(); - Core.inRange(hsvMat, mLowerBound, mUpperBound, Mask); - Mat dilatedMask = new Mat(); - Imgproc.dilate(Mask, dilatedMask, new Mat()); + Core.inRange(mHsvMat, mLowerBound, mUpperBound, mMask); + Imgproc.dilate(mMask, mDilatedMask, new Mat()); List contours = new ArrayList(); - Mat hierarchy = new Mat(); - Imgproc.findContours(dilatedMask, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); + Imgproc.findContours(mDilatedMask, contours, mHierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); // Find max contour area double maxArea = 0; diff --git a/samples/android/face-detection/src/org/opencv/samples/fd/FdActivity.java b/samples/android/face-detection/src/org/opencv/samples/fd/FdActivity.java index 0bb4978a09..9470a8fd1f 100644 --- a/samples/android/face-detection/src/org/opencv/samples/fd/FdActivity.java +++ b/samples/android/face-detection/src/org/opencv/samples/fd/FdActivity.java @@ -50,7 +50,7 @@ public class FdActivity extends Activity implements CvCameraViewListener { private int mDetectorType = JAVA_DETECTOR; private String[] mDetectorName; - private float mRelativeFaceSize = 0; + private float mRelativeFaceSize = 0.2f; private int mAbsoluteFaceSize = 0; private CameraBridgeViewBase mOpenCvCameraView; @@ -132,7 +132,8 @@ public class FdActivity extends Activity implements CvCameraViewListener { @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } diff --git a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java index 569de5dc70..26f7e8317d 100644 --- a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java +++ b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java @@ -113,7 +113,8 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } @@ -126,7 +127,8 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView public void onDestroy() { super.onDestroy(); - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); } @Override diff --git a/samples/android/tutorial-1-addopencv/src/org/opencv/samples/tutorial1/Sample1Java.java b/samples/android/tutorial-1-addopencv/src/org/opencv/samples/tutorial1/Sample1Java.java index beb368f963..6478f3bb05 100644 --- a/samples/android/tutorial-1-addopencv/src/org/opencv/samples/tutorial1/Sample1Java.java +++ b/samples/android/tutorial-1-addopencv/src/org/opencv/samples/tutorial1/Sample1Java.java @@ -68,7 +68,8 @@ public class Sample1Java extends Activity implements CvCameraViewListener { @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } @@ -81,7 +82,8 @@ public class Sample1Java extends Activity implements CvCameraViewListener { public void onDestroy() { super.onDestroy(); - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); } @Override diff --git a/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2NativeCamera.java b/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2NativeCamera.java index 8fbdeef8e3..dcdffe325d 100644 --- a/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2NativeCamera.java +++ b/samples/android/tutorial-2-opencvcamera/src/org/opencv/samples/tutorial2/Sample2NativeCamera.java @@ -75,7 +75,8 @@ public class Sample2NativeCamera extends Activity implements CvCameraViewListene @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } @@ -88,7 +89,8 @@ public class Sample2NativeCamera extends Activity implements CvCameraViewListene public void onDestroy() { super.onDestroy(); - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); } public void onCameraViewStarted(int width, int height) { diff --git a/samples/android/tutorial-3-native/src/org/opencv/samples/tutorial3/Sample3Native.java b/samples/android/tutorial-3-native/src/org/opencv/samples/tutorial3/Sample3Native.java index c216bea9a1..5f0e6c8801 100644 --- a/samples/android/tutorial-3-native/src/org/opencv/samples/tutorial3/Sample3Native.java +++ b/samples/android/tutorial-3-native/src/org/opencv/samples/tutorial3/Sample3Native.java @@ -64,7 +64,8 @@ public class Sample3Native extends Activity implements CvCameraViewListener { @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } @@ -77,7 +78,8 @@ public class Sample3Native extends Activity implements CvCameraViewListener { public void onDestroy() { super.onDestroy(); - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); } public void onCameraViewStarted(int width, int height) { diff --git a/samples/android/tutorial-4-mixed/src/org/opencv/samples/tutorial4/Sample4Mixed.java b/samples/android/tutorial-4-mixed/src/org/opencv/samples/tutorial4/Sample4Mixed.java index c9e745b65c..e70f9d68c7 100644 --- a/samples/android/tutorial-4-mixed/src/org/opencv/samples/tutorial4/Sample4Mixed.java +++ b/samples/android/tutorial-4-mixed/src/org/opencv/samples/tutorial4/Sample4Mixed.java @@ -90,7 +90,8 @@ public class Sample4Mixed extends Activity implements CvCameraViewListener { @Override public void onPause() { - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); super.onPause(); } @@ -103,7 +104,8 @@ public class Sample4Mixed extends Activity implements CvCameraViewListener { public void onDestroy() { super.onDestroy(); - mOpenCvCameraView.disableView(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); } public void onCameraViewStarted(int width, int height) { diff --git a/samples/cpp/pca.cpp b/samples/cpp/pca.cpp index eb891be589..ed23c7622b 100644 --- a/samples/cpp/pca.cpp +++ b/samples/cpp/pca.cpp @@ -64,7 +64,7 @@ static void read_imgList(const string& filename, vector& images) { static Mat formatImagesForPCA(const vector &data) { - Mat dst(data.size(), data[0].rows*data[0].cols, CV_32F); + Mat dst(static_cast(data.size()), data[0].rows*data[0].cols, CV_32F); for(unsigned int i = 0; i < data.size(); i++) { Mat image_row = data[i].clone().reshape(1,1);