From 0b365f6aa564766c236189d577d0c33b1209ca35 Mon Sep 17 00:00:00 2001 From: yao Date: Fri, 8 Feb 2013 11:41:46 +0800 Subject: [PATCH 01/15] add +-*/ operators to oclMat --- modules/ocl/include/opencv2/ocl/ocl.hpp | 11 ++++++++++ modules/ocl/src/arithm.cpp | 29 +++++++++++++++++++++++++ modules/ocl/src/matrix_operations.cpp | 25 +++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/modules/ocl/include/opencv2/ocl/ocl.hpp b/modules/ocl/include/opencv2/ocl/ocl.hpp index 5e4b143f85..e86207d500 100644 --- a/modules/ocl/include/opencv2/ocl/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl/ocl.hpp @@ -219,6 +219,11 @@ namespace cv oclMat operator()( Range rowRange, Range colRange ) const; oclMat operator()( const Rect &roi ) const; + oclMat& operator+=( const oclMat& m ); + oclMat& operator-=( const oclMat& m ); + oclMat& operator*=( const oclMat& m ); + oclMat& operator/=( const oclMat& m ); + //! 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) @@ -468,6 +473,12 @@ namespace cv CV_EXPORTS oclMat operator ^ (const oclMat &src1, const oclMat &src2); CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0); + //! Mathematics operators + CV_EXPORTS oclMat operator + (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMat operator - (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMat operator * (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMat operator / (const oclMat &src1, const oclMat &src2); + //////////////////////////////// Filter Engine //////////////////////////////// /*! diff --git a/modules/ocl/src/arithm.cpp b/modules/ocl/src/arithm.cpp index de8f4343b4..e43cf5096b 100644 --- a/modules/ocl/src/arithm.cpp +++ b/modules/ocl/src/arithm.cpp @@ -12,6 +12,7 @@ // // Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved. // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. // Third party copyrights are property of their respective owners. // // @Authors @@ -2152,6 +2153,34 @@ cv::ocl::oclMat cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2) return dst; } +cv::ocl::oclMat cv::ocl::operator + (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + add(src1, src2, dst); + return dst; +} + +cv::ocl::oclMat cv::ocl::operator - (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + subtract(src1, src2, dst); + return dst; +} + +cv::ocl::oclMat cv::ocl::operator * (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + multiply(src1, src2, dst); + return dst; +} + +cv::ocl::oclMat cv::ocl::operator / (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + divide(src1, src2, dst); + return dst; +} + ////////////////////////////////////////////////////////////////////////////// /////////////////////////////// transpose //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// diff --git a/modules/ocl/src/matrix_operations.cpp b/modules/ocl/src/matrix_operations.cpp index b2b8b5ff20..7b90218d97 100644 --- a/modules/ocl/src/matrix_operations.cpp +++ b/modules/ocl/src/matrix_operations.cpp @@ -12,10 +12,12 @@ // // Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved. // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. // Third party copyrights are property of their respective owners. // // @Authors // Niko Li, newlife20080214@gmail.com +// Yao Wang, bitwangyaoyao@gmail.com // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: @@ -1020,4 +1022,27 @@ void cv::ocl::oclMat::release() refcount = 0; } +oclMat& cv::ocl::oclMat::operator+=( const oclMat& m ) +{ + add(*this, m, *this); + return *this; +} + +oclMat& cv::ocl::oclMat::operator-=( const oclMat& m ) +{ + subtract(*this, m, *this); + return *this; +} + +oclMat& cv::ocl::oclMat::operator*=( const oclMat& m ) +{ + multiply(*this, m, *this); + return *this; +} + +oclMat& cv::ocl::oclMat::operator/=( const oclMat& m ) +{ + divide(*this, m, *this); + return *this; +} #endif /* !defined (HAVE_OPENCL) */ From 8c44e1ff8133eddf6eaf52668f918a26594e6e33 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 18 Jan 2013 18:33:04 +0400 Subject: [PATCH 02/15] Native testing for OpenCV Manager enabled All tests added to CMake; All tests ported on 4 digit version support; Some test fixes and bug fixes were done. --- android/scripts/cmake_android_service.sh | 1 + android/service/engine/CMakeLists.txt | 11 +++++ .../jni/Tests/HardwareDetectionTest.cpp | 13 +++--- .../engine/jni/Tests/OpenCVEngineTest.cpp | 28 ++++++------ .../engine/jni/Tests/PackageInfoTest.cpp | 40 ++++++++--------- .../engine/jni/Tests/PackageManagmentTest.cpp | 45 +++++++++---------- 6 files changed, 74 insertions(+), 64 deletions(-) diff --git a/android/scripts/cmake_android_service.sh b/android/scripts/cmake_android_service.sh index e0d1222cd0..a5a3d50ade 100755 --- a/android/scripts/cmake_android_service.sh +++ b/android/scripts/cmake_android_service.sh @@ -6,3 +6,4 @@ cd build_service cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../.. +#-DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" diff --git a/android/service/engine/CMakeLists.txt b/android/service/engine/CMakeLists.txt index 14066831a6..9ed6ee5cf5 100644 --- a/android/service/engine/CMakeLists.txt +++ b/android/service/engine/CMakeLists.txt @@ -62,3 +62,14 @@ set_target_properties(${engine}_jni PROPERTIES get_target_property(engine_lib_location ${engine}_jni LOCATION) add_custom_command(TARGET ${engine}_jni POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${engine_lib_location}") + +# native tests +add_definitions(-DGTEST_HAS_CLONE=0 -DGTEST_OS_LINUX_ANDROID=1 -DGTEST_HAS_TR1_TUPLE=0) +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined") + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/jni/Tests) +file(GLOB engine_test_files "jni/Tests/*.cpp") + +add_executable(opencv_engine_test ${engine_test_files} jni/Tests/gtest/gtest-all.cpp) +target_link_libraries(opencv_engine_test z binder log utils android_runtime ${engine} ${engine}_jni) + diff --git a/android/service/engine/jni/Tests/HardwareDetectionTest.cpp b/android/service/engine/jni/Tests/HardwareDetectionTest.cpp index 5318733d52..e4c1284f39 100644 --- a/android/service/engine/jni/Tests/HardwareDetectionTest.cpp +++ b/android/service/engine/jni/Tests/HardwareDetectionTest.cpp @@ -111,7 +111,6 @@ TEST(Split, SplitMultiElementString) TEST(CpuCount, CheckNonZero) { EXPECT_TRUE(GetProcessorCount() != 0); - EXPECT_TRUE(a.find("") == a.end()); } TEST(GetCpuInfo, GetCpuInfo) @@ -140,13 +139,13 @@ TEST(CpuID, CheckSSE2) EXPECT_TRUE(cpu_id & FEATURES_HAS_SSE2); } #elseif __mips - #ifdef __SUPPORT_MIPS - TEST(CpuID, CheckMips) - { +#ifdef __SUPPORT_MIPS +TEST(CpuID, CheckMips) +{ int cpu_id = GetCpuID(); EXPECT_TRUE(cpu_id & ARCH_MIPS); - } - #endif +} +#endif #else TEST(TegraDetector, Detect) { @@ -175,4 +174,4 @@ TEST(PlatfromDetector, CheckTegra) { EXPECT_NE(PLATFORM_UNKNOWN, DetectKnownPlatforms()); } -#endif \ No newline at end of file +#endif diff --git a/android/service/engine/jni/Tests/OpenCVEngineTest.cpp b/android/service/engine/jni/Tests/OpenCVEngineTest.cpp index 91302942ad..a42277f96d 100644 --- a/android/service/engine/jni/Tests/OpenCVEngineTest.cpp +++ b/android/service/engine/jni/Tests/OpenCVEngineTest.cpp @@ -69,7 +69,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_X86); + Starter.PackageManager->InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_X86); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4")); EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string()); @@ -79,7 +79,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X86); + Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_X86); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4.1")); EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string()); @@ -89,7 +89,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_X86); + Starter.PackageManager->InstallVersion(2040100, PLATFORM_UNKNOWN, ARCH_X86); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4.2")); EXPECT_EQ(0, result.size()); @@ -100,7 +100,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_MIPS); + Starter.PackageManager->InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4")); EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string()); @@ -110,7 +110,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_MIPS); + Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_MIPS); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4.1")); EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string()); @@ -120,7 +120,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_MIPS); + Starter.PackageManager->InstallVersion(2040100, PLATFORM_UNKNOWN, ARCH_MIPS); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4.2")); EXPECT_EQ(0, result.size()); @@ -131,7 +131,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("240", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + Starter.PackageManager->InstallVersion(2040000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4")); #ifdef __SUPPORT_TEGRA3 @@ -149,7 +149,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + Starter.PackageManager->InstallVersion(2040200, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4.1")); #ifdef __SUPPORT_TEGRA3 @@ -167,7 +167,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("241", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + Starter.PackageManager->InstallVersion(2040100, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4.2")); EXPECT_EQ(0, result.size()); @@ -177,7 +177,7 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage1) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv5); + Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv5); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4")); EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", String8(result).string()); @@ -187,7 +187,7 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage2) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + Starter.PackageManager->InstallVersion(2040200, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4")); #ifdef __SUPPORT_TEGRA3 @@ -225,7 +225,7 @@ TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X64); + Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_X64); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4")); EXPECT_EQ(0, result.size()); @@ -235,7 +235,7 @@ TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1) { sp Engine = InitConnect(); Starter.PackageManager->InstalledPackages.clear(); - Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv7); + Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv7); EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.4")); EXPECT_EQ(0, result.size()); @@ -248,4 +248,4 @@ TEST(OpenCVEngineTest, GetPathForUnExistVersion) EXPECT_FALSE(NULL == Engine.get()); String16 result = Engine->GetLibPathByVersion(String16("2.5")); EXPECT_EQ(0, result.size()); -} \ No newline at end of file +} diff --git a/android/service/engine/jni/Tests/PackageInfoTest.cpp b/android/service/engine/jni/Tests/PackageInfoTest.cpp index 2664b55c64..2e747c305d 100644 --- a/android/service/engine/jni/Tests/PackageInfoTest.cpp +++ b/android/service/engine/jni/Tests/PackageInfoTest.cpp @@ -11,14 +11,14 @@ using namespace std; TEST(PackageInfo, FullNameArmv7) { - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7); string name = info.GetFullName(); EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str()); } TEST(PackageInfo, FullNameArmv7Neon) { - PackageInfo info("241", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON); + PackageInfo info(2040100, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON); string name = info.GetFullName(); #ifdef __SUPPORT_ARMEABI_V7A_FEATURES EXPECT_STREQ("org.opencv.lib_v24_armv7a_neon", name.c_str()); @@ -29,14 +29,14 @@ TEST(PackageInfo, FullNameArmv7Neon) TEST(PackageInfo, FullNameArmv7VFPv3) { - PackageInfo info("233", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3); + PackageInfo info(2030300, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3); string name = info.GetFullName(); EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str()); } TEST(PackageInfo, FullNameArmv7VFPv3Neon) { - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON); string name = info.GetFullName(); #ifdef __SUPPORT_ARMEABI_V7A_FEATURES EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str()); @@ -47,21 +47,21 @@ TEST(PackageInfo, FullNameArmv7VFPv3Neon) TEST(PackageInfo, FullNameArmv5) { - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv5); string name = info.GetFullName(); EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str()); } TEST(PackageInfo, FullNameArmv6) { - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv6); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv6); string name = info.GetFullName(); EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str()); } TEST(PackageInfo, FullNameArmv6VFPv3) { - PackageInfo info("232", PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3); + PackageInfo info(2030200, PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3); string name = info.GetFullName(); #ifdef __SUPPORT_ARMEABI_FEATURES EXPECT_STREQ("org.opencv.lib_v23_armv5_vfpv3", name.c_str()); @@ -72,7 +72,7 @@ TEST(PackageInfo, FullNameArmv6VFPv3) TEST(PackageInfo, FullNameTegra3) { - PackageInfo info("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + PackageInfo info(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); string name = info.GetFullName(); #ifdef __SUPPORT_TEGRA3 EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str()); @@ -87,7 +87,7 @@ TEST(PackageInfo, FullNameTegra3) TEST(PackageInfo, FullNameX86SSE2) { - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2); string name = info.GetFullName(); #ifdef __SUPPORT_INTEL_FEATURES EXPECT_STREQ("org.opencv.lib_v23_x86_sse2", name.c_str()); @@ -99,7 +99,7 @@ TEST(PackageInfo, FullNameX86SSE2) #ifdef __SUPPORT_MIPS TEST(PackageInfo, FullNameMips) { - PackageInfo info("243", PLATFORM_UNKNOWN, ARCH_MIPS); + PackageInfo info(2040300, PLATFORM_UNKNOWN, ARCH_MIPS); string name = info.GetFullName(); EXPECT_STREQ("org.opencv.lib_v24_mips", name.c_str()); } @@ -108,21 +108,21 @@ TEST(PackageInfo, FullNameMips) TEST(PackageInfo, Armv7NeonFromFullName) { PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon"); - EXPECT_EQ("230", info.GetVersion()); + EXPECT_EQ(2030000, info.GetVersion()); EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID()); } TEST(PackageInfo, Armv5FromFullName) { PackageInfo info("org.opencv.lib_v23_armv5", "/data/data/org.opencv.lib_v23_armv5"); - EXPECT_EQ("230", info.GetVersion()); + EXPECT_EQ(2030000, info.GetVersion()); EXPECT_EQ(ARCH_ARMv5, info.GetCpuID()); } TEST(PackageInfo, Armv5VFPv3FromFullName) { PackageInfo info("org.opencv.lib_v23_armv5_vfpv3", "/data/data/org.opencv.lib_v23_armv5_vfpv3"); - EXPECT_EQ("230", info.GetVersion()); + EXPECT_EQ(2030000, info.GetVersion()); EXPECT_EQ(ARCH_ARMv5 | FEATURES_HAS_VFPv3, info.GetCpuID()); } @@ -131,20 +131,20 @@ TEST(PackageInfo, X86SSE2FromFullName) PackageInfo info("org.opencv.lib_v24_x86_sse2", "/data/data/org.opencv.lib_v24_x86_sse2"); EXPECT_EQ(PLATFORM_UNKNOWN, info.GetPlatform()); EXPECT_EQ(ARCH_X86 | FEATURES_HAS_SSE2, info.GetCpuID()); - EXPECT_EQ("240", info.GetVersion()); + EXPECT_EQ(2040000, info.GetVersion()); } TEST(PackageInfo, Tegra2FromFullName) { PackageInfo info("org.opencv.lib_v23_tegra2", "/data/data/org.opencv.lib_v23_tegra2"); - EXPECT_EQ("230", info.GetVersion()); + EXPECT_EQ(2030000, info.GetVersion()); EXPECT_EQ(PLATFORM_TEGRA2, info.GetPlatform()); } TEST(PackageInfo, Tegra3FromFullName) { PackageInfo info("org.opencv.lib_v24_tegra3", "/data/data/org.opencv.lib_v24_tegra3"); - EXPECT_EQ("240", info.GetVersion()); + EXPECT_EQ(2040000, info.GetVersion()); EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform()); } @@ -152,14 +152,14 @@ TEST(PackageInfo, Tegra3FromFullName) TEST(PackageInfo, MipsFromFullName) { PackageInfo info("org.opencv.lib_v24_mips", "/data/data/org.opencv.lib_v24_mips"); - EXPECT_EQ("240", info.GetVersion()); + EXPECT_EQ(2040000, info.GetVersion()); EXPECT_EQ(ARCH_MIPS, info.GetCpuID()); } #endif TEST(PackageInfo, Comparator1) { - PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_X86); + PackageInfo info1(2040000, PLATFORM_UNKNOWN, ARCH_X86); PackageInfo info2("org.opencv.lib_v24_x86", "/data/data/org.opencv.lib_v24_x86"); EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str()); EXPECT_EQ(info1, info2); @@ -167,7 +167,7 @@ TEST(PackageInfo, Comparator1) TEST(PackageInfo, Comparator2) { - PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3); + PackageInfo info1(2040000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3); #ifdef __SUPPORT_ARMEABI_V7A_FEATURES PackageInfo info2("org.opencv.lib_v24_armv7a_neon", "/data/data/org.opencv.lib_v24_armv7a_neon"); #else @@ -180,7 +180,7 @@ TEST(PackageInfo, Comparator2) #ifdef __SUPPORT_TEGRA3 TEST(PackageInfo, Comparator3) { - PackageInfo info1("230", PLATFORM_TEGRA3, 0); + PackageInfo info1(2030000, PLATFORM_TEGRA3, 0); PackageInfo info2("org.opencv.lib_v23_tegra3", "/data/data/org.opencv.lib_v23_tegra3"); EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str()); EXPECT_EQ(info1, info2); diff --git a/android/service/engine/jni/Tests/PackageManagmentTest.cpp b/android/service/engine/jni/Tests/PackageManagmentTest.cpp index 4c28045959..f9ccb74844 100644 --- a/android/service/engine/jni/Tests/PackageManagmentTest.cpp +++ b/android/service/engine/jni/Tests/PackageManagmentTest.cpp @@ -5,7 +5,6 @@ #include "IOpenCVEngine.h" #include #include -#include #include #include @@ -14,52 +13,52 @@ using namespace std; TEST(PackageManager, InstalledVersions) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7); pm.InstalledPackages.push_back(info); - std::set versions = pm.GetInstalledVersions(); + std::vector versions = pm.GetInstalledVersions(); EXPECT_EQ(1, versions.size()); - EXPECT_EQ("230", *versions.begin()); + EXPECT_EQ(2030000, *versions.begin()); } TEST(PackageManager, CheckVersionInstalled) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7); pm.InstalledPackages.push_back(info); - EXPECT_TRUE(pm.CheckVersionInstalled("230", PLATFORM_UNKNOWN, ARCH_ARMv7)); + EXPECT_TRUE(pm.CheckVersionInstalled(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7)); } TEST(PackageManager, InstallVersion) { PackageManagerStub pm; - PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5); + PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv5); pm.InstalledPackages.push_back(info); - EXPECT_TRUE(pm.InstallVersion("240", PLATFORM_UNKNOWN, ARCH_ARMv5)); + EXPECT_TRUE(pm.InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_ARMv5)); EXPECT_EQ(2, pm.InstalledPackages.size()); - EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_UNKNOWN, ARCH_ARMv5)); + EXPECT_TRUE(pm.CheckVersionInstalled(2040000, PLATFORM_UNKNOWN, ARCH_ARMv5)); } TEST(PackageManager, GetPackagePathForArmv5) { PackageManagerStub pm; - EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5)); - string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5); + EXPECT_TRUE(pm.InstallVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv5)); + string path = pm.GetPackagePathByVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv5); EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", path.c_str()); } TEST(PackageManager, GetPackagePathForArmv7) { PackageManagerStub pm; - EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7)); - string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7); + EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7)); + string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7); EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str()); } TEST(PackageManager, GetPackagePathForArmv7Neon) { PackageManagerStub pm; - EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON)); - string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON); + EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON)); + string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON); #ifdef __SUPPORT_ARMEABI_V7A_FEATURES EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str()); #else @@ -70,16 +69,16 @@ TEST(PackageManager, GetPackagePathForArmv7Neon) TEST(PackageManager, GetPackagePathForX86) { PackageManagerStub pm; - EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86)); - string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86); + EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86)); + string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86); EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str()); } TEST(PackageManager, GetPackagePathForX86SSE2) { PackageManagerStub pm; - EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2)); - string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2); + EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2)); + string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2); #ifdef __SUPPORT_INTEL_FEATURES EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str()); #else @@ -90,8 +89,8 @@ TEST(PackageManager, GetPackagePathForX86SSE2) TEST(PackageManager, GetPackagePathForTegra3) { PackageManagerStub pm; - EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON)); - string path = pm.GetPackagePathByVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON); + EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON)); + string path = pm.GetPackagePathByVersion(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON); #ifdef __SUPPORT_TEGRA3 EXPECT_STREQ("/data/data/org.opencv.lib_v23_tegra3/lib", path.c_str()); #else @@ -107,8 +106,8 @@ TEST(PackageManager, GetPackagePathForTegra3) TEST(PackageManager, GetPackagePathForMips) { PackageManagerStub pm; - EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS)); - string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS); + EXPECT_TRUE(pm.InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS)); + string path = pm.GetPackagePathByVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS); EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", path.c_str()); } #endif From 9f01074f4cd660e4bf661ac3febf49da2d9a2ae2 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 22 Jan 2013 15:53:07 +0400 Subject: [PATCH 03/15] Bug in hardware ratings fixed. --- android/scripts/cmake_android_service.sh | 2 - android/service/engine/CMakeLists.txt | 6 +- .../NativeService/CommonPackageManager.cpp | 69 +++++++++++++------ .../jni/NativeService/CommonPackageManager.h | 4 +- .../jni/Tests/HardwareDetectionTest.cpp | 4 +- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/android/scripts/cmake_android_service.sh b/android/scripts/cmake_android_service.sh index a5a3d50ade..0dbd482520 100755 --- a/android/scripts/cmake_android_service.sh +++ b/android/scripts/cmake_android_service.sh @@ -5,5 +5,3 @@ mkdir -p build_service cd build_service cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../.. - -#-DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" diff --git a/android/service/engine/CMakeLists.txt b/android/service/engine/CMakeLists.txt index 9ed6ee5cf5..8b88393942 100644 --- a/android/service/engine/CMakeLists.txt +++ b/android/service/engine/CMakeLists.txt @@ -64,12 +64,12 @@ get_target_property(engine_lib_location ${engine}_jni LOCATION) add_custom_command(TARGET ${engine}_jni POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${engine_lib_location}") # native tests -add_definitions(-DGTEST_HAS_CLONE=0 -DGTEST_OS_LINUX_ANDROID=1 -DGTEST_HAS_TR1_TUPLE=0) +add_definitions(-DGTEST_HAS_CLONE=0 -DANDROID -DGTEST_HAS_TR1_TUPLE=0) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/jni/Tests) file(GLOB engine_test_files "jni/Tests/*.cpp") -add_executable(opencv_engine_test ${engine_test_files} jni/Tests/gtest/gtest-all.cpp) -target_link_libraries(opencv_engine_test z binder log utils android_runtime ${engine} ${engine}_jni) +add_executable(opencv_test_engine ${engine_test_files} jni/Tests/gtest/gtest-all.cpp) +target_link_libraries(opencv_test_engine z binder log utils android_runtime ${engine} ${engine}_jni) diff --git a/android/service/engine/jni/NativeService/CommonPackageManager.cpp b/android/service/engine/jni/NativeService/CommonPackageManager.cpp index 9e1ffaa98a..dbcd8ff689 100644 --- a/android/service/engine/jni/NativeService/CommonPackageManager.cpp +++ b/android/service/engine/jni/NativeService/CommonPackageManager.cpp @@ -80,17 +80,21 @@ string CommonPackageManager::GetPackagePathByVersion(int version, int platform, if (!packages.empty()) { - int OptRating = -1; - int OptVersion = 0; - std::vector >& group = CommonPackageManager::ArmRating; + int platform_group = 0; if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64)) - group = CommonPackageManager::IntelRating; + platform_group = 1; - int HardwareRating = GetHardwareRating(platform, cpu_id, group); - LOGD("Current hardware platform rating %d for (%d,%d)", HardwareRating, platform, cpu_id); + if (cpu_id & ARCH_MIPS) + platform_group = 2; - if (-1 == HardwareRating) + int opt_rating = -1; + int opt_version = 0; + + const int hardware_rating = GetHardwareRating(platform, cpu_id, ArchRatings[platform_group]); + LOGD("Current hardware platform rating %d for (%d,%d)", hardware_rating, platform, cpu_id); + + if (-1 == hardware_rating) { LOGE("Cannot calculate rating for current hardware platform!"); } @@ -99,26 +103,38 @@ string CommonPackageManager::GetPackagePathByVersion(int version, int platform, vector::iterator found = packages.end(); for (vector::iterator it = packages.begin(); it != packages.end(); ++it) { - int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group); - LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), PackageRating, it->GetPlatform(), it->GetCpuID()); - if ((PackageRating >= 0) && (PackageRating <= HardwareRating)) + int package_group = 0; + + if ((it->GetCpuID() & ARCH_X86) || (it->GetCpuID() & ARCH_X64)) + package_group = 1; + + if (it->GetCpuID() & ARCH_MIPS) + package_group = 2; + + if (package_group != platform_group) + continue; + + const int package_rating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), ArchRatings[package_group]); + + LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), package_rating, it->GetPlatform(), it->GetCpuID()); + if ((package_rating >= 0) && (package_rating <= hardware_rating)) { - if (((it->GetVersion() >= OptVersion) && (PackageRating >= OptRating)) || (it->GetVersion() > OptVersion)) + if (((it->GetVersion() >= opt_version) && (package_rating >= opt_rating)) || (it->GetVersion() > opt_version)) { - OptRating = PackageRating; - OptVersion = it->GetVersion(); + opt_rating = package_rating; + opt_version = it->GetVersion(); found = it; } } } - if ((-1 != OptRating) && (packages.end() != found)) + if ((-1 != opt_rating) && (packages.end() != found)) { result = found->GetInstalationPath(); } else { - LOGI("Found package is incompatible with current hardware platform"); + LOGI("No compatible packages found!"); } } } @@ -146,10 +162,13 @@ int CommonPackageManager::GetHardwareRating(int platform, int cpu_id, const std: else { // Calculate rating for Arm + LOGD("!!! Calculating rating for ARM\n"); for (size_t i = 0; i < group.size(); i++) { + LOGD("Checking (%d, %d) against (%d,%d)\n", group[i].first, group[i].second, platform, cpu_id); if (group[i] == std::pair(platform, cpu_id)) { + LOGD("Rating found: %d\n", i); result = i; break; } @@ -182,21 +201,27 @@ std::vector > CommonPackageManager::InitArmRating() return result; } +// Stub for Intel platforms rating initialization. Common package for all Intel based devices is used now std::vector > CommonPackageManager::InitIntelRating() { std::vector > result; - result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_X64)); - result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSSE3)); - result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2)); - result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE)); - result.push_back(std::pair(PLATFORM_UNKNOWN, ARCH_X86)); + return result; +} + +// Stub for MIPS platforms rating initialization. Common package for all MIPS based devices is used now +std::vector > CommonPackageManager::InitMipsRating() +{ + std::vector > result; return result; } -std::vector > CommonPackageManager::IntelRating = CommonPackageManager::InitIntelRating(); -std::vector > CommonPackageManager::ArmRating = InitArmRating(); +const std::vector > CommonPackageManager::ArchRatings[] = { + CommonPackageManager::InitArmRating(), + CommonPackageManager::InitIntelRating(), + CommonPackageManager::InitMipsRating() + }; CommonPackageManager::~CommonPackageManager() { diff --git a/android/service/engine/jni/NativeService/CommonPackageManager.h b/android/service/engine/jni/NativeService/CommonPackageManager.h index c02eb322e5..6d5d6aa64d 100644 --- a/android/service/engine/jni/NativeService/CommonPackageManager.h +++ b/android/service/engine/jni/NativeService/CommonPackageManager.h @@ -16,11 +16,11 @@ public: virtual ~CommonPackageManager(); protected: - static std::vector > ArmRating; - static std::vector > IntelRating; + static const std::vector > ArchRatings[]; static std::vector > InitArmRating(); static std::vector > InitIntelRating(); + static std::vector > InitMipsRating(); bool IsVersionCompatible(int target_version, int package_version); int GetHardwareRating(int platform, int cpu_id, const std::vector >& group); diff --git a/android/service/engine/jni/Tests/HardwareDetectionTest.cpp b/android/service/engine/jni/Tests/HardwareDetectionTest.cpp index e4c1284f39..8637dfee30 100644 --- a/android/service/engine/jni/Tests/HardwareDetectionTest.cpp +++ b/android/service/engine/jni/Tests/HardwareDetectionTest.cpp @@ -126,7 +126,7 @@ TEST(CpuID, CheckNotEmpy) EXPECT_NE(0, cpu_id); } -#ifdef __i386__ +#if defined(__i386__) TEST(CpuID, CheckX86) { int cpu_id = GetCpuID(); @@ -138,7 +138,7 @@ TEST(CpuID, CheckSSE2) int cpu_id = GetCpuID(); EXPECT_TRUE(cpu_id & FEATURES_HAS_SSE2); } -#elseif __mips +#elif defined(__mips) #ifdef __SUPPORT_MIPS TEST(CpuID, CheckMips) { From 3ead4449adea1bd149fc275cca51807ad73274d6 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 15 Feb 2013 17:28:23 +0400 Subject: [PATCH 04/15] Fix several warnings about uninitialized variables from gcov build --- modules/legacy/src/epilines.cpp | 2 +- modules/legacy/src/lmeds.cpp | 2 +- modules/legacy/src/scanlines.cpp | 16 +++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/legacy/src/epilines.cpp b/modules/legacy/src/epilines.cpp index 19d929df98..309ca0b1d5 100644 --- a/modules/legacy/src/epilines.cpp +++ b/modules/legacy/src/epilines.cpp @@ -1826,7 +1826,7 @@ void icvGetCutPiece( CvVect64d areaLineCoef1,CvVect64d areaLineCoef2, /* Collect all candidate point */ CvPoint2D64d candPoints[8]; - CvPoint2D64d midPoint; + CvPoint2D64d midPoint = {0, 0}; int numPoints = 0; int res; int i; diff --git a/modules/legacy/src/lmeds.cpp b/modules/legacy/src/lmeds.cpp index 4f0abfc128..42272345c3 100644 --- a/modules/legacy/src/lmeds.cpp +++ b/modules/legacy/src/lmeds.cpp @@ -1615,7 +1615,7 @@ CvStatus icvPoint7( int *ml, int *mr, double *F, int *amount ) { double A[63], B[7]; - double *solutions; + double *solutions = 0; double a2, a1, a0; double squares[6]; int i, j; diff --git a/modules/legacy/src/scanlines.cpp b/modules/legacy/src/scanlines.cpp index 09eb4d550f..b83da834d7 100644 --- a/modules/legacy/src/scanlines.cpp +++ b/modules/legacy/src/scanlines.cpp @@ -1125,7 +1125,7 @@ icvBuildScanlineLeft( CvMatrix3 * matrix, CvMatrix3 *F; float i; int offset; - float epiline[3]; + float epiline[3] = {0,}; double a, b; assert( l_start_end != 0 ); @@ -1211,7 +1211,7 @@ icvBuildScanlineRight( CvMatrix3 * matrix, CvMatrix3 *F; float i; int offset; - float epiline[3]; + float epiline[3] = {0,}; double a, b; assert( r_start_end != 0 ); @@ -1389,7 +1389,9 @@ icvGetCoefficientStereo( CvMatrix3 * matrix, float l_angle[2], r_angle[2]; float l_radius, r_radius; float r_point[3], l_point[3]; - float l_epiline[3], r_epiline[3], x, y; + float l_epiline[3] = {0,}; + float r_epiline[3] = {0,}; + float x, y; float swap; float radius1, radius2, radius3, radius4; @@ -1731,8 +1733,8 @@ icvBuildScanlineLeftStereo( CvSize imgSize, float delta; float angle; float l_point[3]; - float l_epiline[3]; - float r_epiline[3]; + float l_epiline[3] = {0,}; + float r_epiline[3] = {0,}; CvStatus error = CV_OK; CvMatrix3 *F; @@ -1819,8 +1821,8 @@ icvBuildScanlineRightStereo( CvSize imgSize, float delta; float angle; float r_point[3]; - float l_epiline[3]; - float r_epiline[3]; + float l_epiline[3] = {0,}; + float r_epiline[3] = {0,}; CvStatus error = CV_OK; CvMatrix3 *F; From 69fd2d82735f14b88b9cb3b08eb5cdd527fdb9e8 Mon Sep 17 00:00:00 2001 From: yao Date: Sat, 16 Feb 2013 11:05:23 +0800 Subject: [PATCH 05/15] add oclMatExpr class to prevent extra allocations --- .../include/opencv2/ocl/matrix_operations.hpp | 28 ++++++++++- modules/ocl/include/opencv2/ocl/ocl.hpp | 25 +++++----- modules/ocl/src/arithm.cpp | 46 ++++++++++++++----- 3 files changed, 73 insertions(+), 26 deletions(-) diff --git a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp index 4b617ce07c..13b19bed68 100644 --- a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp +++ b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp @@ -48,9 +48,27 @@ namespace cv namespace ocl { - ////////////////////////////////////OpenCL kernel strings////////////////////////// - //extern const char *convertC3C4; + enum + { + MAT_ADD, + MAT_SUB, + MAT_MUL, + MAT_DIV + }; + + class oclMatExpr + { + public: + oclMatExpr(const oclMat& _a, const oclMat& _b, int _op) + : a(_a), b(_b), op(_op){} + operator oclMat() const; + void assign(oclMat& m) const; + + protected: + int op; + oclMat a, b; + }; //////////////////////////////////////////////////////////////////////// //////////////////////////////// oclMat //////////////////////////////// //////////////////////////////////////////////////////////////////////// @@ -237,6 +255,12 @@ namespace cv return *this; } + oclMat& oclMat::operator = (const oclMatExpr& expr) + { + expr.assign(*this); + return *this; + } + /* Fixme! To be supported in OpenCL later. */ #if 0 template inline oclMat::operator DevMem2D_() const diff --git a/modules/ocl/include/opencv2/ocl/ocl.hpp b/modules/ocl/include/opencv2/ocl/ocl.hpp index e86207d500..83cfb5a26f 100644 --- a/modules/ocl/include/opencv2/ocl/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl/ocl.hpp @@ -119,6 +119,7 @@ namespace cv Impl *impl; }; + class CV_EXPORTS oclMatExpr; //////////////////////////////// oclMat //////////////////////////////// class CV_EXPORTS oclMat { @@ -152,7 +153,7 @@ namespace cv oclMat &operator = (const oclMat &m); //! assignment operator. Perfom blocking upload to device. oclMat &operator = (const Mat &m); - + oclMat& operator = (const oclMatExpr& expr); //! pefroms blocking upload data to oclMat. void upload(const cv::Mat &m); @@ -296,6 +297,7 @@ namespace cv int wholecols; }; + ///////////////////// mat split and merge ///////////////////////////////// //! Compose a multi-channel array from several single-channel arrays // Support all types @@ -459,25 +461,24 @@ namespace cv // supports all types CV_EXPORTS void bitwise_xor(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask = oclMat()); CV_EXPORTS void bitwise_xor(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat()); - //! computes convolution of two images - - //! support only CV_32FC1 type - - CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result); - //! Logical operators CV_EXPORTS oclMat operator ~ (const oclMat &src); CV_EXPORTS oclMat operator | (const oclMat &src1, const oclMat &src2); CV_EXPORTS oclMat operator & (const oclMat &src1, const oclMat &src2); CV_EXPORTS oclMat operator ^ (const oclMat &src1, const oclMat &src2); - CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0); //! Mathematics operators - CV_EXPORTS oclMat operator + (const oclMat &src1, const oclMat &src2); - CV_EXPORTS oclMat operator - (const oclMat &src1, const oclMat &src2); - CV_EXPORTS oclMat operator * (const oclMat &src1, const oclMat &src2); - CV_EXPORTS oclMat operator / (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMatExpr operator + (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMatExpr operator - (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMatExpr operator * (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMatExpr operator / (const oclMat &src1, const oclMat &src2); + + //! computes convolution of two images + //! support only CV_32FC1 type + CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result); + + CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0); //////////////////////////////// Filter Engine //////////////////////////////// diff --git a/modules/ocl/src/arithm.cpp b/modules/ocl/src/arithm.cpp index e43cf5096b..b9174e7b59 100644 --- a/modules/ocl/src/arithm.cpp +++ b/modules/ocl/src/arithm.cpp @@ -2153,34 +2153,56 @@ cv::ocl::oclMat cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2) return dst; } -cv::ocl::oclMat cv::ocl::operator + (const oclMat &src1, const oclMat &src2) +cv::ocl::oclMatExpr cv::ocl::operator + (const oclMat &src1, const oclMat &src2) { - oclMat dst; - add(src1, src2, dst); + oclMatExpr dst(src1, src2, cv::ocl::MAT_ADD); return dst; } -cv::ocl::oclMat cv::ocl::operator - (const oclMat &src1, const oclMat &src2) +cv::ocl::oclMatExpr cv::ocl::operator - (const oclMat &src1, const oclMat &src2) { - oclMat dst; - subtract(src1, src2, dst); + oclMatExpr dst(src1, src2, cv::ocl::MAT_SUB); return dst; } -cv::ocl::oclMat cv::ocl::operator * (const oclMat &src1, const oclMat &src2) +cv::ocl::oclMatExpr cv::ocl::operator * (const oclMat &src1, const oclMat &src2) { - oclMat dst; - multiply(src1, src2, dst); + oclMatExpr dst(src1, src2, cv::ocl::MAT_MUL); return dst; } -cv::ocl::oclMat cv::ocl::operator / (const oclMat &src1, const oclMat &src2) +cv::ocl::oclMatExpr cv::ocl::operator / (const oclMat &src1, const oclMat &src2) { - oclMat dst; - divide(src1, src2, dst); + oclMatExpr dst(src1, src2, cv::ocl::MAT_DIV); return dst; } +void oclMatExpr::assign(oclMat& m) const +{ + switch (op) + { + case MAT_ADD: + add(a, b, m); + break; + case MAT_SUB: + subtract(a, b, m); + break; + case MAT_MUL: + multiply(a, b, m); + break; + case MAT_DIV: + divide(a, b, m); + break; + } +} + +oclMatExpr::operator oclMat() const +{ + oclMat m; + assign(m); + return m; +} + ////////////////////////////////////////////////////////////////////////////// /////////////////////////////// transpose //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// From 9613135e8dad2a1beed03d190b5f9facf2f55f7f Mon Sep 17 00:00:00 2001 From: yao Date: Sat, 16 Feb 2013 18:41:43 +0800 Subject: [PATCH 06/15] fix compiling errors on Linux more operators use oclMatExpr --- .../include/opencv2/ocl/matrix_operations.hpp | 18 ++++--- modules/ocl/include/opencv2/ocl/ocl.hpp | 12 ++--- modules/ocl/src/arithm.cpp | 48 +++++++++---------- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp index 13b19bed68..fcd847cb6b 100644 --- a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp +++ b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp @@ -12,6 +12,7 @@ // // Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved. // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, @@ -51,23 +52,28 @@ namespace cv enum { - MAT_ADD, + MAT_ADD = 1, MAT_SUB, MAT_MUL, - MAT_DIV + MAT_DIV, + MAT_NOT, + MAT_AND, + MAT_OR, + MAT_XOR }; - class oclMatExpr + class CV_EXPORTS oclMatExpr { public: + oclMatExpr() : a(oclMat()), b(oclMat()), op(0) {} oclMatExpr(const oclMat& _a, const oclMat& _b, int _op) - : a(_a), b(_b), op(_op){} + : a(_a), b(_b), op(_op) {} operator oclMat() const; void assign(oclMat& m) const; protected: - int op; oclMat a, b; + int op; }; //////////////////////////////////////////////////////////////////////// //////////////////////////////// oclMat //////////////////////////////// @@ -255,7 +261,7 @@ namespace cv return *this; } - oclMat& oclMat::operator = (const oclMatExpr& expr) + inline oclMat& oclMat::operator = (const oclMatExpr& expr) { expr.assign(*this); return *this; diff --git a/modules/ocl/include/opencv2/ocl/ocl.hpp b/modules/ocl/include/opencv2/ocl/ocl.hpp index 83cfb5a26f..57d18d1edb 100644 --- a/modules/ocl/include/opencv2/ocl/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl/ocl.hpp @@ -153,7 +153,7 @@ namespace cv oclMat &operator = (const oclMat &m); //! assignment operator. Perfom blocking upload to device. oclMat &operator = (const Mat &m); - oclMat& operator = (const oclMatExpr& expr); + oclMat &operator = (const oclMatExpr& expr); //! pefroms blocking upload data to oclMat. void upload(const cv::Mat &m); @@ -463,10 +463,10 @@ namespace cv CV_EXPORTS void bitwise_xor(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat()); //! Logical operators - CV_EXPORTS oclMat operator ~ (const oclMat &src); - CV_EXPORTS oclMat operator | (const oclMat &src1, const oclMat &src2); - CV_EXPORTS oclMat operator & (const oclMat &src1, const oclMat &src2); - CV_EXPORTS oclMat operator ^ (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMatExpr operator ~ (const oclMat &src); + CV_EXPORTS oclMatExpr operator | (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMatExpr operator & (const oclMat &src1, const oclMat &src2); + CV_EXPORTS oclMatExpr operator ^ (const oclMat &src1, const oclMat &src2); //! Mathematics operators CV_EXPORTS oclMatExpr operator + (const oclMat &src1, const oclMat &src2); @@ -478,7 +478,7 @@ namespace cv //! support only CV_32FC1 type CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result); - CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0); + CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0); //////////////////////////////// Filter Engine //////////////////////////////// diff --git a/modules/ocl/src/arithm.cpp b/modules/ocl/src/arithm.cpp index b9174e7b59..f98b14358d 100644 --- a/modules/ocl/src/arithm.cpp +++ b/modules/ocl/src/arithm.cpp @@ -2125,56 +2125,44 @@ void cv::ocl::bitwise_xor(const oclMat &src1, const Scalar &src2, oclMat &dst, c bitwise_scalar( src1, src2, dst, mask, kernelName, &arithm_bitwise_xor_scalar); } -cv::ocl::oclMat cv::ocl::operator ~ (const oclMat &src) +oclMatExpr cv::ocl::operator ~ (const oclMat &src) { - oclMat dst; - bitwise_not(src, dst); - return dst; + return oclMatExpr(src, oclMat(), MAT_NOT); } -cv::ocl::oclMat cv::ocl::operator | (const oclMat &src1, const oclMat &src2) +oclMatExpr cv::ocl::operator | (const oclMat &src1, const oclMat &src2) { - oclMat dst; - bitwise_or(src1, src2, dst); - return dst; + return oclMatExpr(src1, src2, MAT_OR); } -cv::ocl::oclMat cv::ocl::operator & (const oclMat &src1, const oclMat &src2) +oclMatExpr cv::ocl::operator & (const oclMat &src1, const oclMat &src2) { - oclMat dst; - bitwise_and(src1, src2, dst); - return dst; + return oclMatExpr(src1, src2, MAT_AND); } -cv::ocl::oclMat cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2) +oclMatExpr cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2) { - oclMat dst; - bitwise_xor(src1, src2, dst); - return dst; + return oclMatExpr(src1, src2, MAT_XOR); } cv::ocl::oclMatExpr cv::ocl::operator + (const oclMat &src1, const oclMat &src2) { - oclMatExpr dst(src1, src2, cv::ocl::MAT_ADD); - return dst; + return oclMatExpr(src1, src2, cv::ocl::MAT_ADD); } cv::ocl::oclMatExpr cv::ocl::operator - (const oclMat &src1, const oclMat &src2) { - oclMatExpr dst(src1, src2, cv::ocl::MAT_SUB); - return dst; + return oclMatExpr(src1, src2, cv::ocl::MAT_SUB); } cv::ocl::oclMatExpr cv::ocl::operator * (const oclMat &src1, const oclMat &src2) { - oclMatExpr dst(src1, src2, cv::ocl::MAT_MUL); - return dst; + return oclMatExpr(src1, src2, cv::ocl::MAT_MUL); } cv::ocl::oclMatExpr cv::ocl::operator / (const oclMat &src1, const oclMat &src2) { - oclMatExpr dst(src1, src2, cv::ocl::MAT_DIV); - return dst; + return oclMatExpr(src1, src2, cv::ocl::MAT_DIV); } void oclMatExpr::assign(oclMat& m) const @@ -2193,6 +2181,18 @@ void oclMatExpr::assign(oclMat& m) const case MAT_DIV: divide(a, b, m); break; + case MAT_NOT: + bitwise_not(a, m); + break; + case MAT_AND: + bitwise_and(a, b, m); + break; + case MAT_OR: + bitwise_or(a, b, m); + break; + case MAT_XOR: + bitwise_xor(a, b, m); + break; } } From a1c7e0368cb44018f56045505a86133d72272a7e Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 18 Feb 2013 17:01:21 +0400 Subject: [PATCH 07/15] fixed problem reported by Thouis (Ray) Jones --- modules/core/src/matrix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index f21e6ac4f2..6c265f6c6f 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -3496,7 +3496,7 @@ enum { HASH_SIZE0 = 8 }; static inline void copyElem(const uchar* from, uchar* to, size_t elemSize) { size_t i; - for( i = 0; (int)i <= (int)(elemSize - sizeof(int)); i += sizeof(int) ) + for( i = 0; i + sizeof(int) <= elemSize; i += sizeof(int) ) *(int*)(to + i) = *(const int*)(from + i); for( ; i < elemSize; i++ ) to[i] = from[i]; @@ -3505,7 +3505,7 @@ static inline void copyElem(const uchar* from, uchar* to, size_t elemSize) static inline bool isZeroElem(const uchar* data, size_t elemSize) { size_t i; - for( i = 0; i <= elemSize - sizeof(int); i += sizeof(int) ) + for( i = 0; i + sizeof(int) <= elemSize; i += sizeof(int) ) if( *(int*)(data + i) != 0 ) return false; for( ; i < elemSize; i++ ) From 7697d79d93cdcfbc81ad65f1f3560e8d60a35958 Mon Sep 17 00:00:00 2001 From: Niels Gerlif Myrtue Date: Tue, 19 Feb 2013 13:11:30 +1100 Subject: [PATCH 08/15] Added the predict_all function wrapper for python that was missing from the documentation Copied the docstring description --- modules/ml/doc/support_vector_machines.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ml/doc/support_vector_machines.rst b/modules/ml/doc/support_vector_machines.rst index bf88ec68cd..b0d23ae863 100644 --- a/modules/ml/doc/support_vector_machines.rst +++ b/modules/ml/doc/support_vector_machines.rst @@ -232,6 +232,8 @@ Predicts the response for input sample(s). .. ocv:pyfunction:: cv2.SVM.predict(sample[, returnDFVal]) -> retval +.. ocv:pyfunction:: cv2.SVM.predict_all(samples[, results]) -> results + :param sample: Input sample for prediction. :param samples: Input samples for prediction. From 0570aa64945e94f31c17dc6928edbd9407c52996 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 19 Feb 2013 10:34:43 +0400 Subject: [PATCH 09/15] Avoid problem of old sphinx reporting an error on lines starting from : See http://sourceforge.net/tracker/?func=detail&aid=3484857&group_id=38414&atid=422030 --- .../android_binary_package/android_dev_intro.rst | 6 +++--- doc/tutorials/introduction/desktop_java/java_dev_intro.rst | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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 a735bc8a7b..021561e8cb 100644 --- a/doc/tutorials/introduction/android_binary_package/android_dev_intro.rst +++ b/doc/tutorials/introduction/android_binary_package/android_dev_intro.rst @@ -210,9 +210,9 @@ You need the following software to be installed in order to develop for Android .. 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`. + 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** diff --git a/doc/tutorials/introduction/desktop_java/java_dev_intro.rst b/doc/tutorials/introduction/desktop_java/java_dev_intro.rst index 9e5e9510c3..2bb50f00ed 100644 --- a/doc/tutorials/introduction/desktop_java/java_dev_intro.rst +++ b/doc/tutorials/introduction/desktop_java/java_dev_intro.rst @@ -35,8 +35,8 @@ Starting from version 2.4.4 OpenCV includes desktop Java bindings. The most simple way to get it is downloading the appropriate package of **version 2.4.4 or higher** from the `OpenCV SourceForge repository `_. -.. note:: Windows users can find the prebuilt files needed for Java development in the - :file:`opencv/build/java/` folder inside the package. +.. note:: Windows users can find the prebuilt files needed for Java development in + the :file:`opencv/build/java/` folder inside the package. For other OSes it's required to build OpenCV from sources. Another option to get OpenCV sources is to clone `OpenCV git repository From 535f1fb2e2ed9eeb46a6edd97f57e15531b1a925 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 19 Feb 2013 10:39:31 +0400 Subject: [PATCH 10/15] Hack to stop parsing of problematic CvStatModel::train definition --- doc/ocv.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ocv.py b/doc/ocv.py index ce750933b8..3e325b7d79 100755 --- a/doc/ocv.py +++ b/doc/ocv.py @@ -992,6 +992,11 @@ class DefinitionParser(object): return rv def _parse_signature(self): + if r'CvStatModel::train' in self.definition: + # hack to skip parsing of problematic definition + self.pos = self.end + return [ArgumentDefExpr("const Mat&", "train_data", None), ArgumentDefExpr(None, self.definition[self.definition.find("["):-1], None)], False, True + self.skip_ws() if not self.skip_string('('): self.fail('expected parentheses for function') From 2bbb777d9535833123d5a9e9a1734d52d46746c1 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 19 Feb 2013 11:49:05 +0400 Subject: [PATCH 11/15] Fix warnings about missing parent for class members --- modules/video/doc/motion_analysis_and_object_tracking.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/video/doc/motion_analysis_and_object_tracking.rst b/modules/video/doc/motion_analysis_and_object_tracking.rst index 2c5dcb1a8e..5653e21bdf 100644 --- a/modules/video/doc/motion_analysis_and_object_tracking.rst +++ b/modules/video/doc/motion_analysis_and_object_tracking.rst @@ -650,9 +650,9 @@ createOptFlow_DualTVL1 .. ocv:function:: Ptr createOptFlow_DualTVL1() -The class implements the "Dual TV L1" optical flow algorithm described in [Zach2007]_ and [Javier2012]_ . + The class implements the "Dual TV L1" optical flow algorithm described in [Zach2007]_ and [Javier2012]_ . -Here are important members of the class that control the algorithm, which you can set after constructing the class instance: + Here are important members of the class that control the algorithm, which you can set after constructing the class instance: .. ocv:member:: double tau From ff7b604a250ae46ec413c86f3ede7b1314894f02 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 19 Feb 2013 12:01:27 +0400 Subject: [PATCH 12/15] Fix several inconsistent declarations identified by check_doc2 script --- modules/core/doc/basic_structures.rst | 17 +++++++++-------- .../utility_and_system_functions_and_macros.rst | 4 ++-- .../common_interfaces_of_feature_detectors.rst | 2 +- modules/gpu/doc/data_structures.rst | 6 +++--- modules/ml/doc/boosting.rst | 8 ++++---- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index 2e680229ee..054aa2ad7c 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -2064,10 +2064,11 @@ SparseMat::SparseMat Various SparseMat constructors. .. ocv:function:: SparseMat::SparseMat() -.. ocv:function:: SparseMat::SparseMat(int dims, const int* _sizes, int _type) -.. ocv:function:: SparseMat::SparseMat(const SparseMat& m) -.. ocv:function:: SparseMat::SparseMat(const Mat& m, bool try1d=false) -.. ocv:function:: SparseMat::SparseMat(const CvSparseMat* m) +.. ocv:function:: SparseMat::SparseMat( int dims, const int* _sizes, int _type ) +.. ocv:function:: SparseMat::SparseMat( const SparseMat& m ) +.. ocv:function:: SparseMat::SparseMat( const Mat& m ) +.. ocv:function:: SparseMat::SparseMat( const CvSparseMat* m ) + :param m: Source matrix for copy constructor. If m is dense matrix (ocv:class:`Mat`) then it will be converted to sparse representation. :param dims: Array dimensionality. @@ -2081,12 +2082,12 @@ SparseMat object destructor. .. ocv:function:: SparseMat::~SparseMat() -SparseMat::operator = ---------------------- +SparseMat::operator= +-------------------- Provides sparse matrix assignment operators. -.. ocv:function:: SparseMat& SparseMat::operator=(const SparseMat& m) -.. ocv:function:: SparseMat& SparseMat::operator=(const Mat& m) +.. ocv:function:: SparseMat& SparseMat::operator = (const SparseMat& m) +.. ocv:function:: SparseMat& SparseMat::operator = (const Mat& m) The last variant is equivalent to the corresponding constructor with try1d=false. diff --git a/modules/core/doc/utility_and_system_functions_and_macros.rst b/modules/core/doc/utility_and_system_functions_and_macros.rst index 9055415f13..54198b058a 100644 --- a/modules/core/doc/utility_and_system_functions_and_macros.rst +++ b/modules/core/doc/utility_and_system_functions_and_macros.rst @@ -444,9 +444,9 @@ If ``threads == 0``, OpenCV will disable threading optimizations and run all it' functions sequentially. Passing ``threads < 0`` will reset threads number to system default. This function must be called outside of parallel region. -.. ocv:function:: void setNumThreads(int threads) +.. ocv:function:: void setNumThreads(int nthreads) - :param threads: Number of threads used by OpenCV. + :param nthreads: Number of threads used by OpenCV. OpenCV will try to run it's functions with specified threads number, but some behaviour differs from framework: diff --git a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst index 8804bdeba7..81c72d3a81 100644 --- a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst +++ b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst @@ -531,7 +531,7 @@ StarAdjuster SurfAdjuster ------------ -.. ocv:class:: SurfAdjuster: public AdjusterAdapter +.. ocv:class:: SurfAdjuster : public AdjusterAdapter :ocv:class:`AdjusterAdapter` for ``SurfFeatureDetector``. :: diff --git a/modules/gpu/doc/data_structures.rst b/modules/gpu/doc/data_structures.rst index 1291cf9bb6..5699723203 100644 --- a/modules/gpu/doc/data_structures.rst +++ b/modules/gpu/doc/data_structures.rst @@ -352,9 +352,9 @@ gpu::Stream::enqueueMemSet -------------------------- Initializes or sets device memory to a value. -.. ocv:function:: void gpu::Stream::enqueueMemSet(const GpuMat& src, Scalar val) +.. ocv:function:: void gpu::Stream::enqueueMemSet( GpuMat& src, Scalar val ) -.. ocv:function:: void gpu::Stream::enqueueMemSet(const GpuMat& src, Scalar val, const GpuMat& mask) +.. ocv:function:: void gpu::Stream::enqueueMemSet( GpuMat& src, Scalar val, const GpuMat& mask ) @@ -362,7 +362,7 @@ gpu::Stream::enqueueConvert --------------------------- Converts matrix type, ex from float to uchar depending on type. -.. ocv:function:: void gpu::Stream::enqueueConvert(const GpuMat& src, GpuMat& dst, int type, double a = 1, double b = 0) +.. ocv:function:: void gpu::Stream::enqueueConvert( const GpuMat& src, GpuMat& dst, int dtype, double a=1, double b=0 ) diff --git a/modules/ml/doc/boosting.rst b/modules/ml/doc/boosting.rst index 6dd40f7350..7c5bc83fce 100644 --- a/modules/ml/doc/boosting.rst +++ b/modules/ml/doc/boosting.rst @@ -169,11 +169,11 @@ CvBoost::predict ---------------- Predicts a response for an input sample. -.. ocv:function:: float CvBoost::predict( const Mat& sample, const Mat& missing=Mat(), const Range& slice=Range::all(), bool raw_mode=false, bool return_sum=false ) const +.. ocv:function:: float CvBoost::predict( const cv::Mat& sample, const cv::Mat& missing=Mat(), const cv::Range& slice=Range::all(), bool rawMode=false, bool returnSum=false ) const .. ocv:function:: float CvBoost::predict( const CvMat* sample, const CvMat* missing=0, CvMat* weak_responses=0, CvSlice slice=CV_WHOLE_SEQ, bool raw_mode=false, bool return_sum=false ) const -.. ocv:pyfunction:: cv2.Boost.predict(sample[, missing[, slice[, raw_mode[, return_sum]]]]) -> retval +.. ocv:pyfunction:: cv2.Boost.predict(sample[, missing[, slice[, rawMode[, returnSum]]]]) -> retval :param sample: Input sample. @@ -183,9 +183,9 @@ Predicts a response for an input sample. :param slice: Continuous subset of the sequence of weak classifiers to be used for prediction. By default, all the weak classifiers are used. - :param raw_mode: Normally, it should be set to ``false``. + :param rawMode: Normally, it should be set to ``false``. - :param return_sum: If ``true`` then return sum of votes instead of the class label. + :param returnSum: If ``true`` then return sum of votes instead of the class label. The method runs the sample through the trees in the ensemble and returns the output class label based on the weighted voting. From 2fe7482b73e80c1a5221512305c7da5157e6a2e3 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 19 Feb 2013 14:19:59 +0400 Subject: [PATCH 13/15] Add support for enums into rst ocv domain --- doc/ocv.py | 56 +++++++++++++++-- .../gpu/doc/initalization_and_information.rst | 29 +++++---- modules/gpu/doc/video.rst | 63 +++++++++++-------- modules/stitching/doc/motion_estimation.rst | 14 ++--- 4 files changed, 108 insertions(+), 54 deletions(-) diff --git a/doc/ocv.py b/doc/ocv.py index 3e325b7d79..4ff8a6deb5 100755 --- a/doc/ocv.py +++ b/doc/ocv.py @@ -1080,6 +1080,17 @@ class DefinitionParser(object): value = None return MemberObjDefExpr(name, visibility, static, typename, value) + def parse_enum_member_object(self): + visibility, static = self._parse_visibility_static() + typename = None + name = self._parse_type() + self.skip_ws() + if self.skip_string('='): + value = self.read_rest().strip() + else: + value = None + return MemberObjDefExpr(name, visibility, static, typename, value) + def parse_function(self): visibility, static = self._parse_visibility_static() if self.skip_word('explicit'): @@ -1185,6 +1196,8 @@ class OCVObject(ObjectDescription): def add_target_and_index(self, sigobj, sig, signode): theid = sig#obj.get_id() theid = re.sub(r" +", " ", theid) + if self.objtype == 'emember': + theid = re.sub(r" ?=.*", "", theid) theid = re.sub(r"=[^,()]+\([^)]*?\)[^,)]*(,|\))", "\\1", theid) theid = re.sub(r"=\w*[^,)(]+(,|\))", "\\1", theid) theid = theid.replace("( ", "(").replace(" )", ")") @@ -1298,6 +1311,25 @@ class OCVTypeObject(OCVObject): signode += nodes.Text(' ') self.attach_name(signode, obj.name) +class OCVEnumObject(OCVObject): + + def get_index_text(self, name): + if self.objtype == 'enum': + return _('%s (enum)') % name + return '' + + def parse_definition(self, parser): + return parser.parse_type_object() + + def describe_signature(self, signode, obj): + self.attach_modifiers(signode, obj) + signode += addnodes.desc_annotation('enum ', 'enum ') + if obj.typename is not None: + self.attach_type(signode, obj.typename) + signode += nodes.Text(' ') + self.attach_name(signode, obj.name) + + class OCVMemberObject(OCVObject): ismember = True @@ -1314,12 +1346,20 @@ class OCVMemberObject(OCVObject): def describe_signature(self, signode, obj): self.attach_modifiers(signode, obj) - self.attach_type(signode, obj.typename) - signode += nodes.Text(' ') + if obj.typename: + self.attach_type(signode, obj.typename) + signode += nodes.Text(' ') self.attach_name(signode, obj.name) if obj.value is not None: signode += nodes.Text(u' = ' + obj.value) +class OCVEnumMemberObject(OCVMemberObject): + def parse_definition(self, parser): + # parent_class = self.env.temp_data.get('ocv:parent') + # if parent_class is None: + # parser.fail("missing parent structure/class") + return parser.parse_enum_member_object() + class OCVFunctionObject(OCVObject): def attach_function(self, node, func): @@ -1453,7 +1493,9 @@ class OCVDomain(Domain): 'pyfunction': ObjType(l_('pyfunction'), 'pyfunc'), 'pyoldfunction': ObjType(l_('pyoldfunction'), 'pyoldfunc'), 'member': ObjType(l_('member'), 'member'), - 'type': ObjType(l_('type'), 'type') + 'emember': ObjType(l_('emember'), 'emember'), + 'type': ObjType(l_('type'), 'type'), + 'enum': ObjType(l_('enum'), 'enum') } directives = { @@ -1465,7 +1507,9 @@ class OCVDomain(Domain): 'pyfunction': OCVPyModulelevel, 'pyoldfunction': OCVPyOldModulelevel, 'member': OCVMemberObject, + 'emember': OCVEnumMemberObject, 'type': OCVTypeObject, + 'enum': OCVEnumObject, 'namespace': OCVCurrentNamespace } roles = { @@ -1480,7 +1524,9 @@ class OCVDomain(Domain): 'pyfunc' : OCVPyXRefRole(), 'pyoldfunc' : OCVPyXRefRole(), 'member': OCVXRefRole(), - 'type': OCVXRefRole() + 'emember': OCVXRefRole(), + 'type': OCVXRefRole(), + 'enum': OCVXRefRole() } initial_data = { 'objects': {}, # fullname -> docname, objtype @@ -1568,7 +1614,9 @@ class OCVDomain(Domain): 'pyfunction': _('Python function'), 'pyoldfunction': _('Legacy Python function'), 'member': _('C++ member'), + 'emember': _('enum member'), 'type': _('C/C++ type'), + 'enum': _('C/C++ enum'), 'namespace': _('C++ namespace'), }.get(type.lname, _('%s %s') % (self.label, type.lname)) diff --git a/modules/gpu/doc/initalization_and_information.rst b/modules/gpu/doc/initalization_and_information.rst index ed045a3098..fc7236dcf1 100644 --- a/modules/gpu/doc/initalization_and_information.rst +++ b/modules/gpu/doc/initalization_and_information.rst @@ -47,20 +47,19 @@ Any subsequent API call to this device will reinitialize the device. gpu::FeatureSet --------------- -Enumeration providing GPU computing features. :: +Enumeration providing GPU computing features. - enum FeatureSet - { - FEATURE_SET_COMPUTE_10, - FEATURE_SET_COMPUTE_11, - FEATURE_SET_COMPUTE_12, - FEATURE_SET_COMPUTE_13, - FEATURE_SET_COMPUTE_20, - FEATURE_SET_COMPUTE_21, - GLOBAL_ATOMICS, - SHARED_ATOMICS, - NATIVE_DOUBLE - }; +.. ocv:enum:: gpu::FeatureSet + + .. ocv:emember:: FEATURE_SET_COMPUTE_10 + .. ocv:emember:: FEATURE_SET_COMPUTE_11 + .. ocv:emember:: FEATURE_SET_COMPUTE_12 + .. ocv:emember:: FEATURE_SET_COMPUTE_13 + .. ocv:emember:: FEATURE_SET_COMPUTE_20 + .. ocv:emember:: FEATURE_SET_COMPUTE_21 + .. ocv:emember:: GLOBAL_ATOMICS + .. ocv:emember:: SHARED_ATOMICS + .. ocv:emember:: NATIVE_DOUBLE gpu::TargetArchs @@ -73,7 +72,7 @@ The following method checks whether the module was built with the support of the .. ocv:function:: static bool gpu::TargetArchs::builtWith( FeatureSet feature_set ) - :param feature_set: Features to be checked. See :ocv:class:`gpu::FeatureSet`. + :param feature_set: Features to be checked. See :ocv:enum:`gpu::FeatureSet`. There is a set of methods to check whether the module contains intermediate (PTX) or binary GPU code for the given architecture(s): @@ -197,7 +196,7 @@ Provides information on GPU feature support. .. ocv:function:: bool gpu::DeviceInfo::supports( FeatureSet feature_set ) const - :param feature_set: Features to be checked. See :ocv:class:`gpu::FeatureSet`. + :param feature_set: Features to be checked. See :ocv:enum:`gpu::FeatureSet`. This function returns ``true`` if the device has the specified GPU feature. Otherwise, it returns ``false`` . diff --git a/modules/gpu/doc/video.rst b/modules/gpu/doc/video.rst index 9b17081c24..fc5b1fb6cb 100644 --- a/modules/gpu/doc/video.rst +++ b/modules/gpu/doc/video.rst @@ -985,41 +985,51 @@ Class for reading video from files. gpu::VideoReader_GPU::Codec --------------------------- -Video codecs supported by :ocv:class:`gpu::VideoReader_GPU` . :: +Video codecs supported by :ocv:class:`gpu::VideoReader_GPU` . - enum Codec - { - MPEG1 = 0, - MPEG2, - MPEG4, - VC1, - H264, - JPEG, - H264_SVC, - H264_MVC, - - Uncompressed_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), // Y,U,V (4:2:0) - Uncompressed_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,V,U (4:2:0) - Uncompressed_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,UV (4:2:0) - Uncompressed_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), // YUYV/YUY2 (4:2:2) - Uncompressed_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')), // UYVY (4:2:2) - }; +.. ocv:enum:: gpu::VideoReader_GPU::Codec + + .. ocv:emember:: MPEG1 = 0 + .. ocv:emember:: MPEG2 + .. ocv:emember:: MPEG4 + .. ocv:emember:: VC1 + .. ocv:emember:: H264 + .. ocv:emember:: JPEG + .. ocv:emember:: H264_SVC + .. ocv:emember:: H264_MVC + + .. ocv:emember:: Uncompressed_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')) + + Y,U,V (4:2:0) + + .. ocv:emember:: Uncompressed_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')) + + Y,V,U (4:2:0) + + .. ocv:emember:: Uncompressed_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')) + Y,UV (4:2:0) + + .. ocv:emember:: Uncompressed_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')) + + YUYV/YUY2 (4:2:2) + + .. ocv:emember:: Uncompressed_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) + + UYVY (4:2:2) gpu::VideoReader_GPU::ChromaFormat ---------------------------------- -Chroma formats supported by :ocv:class:`gpu::VideoReader_GPU` . :: +Chroma formats supported by :ocv:class:`gpu::VideoReader_GPU` . - enum ChromaFormat - { - Monochrome=0, - YUV420, - YUV422, - YUV444, - }; +.. ocv:enum:: gpu::VideoReader_GPU::ChromaFormat + .. ocv:emember:: Monochrome = 0 + .. ocv:emember:: YUV420 + .. ocv:emember:: YUV422 + .. ocv:emember:: YUV444 gpu::VideoReader_GPU::FormatInfo @@ -1037,7 +1047,6 @@ Struct providing information about video file format. :: }; - gpu::VideoReader_GPU::VideoReader_GPU ------------------------------------- Constructors. diff --git a/modules/stitching/doc/motion_estimation.rst b/modules/stitching/doc/motion_estimation.rst index a4cc62f001..6cda27522d 100644 --- a/modules/stitching/doc/motion_estimation.rst +++ b/modules/stitching/doc/motion_estimation.rst @@ -221,15 +221,13 @@ Implementation of the camera parameters refinement algorithm which minimizes sum detail::WaveCorrectKind ----------------------- -.. ocv:class:: detail::WaveCorrectKind +Wave correction kind. -Wave correction kind. :: +.. ocv:enum:: detail::WaveCorrectKind + + .. ocv:emember:: WAVE_CORRECT_HORIZ + .. ocv:emember:: WAVE_CORRECT_VERT - enum CV_EXPORTS WaveCorrectKind - { - WAVE_CORRECT_HORIZ, - WAVE_CORRECT_VERT - }; detail::waveCorrect ------------------- @@ -239,4 +237,4 @@ Tries to make panorama more horizontal (or vertical). :param rmats: Camera rotation matrices. - :param kind: Correction kind, see :ocv:class:`detail::WaveCorrectKind`. + :param kind: Correction kind, see :ocv:enum:`detail::WaveCorrectKind`. From 60f7b1d98d1d7c0dbdd01817b0d19b968faf2bb8 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 19 Feb 2013 15:56:34 +0400 Subject: [PATCH 14/15] Whitelist functions/structs in check_docs2 that are impossible to fix in 2.4 --- doc/check_docs2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/check_docs2.py b/doc/check_docs2.py index 0a29b50384..8092c68011 100755 --- a/doc/check_docs2.py +++ b/doc/check_docs2.py @@ -38,7 +38,7 @@ doc_signatures_whitelist = [ "CvArr", "CvFileStorage", # other "InputArray", "OutputArray", -] +] + ["CvSubdiv2D", "CvQuadEdge2D", "CvSubdiv2DPoint", "cvDrawContours"] defines = ["cvGraphEdgeIdx", "cvFree", "CV_Assert", "cvSqrt", "cvGetGraphVtx", "cvGraphVtxIdx", "cvCaptureFromFile", "cvCaptureFromCAM", "cvCalcBackProjectPatch", "cvCalcBackProject", From 96b2898f38604ef54b740e9ea7e9dc0d3c7f5ff2 Mon Sep 17 00:00:00 2001 From: Abid K Date: Tue, 19 Feb 2013 19:31:53 +0530 Subject: [PATCH 15/15] Update samples/python2/hist.py range in calcHist() changed from [0,255] to [0,256]. Otherwise, it won't count pixels with value 255. It can be verified taking sum of histogram values and checking it with image size. --- samples/python2/hist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/python2/hist.py b/samples/python2/hist.py index ea950c8326..47fdb56bb4 100755 --- a/samples/python2/hist.py +++ b/samples/python2/hist.py @@ -27,7 +27,7 @@ def hist_curve(im): elif im.shape[2] == 3: color = [ (255,0,0),(0,255,0),(0,0,255) ] for ch, col in enumerate(color): - hist_item = cv2.calcHist([im],[ch],None,[256],[0,255]) + hist_item = cv2.calcHist([im],[ch],None,[256],[0,256]) cv2.normalize(hist_item,hist_item,0,255,cv2.NORM_MINMAX) hist=np.int32(np.around(hist_item)) pts = np.int32(np.column_stack((bins,hist))) @@ -41,7 +41,7 @@ def hist_lines(im): print "hist_lines applicable only for grayscale images" #print "so converting image to grayscale for representation" im = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) - hist_item = cv2.calcHist([im],[0],None,[256],[0,255]) + hist_item = cv2.calcHist([im],[0],None,[256],[0,256]) cv2.normalize(hist_item,hist_item,0,255,cv2.NORM_MINMAX) hist=np.int32(np.around(hist_item)) for x,y in enumerate(hist):