From e59912f803c73d62ce08c3b10885a43392a17626 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Thu, 21 Nov 2013 14:07:53 +0100 Subject: [PATCH 01/27] Applied fix mentioned in bugreport 3370. Seems to solve the issue. --- apps/traincascade/imagestorage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/traincascade/imagestorage.cpp b/apps/traincascade/imagestorage.cpp index 0f749f9b01..078b0d02cb 100644 --- a/apps/traincascade/imagestorage.cpp +++ b/apps/traincascade/imagestorage.cpp @@ -67,7 +67,7 @@ bool CvCascadeImageReader::NegReader::nextImg() _offset.x = min( (int)round % winSize.width, src.cols - winSize.width ); _offset.y = min( (int)round / winSize.width, src.rows - winSize.height ); if( !src.empty() && src.type() == CV_8UC1 - && offset.x >= 0 && offset.y >= 0 ) + && _offset.x >= 0 && _offset.y >= 0 ) break; } From 3b4f65b18693b6afebc90bbc46e7f88c28d5f048 Mon Sep 17 00:00:00 2001 From: Eric Sommerlade Date: Tue, 26 Nov 2013 00:12:30 +0000 Subject: [PATCH 02/27] fixed comparison to stop integer wrap around --- modules/imgproc/src/samplers.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/imgproc/src/samplers.cpp b/modules/imgproc/src/samplers.cpp index eb2f61755c..f1c11447bd 100644 --- a/modules/imgproc/src/samplers.cpp +++ b/modules/imgproc/src/samplers.cpp @@ -97,7 +97,7 @@ icvAdjustRect( const void* srcptr, int src_step, int pix_size, rect.x = win_size.width; } - if( ip.x + win_size.width < src_size.width ) + if( ip.x < src_size.width - win_size.width ) rect.width = win_size.width; else { @@ -118,7 +118,7 @@ icvAdjustRect( const void* srcptr, int src_step, int pix_size, else rect.y = -ip.y; - if( ip.y + win_size.height < src_size.height ) + if( ip.y < src_size.height - win_size.height ) rect.height = win_size.height; else { @@ -164,8 +164,8 @@ CvStatus CV_STDCALL icvGetRectSubPix_##flavor##_C1R \ src_step /= sizeof(src[0]); \ dst_step /= sizeof(dst[0]); \ \ - if( 0 <= ip.x && ip.x + win_size.width < src_size.width && \ - 0 <= ip.y && ip.y + win_size.height < src_size.height ) \ + if( 0 <= ip.x && ip.x < src_size.width - win_size.width && \ + 0 <= ip.y && ip.y < src_size.height - win_size.height ) \ { \ /* extracted rectangle is totally inside the image */ \ src += ip.y * src_step + ip.x; \ @@ -270,8 +270,8 @@ static CvStatus CV_STDCALL icvGetRectSubPix_##flavor##_C3R \ src_step /= sizeof( src[0] ); \ dst_step /= sizeof( dst[0] ); \ \ - if( 0 <= ip.x && ip.x + win_size.width < src_size.width && \ - 0 <= ip.y && ip.y + win_size.height < src_size.height ) \ + if( 0 <= ip.x && ip.x < src_size.width - win_size.width && \ + 0 <= ip.y && ip.y < src_size.height - win_size.height ) \ { \ /* extracted rectangle is totally inside the image */ \ src += ip.y * src_step + ip.x*3; \ @@ -407,8 +407,8 @@ CvStatus CV_STDCALL icvGetRectSubPix_8u32f_C1R src_step /= sizeof(src[0]); dst_step /= sizeof(dst[0]); - if( 0 <= ip.x && ip.x + win_size.width < src_size.width && - 0 <= ip.y && ip.y + win_size.height < src_size.height ) + if( 0 <= ip.x && ip.x < src_size.width - win_size.width && + 0 <= ip.y && ip.y < src_size.height - win_size.height ) { // extracted rectangle is totally inside the image src += ip.y * src_step + ip.x; From 95ebdf4069a6333c14e4a610acc37e11cc90a0da Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 7 Nov 2013 12:16:06 +0400 Subject: [PATCH 03/27] fixed compilation with CUDA 6.0: GpuMat::setTo function, removed NPP call for CV_8S --- modules/core/src/gpumat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/gpumat.cpp b/modules/core/src/gpumat.cpp index ff459f9a61..4c4af61c47 100644 --- a/modules/core/src/gpumat.cpp +++ b/modules/core/src/gpumat.cpp @@ -1361,7 +1361,7 @@ namespace static const func_t funcs[7][4] = { {NppSet::call, cv::gpu::setTo , cv::gpu::setTo , NppSet::call}, - {NppSet::call, NppSet::call, NppSet::call, NppSet::call}, + {cv::gpu::setTo , cv::gpu::setTo , cv::gpu::setTo , cv::gpu::setTo }, {NppSet::call, NppSet::call, cv::gpu::setTo , NppSet::call}, {NppSet::call, NppSet::call, cv::gpu::setTo , NppSet::call}, {NppSet::call, cv::gpu::setTo , cv::gpu::setTo , NppSet::call}, From 9ce9fc3361decee8ac2381fc0dfcff551927ed7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9verin=20Lemaignan?= Date: Tue, 26 Nov 2013 05:53:44 +0100 Subject: [PATCH 04/27] Ensure compilation to Javascript with Emscripten --- modules/core/include/opencv2/core/operations.hpp | 6 ++++-- modules/core/src/system.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 9569d1abc0..4ab7e35f90 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -56,7 +56,7 @@ #define CV_XADD(addr,delta) _InterlockedExchangeAdd(const_cast(reinterpret_cast(addr)), delta) #elif defined __GNUC__ - #if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ + #if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ #ifdef __ATOMIC_SEQ_CST #define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST) #else @@ -66,7 +66,9 @@ #if !(defined WIN32 || defined _WIN32) && (defined __i486__ || defined __i586__ || \ defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) || \ - (defined __GNUC__ && defined _STLPORT_MAJOR) + (defined __GNUC__ && defined _STLPORT_MAJOR) || \ + defined __EMSCRIPTEN__ + #define CV_XADD __sync_fetch_and_add #else #include diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 88993630ec..88f13d622a 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -126,7 +126,7 @@ std::wstring GetTempFileNameWinRT(std::wstring prefix) #include -#if defined __linux__ || defined __APPLE__ +#if defined __linux__ || defined __APPLE__ || defined __EMSCRIPTEN__ #include #include #include From bd9d3dd561764f4e6993cd0b7b0b1aba7b27b099 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 3 Dec 2013 13:16:44 +0400 Subject: [PATCH 05/27] fixing build of 2.4 branch with VC12 (aka 2013) (master branch was fixed before, no need to merge this to master!) - disable openexr (numerous undefined std::min & std::max) - workaround for two compilator bugs --- CMakeLists.txt | 2 +- modules/features2d/src/features2d_init.cpp | 2 +- modules/features2d/src/orb.cpp | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a7c730bc0..14353dccb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ OCV_OPTION(WITH_IMAGEIO "ImageIO support for OS X" OFF OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) ) OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) ) OCV_OPTION(WITH_JPEG "Include JPEG support" ON) -OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) ) +OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS AND NOT MSVC12) ) OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT APPLE) ) OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_PNG "Include PNG support" ON) diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index ebac9cb54f..9fcbcd6c59 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -181,7 +181,7 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense", obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale)); CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid", - obj.info()->addParam(obj, "detector", obj.detector); + obj.info()->addParam(obj, "detector", (Ptr&)obj.detector); obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints); obj.info()->addParam(obj, "gridRows", obj.gridRows); obj.info()->addParam(obj, "gridCols", obj.gridCols)); diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 8aeea829a8..dd81c5f682 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -138,13 +138,16 @@ static void computeOrbDescriptor(const KeyPoint& kpt, const uchar* center = &img.at(cvRound(kpt.pt.y), cvRound(kpt.pt.x)); int step = (int)img.step; + float x, y; + int ix, iy; #if 1 #define GET_VALUE(idx) \ - center[cvRound(pattern[idx].x*b + pattern[idx].y*a)*step + \ - cvRound(pattern[idx].x*a - pattern[idx].y*b)] + (x = pattern[idx].x*a - pattern[idx].y*b, \ + y = pattern[idx].x*b + pattern[idx].y*a, \ + ix = cvRound(x), \ + iy = cvRound(y), \ + *(center + iy*step + ix) ) #else - float x, y; - int ix, iy; #define GET_VALUE(idx) \ (x = pattern[idx].x*a - pattern[idx].y*b, \ y = pattern[idx].x*b + pattern[idx].y*a, \ From 14ee306b9ec7c4dcd09014b8480d85a955c7706f Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 3 Dec 2013 15:55:10 +0400 Subject: [PATCH 06/27] fix gpu test for Demosaicing: check that input images was loaded correctly --- modules/gpu/test/test_color.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/gpu/test/test_color.cpp b/modules/gpu/test/test_color.cpp index 4bd53c9194..3f5a37fd03 100644 --- a/modules/gpu/test/test_color.cpp +++ b/modules/gpu/test/test_color.cpp @@ -2357,6 +2357,7 @@ struct Demosaicing : testing::TestWithParam GPU_TEST_P(Demosaicing, BayerBG2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 1)); @@ -2370,6 +2371,7 @@ GPU_TEST_P(Demosaicing, BayerBG2BGR) GPU_TEST_P(Demosaicing, BayerGB2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 1)); @@ -2383,6 +2385,7 @@ GPU_TEST_P(Demosaicing, BayerGB2BGR) GPU_TEST_P(Demosaicing, BayerRG2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 0)); @@ -2396,6 +2399,7 @@ GPU_TEST_P(Demosaicing, BayerRG2BGR) GPU_TEST_P(Demosaicing, BayerGR2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 0)); @@ -2409,6 +2413,7 @@ GPU_TEST_P(Demosaicing, BayerGR2BGR) GPU_TEST_P(Demosaicing, BayerBG2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 1)); @@ -2422,6 +2427,7 @@ GPU_TEST_P(Demosaicing, BayerBG2BGR_MHT) GPU_TEST_P(Demosaicing, BayerGB2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 1)); @@ -2435,6 +2441,7 @@ GPU_TEST_P(Demosaicing, BayerGB2BGR_MHT) GPU_TEST_P(Demosaicing, BayerRG2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 0)); @@ -2448,6 +2455,7 @@ GPU_TEST_P(Demosaicing, BayerRG2BGR_MHT) GPU_TEST_P(Demosaicing, BayerGR2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 0)); From adb2040980e61a4bf76675c163c0ada20809a7e2 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 3 Dec 2013 15:55:47 +0400 Subject: [PATCH 07/27] added additional check in cv::gpu::demosaicing that source is not empty --- modules/gpu/src/color.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gpu/src/color.cpp b/modules/gpu/src/color.cpp index 76793d5200..864c4755ea 100644 --- a/modules/gpu/src/color.cpp +++ b/modules/gpu/src/color.cpp @@ -1863,7 +1863,7 @@ void cv::gpu::demosaicing(const GpuMat& src, GpuMat& dst, int code, int dcn, Str { const int depth = src.depth(); - CV_Assert( src.channels() == 1 ); + CV_Assert( src.channels() == 1 && !src.empty() ); switch (code) { From c962a9d61cffbbc88a61d59449f557d3a2202258 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 3 Dec 2013 16:02:41 +0400 Subject: [PATCH 08/27] ocl:perf: fix moments test for plain impl --- modules/ocl/perf/perf_moments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ocl/perf/perf_moments.cpp b/modules/ocl/perf/perf_moments.cpp index c5d616f83d..631031ecb4 100644 --- a/modules/ocl/perf/perf_moments.cpp +++ b/modules/ocl/perf/perf_moments.cpp @@ -73,10 +73,10 @@ PERF_TEST_P(MomentsFixture, Moments, Mat src(srcSize, type), dst(7, 1, CV_64F); randu(src, 0, 255); - oclMat src_d(src); cv::Moments mom; if (RUN_OCL_IMPL) { + oclMat src_d(src); OCL_TEST_CYCLE() mom = cv::ocl::ocl_moments(src_d, binaryImage); } else if (RUN_PLAIN_IMPL) From b5dbe9e04bc69e966168a33a5f96f44b7e064502 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 3 Dec 2013 16:08:57 +0400 Subject: [PATCH 09/27] Added patch from master for fixing VS2013 in 3rd party lib OpenEXR --- 3rdparty/openexr/IlmImf/ImfAcesFile.cpp | 1 + 3rdparty/openexr/IlmImf/ImfOutputFile.cpp | 1 + .../openexr/IlmImf/ImfScanLineInputFile.cpp | 1 + 3rdparty/openexr/IlmImf/ImfTiledMisc.cpp | 1 + .../openexr/IlmImf/ImfTiledOutputFile.cpp | 1 + 3rdparty/openexr/Imath/ImathMatrixAlgo.cpp | 1 + 3rdparty/openexr/fix_msvc2013_errors.patch | 72 +++++++++++++++++++ CMakeLists.txt | 2 +- 8 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 3rdparty/openexr/fix_msvc2013_errors.patch diff --git a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp index de4bf83c6a..9418b9d2a1 100644 --- a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp @@ -42,6 +42,7 @@ #include #include #include +#include // for std::max() using namespace std; using namespace Imath; diff --git a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp index 8831ec94d1..e69b92bd57 100644 --- a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp @@ -58,6 +58,7 @@ #include #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp index f7a12a3476..5d8b52201b 100644 --- a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp @@ -56,6 +56,7 @@ #include #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp index 57f52f17f8..9588e789f6 100644 --- a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp +++ b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp @@ -43,6 +43,7 @@ #include "Iex.h" #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp index 08821060d8..0bc3cb3c30 100644 --- a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp +++ b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp @@ -63,6 +63,7 @@ #include #include #include +#include // for std::max() namespace Imf { diff --git a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp index f0d2ed679f..7ddc64968f 100644 --- a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp +++ b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp @@ -44,6 +44,7 @@ #include "ImathMatrixAlgo.h" #include +#include // for std::max() #if defined(OPENEXR_DLL) #define EXPORT_CONST __declspec(dllexport) diff --git a/3rdparty/openexr/fix_msvc2013_errors.patch b/3rdparty/openexr/fix_msvc2013_errors.patch new file mode 100644 index 0000000000..0ce106f13b --- /dev/null +++ b/3rdparty/openexr/fix_msvc2013_errors.patch @@ -0,0 +1,72 @@ +diff --git a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp +index de4bf83..9418b9d 100644 +--- a/3rdparty/openexr/IlmImf/ImfAcesFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfAcesFile.cpp +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include // for std::max() + + using namespace std; + using namespace Imath; +diff --git a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp +index 8831ec9..e69b92b 100644 +--- a/3rdparty/openexr/IlmImf/ImfOutputFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfOutputFile.cpp +@@ -58,6 +58,7 @@ + #include + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp +index f7a12a3..5d8b522 100644 +--- a/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfScanLineInputFile.cpp +@@ -56,6 +56,7 @@ + #include + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp +index 57f52f1..9588e78 100644 +--- a/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp ++++ b/3rdparty/openexr/IlmImf/ImfTiledMisc.cpp +@@ -43,6 +43,7 @@ + #include "Iex.h" + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp +index 0882106..0bc3cb3 100644 +--- a/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp ++++ b/3rdparty/openexr/IlmImf/ImfTiledOutputFile.cpp +@@ -63,6 +63,7 @@ + #include + #include + #include ++#include // for std::max() + + + namespace Imf { +diff --git a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp +index f0d2ed6..7ddc649 100644 +--- a/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp ++++ b/3rdparty/openexr/Imath/ImathMatrixAlgo.cpp +@@ -44,6 +44,7 @@ + + #include "ImathMatrixAlgo.h" + #include ++#include // for std::max() + + #if defined(OPENEXR_DLL) + #define EXPORT_CONST __declspec(dllexport) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14353dccb6..2a7c730bc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ OCV_OPTION(WITH_IMAGEIO "ImageIO support for OS X" OFF OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) ) OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) ) OCV_OPTION(WITH_JPEG "Include JPEG support" ON) -OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS AND NOT MSVC12) ) +OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) ) OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT APPLE) ) OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_PNG "Include PNG support" ON) From 2b3105591446cabbf13a1bc7ac26b1f6ca397af9 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 3 Dec 2013 17:33:28 +0400 Subject: [PATCH 10/27] Fixed the "platfrom" typo everywhere. --- .../arm_crosscompile_with_cmake.rst | 2 +- .../engine/jni/NativeService/PackageInfo.cpp | 4 ++-- .../engine/jni/Tests/HardwareDetectionTest.cpp | 2 +- .../org/opencv/engine/manager/ManagerActivity.java | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst b/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst index c40b86c974..0b2253acea 100644 --- a/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst +++ b/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst @@ -105,7 +105,7 @@ Building OpenCV Enable hardware optimizations ----------------------------- -Depending on target platfrom architecture different instruction sets can be used. By default +Depending on target platform architecture different instruction sets can be used. By default compiler generates code for armv5l without VFPv3 and NEON extensions. Add ``-DUSE_VFPV3=ON`` to cmake command line to enable code generation for VFPv3 and ``-DUSE_NEON=ON`` for using NEON SIMD extensions. diff --git a/platforms/android/service/engine/jni/NativeService/PackageInfo.cpp b/platforms/android/service/engine/jni/NativeService/PackageInfo.cpp index 64ea70dae8..98ea828747 100644 --- a/platforms/android/service/engine/jni/NativeService/PackageInfo.cpp +++ b/platforms/android/service/engine/jni/NativeService/PackageInfo.cpp @@ -170,7 +170,7 @@ inline string JoinPlatform(int platform) return result; } -inline int SplitPlatfrom(const vector& features) +inline int SplitPlatform(const vector& features) { int result = 0; @@ -419,7 +419,7 @@ InstallPath(install_path) return; } - Platform = SplitPlatfrom(features); + Platform = SplitPlatform(features); if (PLATFORM_UNKNOWN != Platform) { switch (Platform) diff --git a/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp b/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp index 8637dfee30..83dd9c27e1 100644 --- a/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp +++ b/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp @@ -170,7 +170,7 @@ TEST(CpuID, CheckVFPv3) EXPECT_TRUE(cpu_id & FEATURES_HAS_VFPv3); } -TEST(PlatfromDetector, CheckTegra) +TEST(PlatformDetector, CheckTegra) { EXPECT_NE(PLATFORM_UNKNOWN, DetectKnownPlatforms()); } diff --git a/platforms/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java b/platforms/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java index 4e9050fa4d..8e8389dcc7 100644 --- a/platforms/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java +++ b/platforms/android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java @@ -90,28 +90,28 @@ public class ManagerActivity extends Activity mInstalledPackageView.setAdapter(mInstalledPacksAdapter); TextView HardwarePlatformView = (TextView)findViewById(R.id.HardwareValue); - int Platfrom = HardwareDetector.DetectKnownPlatforms(); + int Platform = HardwareDetector.DetectKnownPlatforms(); int CpuId = HardwareDetector.GetCpuID(); - if (HardwareDetector.PLATFORM_UNKNOWN != Platfrom) + if (HardwareDetector.PLATFORM_UNKNOWN != Platform) { - if (HardwareDetector.PLATFORM_TEGRA == Platfrom) + if (HardwareDetector.PLATFORM_TEGRA == Platform) { HardwarePlatformView.setText("Tegra"); } - else if (HardwareDetector.PLATFORM_TEGRA2 == Platfrom) + else if (HardwareDetector.PLATFORM_TEGRA2 == Platform) { HardwarePlatformView.setText("Tegra 2"); } - else if (HardwareDetector.PLATFORM_TEGRA3 == Platfrom) + else if (HardwareDetector.PLATFORM_TEGRA3 == Platform) { HardwarePlatformView.setText("Tegra 3"); } - else if (HardwareDetector.PLATFORM_TEGRA4i == Platfrom) + else if (HardwareDetector.PLATFORM_TEGRA4i == Platform) { HardwarePlatformView.setText("Tegra 4i"); } - else if (HardwareDetector.PLATFORM_TEGRA4 == Platfrom) + else if (HardwareDetector.PLATFORM_TEGRA4 == Platform) { HardwarePlatformView.setText("Tegra 4"); } From 1966e7cea9d6dd38db39f29f53b4ca96d56ce2d1 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 3 Dec 2013 17:46:09 +0400 Subject: [PATCH 11/27] fixing compilation on Linux --- modules/features2d/src/features2d_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index 9fcbcd6c59..13ef0f8ae5 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -181,7 +181,7 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense", obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale)); CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid", - obj.info()->addParam(obj, "detector", (Ptr&)obj.detector); + obj.info()->addParam(obj, "detector", obj.detector, false, 0, 0); // Extra params added to avoid VS2013 fatal error in opencv2/core.hpp (decl. of addParam) obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints); obj.info()->addParam(obj, "gridRows", obj.gridRows); obj.info()->addParam(obj, "gridCols", obj.gridCols)); From 11c7053b0f81ad31474b236205ca9fab177f75fc Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 4 Dec 2013 12:39:20 +0400 Subject: [PATCH 12/27] Fixed a -Wundef warning in cl_platform.h. _MSC_VER -> defined _MSC_VER. Fixes building with MinGW. Similar to fbc91c5ee. --- 3rdparty/include/opencl/1.2/CL/cl_platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/include/opencl/1.2/CL/cl_platform.h b/3rdparty/include/opencl/1.2/CL/cl_platform.h index 46b3d9dcdc..e94949a31c 100644 --- a/3rdparty/include/opencl/1.2/CL/cl_platform.h +++ b/3rdparty/include/opencl/1.2/CL/cl_platform.h @@ -454,7 +454,7 @@ typedef unsigned int cl_GLenum; /* Define alignment keys */ #if defined( __GNUC__ ) #define CL_ALIGNED(_x) __attribute__ ((aligned(_x))) -#elif defined( _WIN32) && (_MSC_VER) +#elif defined( _WIN32) && defined(_MSC_VER) /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */ /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */ /* #include */ From 7b551af424b9daf576d52190fcbca64c88108e31 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 4 Dec 2013 13:00:37 +0400 Subject: [PATCH 13/27] ocl: try to disable clFinish workaround --- modules/ocl/src/cl_operations.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ocl/src/cl_operations.cpp b/modules/ocl/src/cl_operations.cpp index 032ebe82a4..0b934074d8 100644 --- a/modules/ocl/src/cl_operations.cpp +++ b/modules/ocl/src/cl_operations.cpp @@ -290,8 +290,9 @@ void openCLFree(void *devPtr) } #else // TODO FIXIT Attach clReleaseMemObject call to event completion callback - Context* ctx = Context::getContext(); - clFinish(getClCommandQueue(ctx)); + // TODO 2013/12/04 Disable workaround + // Context* ctx = Context::getContext(); + // clFinish(getClCommandQueue(ctx)); #endif openCLSafeCall(clReleaseMemObject(data.mainBuffer)); } From 00300baa53a6f57c8f5c2c52c7e32d6077802417 Mon Sep 17 00:00:00 2001 From: Baichuan Su Date: Sat, 9 Nov 2013 08:42:39 +0800 Subject: [PATCH 14/27] Add OpenCL SVM paths for bagofwords_classification and points_classifier samples. --- samples/cpp/CMakeLists.txt | 8 +++++++ samples/cpp/bagofwords_classification.cpp | 20 +++++++++++++++++ samples/cpp/points_classifier.cpp | 27 ++++++++++++++++++++++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 4eabd09f0b..ebee5bd0a8 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -20,6 +20,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") endif() + if(HAVE_opencv_ocl) + ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/ocl/include") + endif() + if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") endif() @@ -47,6 +51,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) target_link_libraries(${the_target} opencv_gpu) endif() + if(HAVE_opencv_ocl) + target_link_libraries(${the_target} opencv_ocl) + endif() + set_target_properties(${the_target} PROPERTIES OUTPUT_NAME "cpp-${sample_kind}-${name}" PROJECT_LABEL "(${sample_KIND}) ${name}") diff --git a/samples/cpp/bagofwords_classification.cpp b/samples/cpp/bagofwords_classification.cpp index 39342c4d32..9749b4a2f0 100644 --- a/samples/cpp/bagofwords_classification.cpp +++ b/samples/cpp/bagofwords_classification.cpp @@ -1,8 +1,12 @@ +#include "opencv2/opencv_modules.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/features2d/features2d.hpp" #include "opencv2/nonfree/nonfree.hpp" #include "opencv2/ml/ml.hpp" +#ifdef HAVE_OPENCV_OCL +#include "opencv2/ocl/ocl.hpp" +#endif #include #include @@ -2373,9 +2377,15 @@ static void setSVMTrainAutoParams( CvParamGrid& c_grid, CvParamGrid& gamma_grid, degree_grid.step = 0; } +#ifdef HAVE_OPENCV_OCL +static void trainSVMClassifier( cv::ocl::CvSVM_OCL& svm, const SVMTrainParamsExt& svmParamsExt, const string& objClassName, VocData& vocData, + Ptr& bowExtractor, const Ptr& fdetector, + const string& resPath ) +#else static void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsExt, const string& objClassName, VocData& vocData, Ptr& bowExtractor, const Ptr& fdetector, const string& resPath ) +#endif { /* first check if a previously trained svm for the current class has been saved to file */ string svmFilename = resPath + svmsDir + "/" + objClassName + ".xml.gz"; @@ -2448,9 +2458,15 @@ static void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsEx } } +#ifdef HAVE_OPENCV_OCL +static void computeConfidences( cv::ocl::CvSVM_OCL& svm, const string& objClassName, VocData& vocData, + Ptr& bowExtractor, const Ptr& fdetector, + const string& resPath ) +#else static void computeConfidences( CvSVM& svm, const string& objClassName, VocData& vocData, Ptr& bowExtractor, const Ptr& fdetector, const string& resPath ) +#endif { cout << "*** CALCULATING CONFIDENCES FOR CLASS " << objClassName << " ***" << endl; cout << "CALCULATING BOW VECTORS FOR TEST SET OF " << objClassName << "..." << endl; @@ -2589,7 +2605,11 @@ int main(int argc, char** argv) for( size_t classIdx = 0; classIdx < objClasses.size(); ++classIdx ) { // Train a classifier on train dataset +#ifdef HAVE_OPENCV_OCL + cv::ocl::CvSVM_OCL svm; +#else CvSVM svm; +#endif trainSVMClassifier( svm, svmTrainParamsExt, objClasses[classIdx], vocData, bowExtractor, featureDetector, resPath ); diff --git a/samples/cpp/points_classifier.cpp b/samples/cpp/points_classifier.cpp index e23b2768a9..ca6c0c6817 100644 --- a/samples/cpp/points_classifier.cpp +++ b/samples/cpp/points_classifier.cpp @@ -1,6 +1,10 @@ +#include "opencv2/opencv_modules.hpp" #include "opencv2/core/core.hpp" #include "opencv2/ml/ml.hpp" #include "opencv2/highgui/highgui.hpp" +#ifdef HAVE_OPENCV_OCL +#include "opencv2/ocl/ocl.hpp" +#endif #include @@ -133,7 +137,14 @@ static void find_decision_boundary_KNN( int K ) prepare_train_data( trainSamples, trainClasses ); // learn classifier +#ifdef HAVE_OPENCV_OCL + cv::ocl::KNearestNeighbour knnClassifier; + Mat temp, result; + knnClassifier.train(trainSamples, trainClasses, temp, false, K); + cv::ocl::oclMat testSample_ocl, reslut_ocl; +#else CvKNearest knnClassifier( trainSamples, trainClasses, Mat(), false, K ); +#endif Mat testSample( 1, 2, CV_32FC1 ); for( int y = 0; y < img.rows; y += testStep ) @@ -142,9 +153,19 @@ static void find_decision_boundary_KNN( int K ) { testSample.at(0) = (float)x; testSample.at(1) = (float)y; +#ifdef HAVE_OPENCV_OCL + testSample_ocl.upload(testSample); + + knnClassifier.find_nearest(testSample_ocl, K, reslut_ocl); + + reslut_ocl.download(result); + int response = saturate_cast(result.at(0)); + circle(imgDst, Point(x, y), 1, classColors[response]); +#else int response = (int)knnClassifier.find_nearest( testSample, K ); circle( imgDst, Point(x,y), 1, classColors[response] ); +#endif } } } @@ -159,7 +180,11 @@ static void find_decision_boundary_SVM( CvSVMParams params ) prepare_train_data( trainSamples, trainClasses ); // learn classifier +#ifdef HAVE_OPENCV_OCL + cv::ocl::CvSVM_OCL svmClassifier(trainSamples, trainClasses, Mat(), Mat(), params); +#else CvSVM svmClassifier( trainSamples, trainClasses, Mat(), Mat(), params ); +#endif Mat testSample( 1, 2, CV_32FC1 ); for( int y = 0; y < img.rows; y += testStep ) @@ -178,7 +203,7 @@ static void find_decision_boundary_SVM( CvSVMParams params ) for( int i = 0; i < svmClassifier.get_support_vector_count(); i++ ) { const float* supportVector = svmClassifier.get_support_vector(i); - circle( imgDst, Point(supportVector[0],supportVector[1]), 5, Scalar(255,255,255), -1 ); + circle( imgDst, Point(saturate_cast(supportVector[0]),saturate_cast(supportVector[1])), 5, CV_RGB(255,255,255), -1 ); } } From 2cf16db683add5c9a4775bf17c76b6e55abcd8ee Mon Sep 17 00:00:00 2001 From: Baichuan Su Date: Mon, 11 Nov 2013 11:46:07 +0800 Subject: [PATCH 15/27] Add Macro to decide using ocl method or not. --- samples/cpp/bagofwords_classification.cpp | 7 ++++--- samples/cpp/points_classifier.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/samples/cpp/bagofwords_classification.cpp b/samples/cpp/bagofwords_classification.cpp index 9749b4a2f0..fbb312f930 100644 --- a/samples/cpp/bagofwords_classification.cpp +++ b/samples/cpp/bagofwords_classification.cpp @@ -5,6 +5,7 @@ #include "opencv2/nonfree/nonfree.hpp" #include "opencv2/ml/ml.hpp" #ifdef HAVE_OPENCV_OCL +#define _OCL_SVM_ 0 //select whether using ocl::svm method or not, default is not #include "opencv2/ocl/ocl.hpp" #endif @@ -2377,7 +2378,7 @@ static void setSVMTrainAutoParams( CvParamGrid& c_grid, CvParamGrid& gamma_grid, degree_grid.step = 0; } -#ifdef HAVE_OPENCV_OCL +#if defined HAVE_OPENCV_OCL && _OCL_SVM_ static void trainSVMClassifier( cv::ocl::CvSVM_OCL& svm, const SVMTrainParamsExt& svmParamsExt, const string& objClassName, VocData& vocData, Ptr& bowExtractor, const Ptr& fdetector, const string& resPath ) @@ -2458,7 +2459,7 @@ static void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsEx } } -#ifdef HAVE_OPENCV_OCL +#if defined HAVE_OPENCV_OCL && _OCL_SVM_ static void computeConfidences( cv::ocl::CvSVM_OCL& svm, const string& objClassName, VocData& vocData, Ptr& bowExtractor, const Ptr& fdetector, const string& resPath ) @@ -2605,7 +2606,7 @@ int main(int argc, char** argv) for( size_t classIdx = 0; classIdx < objClasses.size(); ++classIdx ) { // Train a classifier on train dataset -#ifdef HAVE_OPENCV_OCL +#if defined HAVE_OPENCV_OCL && _OCL_SVM_ cv::ocl::CvSVM_OCL svm; #else CvSVM svm; diff --git a/samples/cpp/points_classifier.cpp b/samples/cpp/points_classifier.cpp index ca6c0c6817..b0dc0357c9 100644 --- a/samples/cpp/points_classifier.cpp +++ b/samples/cpp/points_classifier.cpp @@ -3,6 +3,8 @@ #include "opencv2/ml/ml.hpp" #include "opencv2/highgui/highgui.hpp" #ifdef HAVE_OPENCV_OCL +#define _OCL_KNN_ 0 // select whether using ocl::KNN method or not, default is not +#define _OCL_SVM_ 0 // select whether using ocl::svm method or not, default is not #include "opencv2/ocl/ocl.hpp" #endif @@ -137,7 +139,7 @@ static void find_decision_boundary_KNN( int K ) prepare_train_data( trainSamples, trainClasses ); // learn classifier -#ifdef HAVE_OPENCV_OCL +#if defined HAVE_OPENCV_OCL && _OCL_KNN_ cv::ocl::KNearestNeighbour knnClassifier; Mat temp, result; knnClassifier.train(trainSamples, trainClasses, temp, false, K); @@ -153,7 +155,7 @@ static void find_decision_boundary_KNN( int K ) { testSample.at(0) = (float)x; testSample.at(1) = (float)y; -#ifdef HAVE_OPENCV_OCL +#if defined HAVE_OPENCV_OCL && _OCL_KNN_ testSample_ocl.upload(testSample); knnClassifier.find_nearest(testSample_ocl, K, reslut_ocl); @@ -180,7 +182,7 @@ static void find_decision_boundary_SVM( CvSVMParams params ) prepare_train_data( trainSamples, trainClasses ); // learn classifier -#ifdef HAVE_OPENCV_OCL +#if defined HAVE_OPENCV_OCL && _OCL_SVM_ cv::ocl::CvSVM_OCL svmClassifier(trainSamples, trainClasses, Mat(), Mat(), params); #else CvSVM svmClassifier( trainSamples, trainClasses, Mat(), Mat(), params ); From 632b21e090a18e3ff8c06ce660f18431e7947719 Mon Sep 17 00:00:00 2001 From: Baichuan Su Date: Tue, 12 Nov 2013 13:13:25 +0800 Subject: [PATCH 16/27] Modify default setting, using ocl method when have ocl module --- samples/cpp/bagofwords_classification.cpp | 2 +- samples/cpp/points_classifier.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/cpp/bagofwords_classification.cpp b/samples/cpp/bagofwords_classification.cpp index fbb312f930..db194b536c 100644 --- a/samples/cpp/bagofwords_classification.cpp +++ b/samples/cpp/bagofwords_classification.cpp @@ -5,7 +5,7 @@ #include "opencv2/nonfree/nonfree.hpp" #include "opencv2/ml/ml.hpp" #ifdef HAVE_OPENCV_OCL -#define _OCL_SVM_ 0 //select whether using ocl::svm method or not, default is not +#define _OCL_SVM_ 1 //select whether using ocl::svm method or not, default is using #include "opencv2/ocl/ocl.hpp" #endif diff --git a/samples/cpp/points_classifier.cpp b/samples/cpp/points_classifier.cpp index b0dc0357c9..b7e890d17b 100644 --- a/samples/cpp/points_classifier.cpp +++ b/samples/cpp/points_classifier.cpp @@ -3,8 +3,8 @@ #include "opencv2/ml/ml.hpp" #include "opencv2/highgui/highgui.hpp" #ifdef HAVE_OPENCV_OCL -#define _OCL_KNN_ 0 // select whether using ocl::KNN method or not, default is not -#define _OCL_SVM_ 0 // select whether using ocl::svm method or not, default is not +#define _OCL_KNN_ 1 // select whether using ocl::KNN method or not, default is using +#define _OCL_SVM_ 1 // select whether using ocl::svm method or not, default is using #include "opencv2/ocl/ocl.hpp" #endif From 2153453fd1f925ef029bc62e1c8f6116736d93e2 Mon Sep 17 00:00:00 2001 From: Josep Bosch Date: Wed, 4 Dec 2013 22:32:20 +0100 Subject: [PATCH 17/27] Fixed little issue with mouse callback refering to issue 3409. Was using round instead of floor. --- modules/highgui/src/window_gtk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/highgui/src/window_gtk.cpp b/modules/highgui/src/window_gtk.cpp index 3ee3d0c480..46ac61bfb9 100644 --- a/modules/highgui/src/window_gtk.cpp +++ b/modules/highgui/src/window_gtk.cpp @@ -1558,9 +1558,9 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da // image origin is not necessarily at (0,0) int x0 = (widget->allocation.width - image_widget->scaled_image->cols)/2; int y0 = (widget->allocation.height - image_widget->scaled_image->rows)/2; - pt.x = cvRound( ((pt32f.x-x0)*image_widget->original_image->cols)/ + pt.x = cvFloor( ((pt32f.x-x0)*image_widget->original_image->cols)/ image_widget->scaled_image->cols ); - pt.y = cvRound( ((pt32f.y-y0)*image_widget->original_image->rows)/ + pt.y = cvFloor( ((pt32f.y-y0)*image_widget->original_image->rows)/ image_widget->scaled_image->rows ); } else{ From 6ce03b04842292ce507a49ed435d50b2e20c5f2c Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Tue, 3 Dec 2013 10:49:51 +0800 Subject: [PATCH 18/27] Fixed some implicitly type conversions between vector and scalar data type. There are some mixed implicitly/explicitly type conversion between scalar and vector. Although the spec allows those conversion, I prefer to make them consistent and use explicitly all the cases. Signed-off-by: Zhigang Gong --- modules/ocl/src/opencl/imgproc_threshold.cl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ocl/src/opencl/imgproc_threshold.cl b/modules/ocl/src/opencl/imgproc_threshold.cl index 63e410297b..85631be368 100644 --- a/modules/ocl/src/opencl/imgproc_threshold.cl +++ b/modules/ocl/src/opencl/imgproc_threshold.cl @@ -74,11 +74,11 @@ __kernel void threshold(__global const T * restrict src, int src_offset, int src VT vthresh = (VT)(thresh); #ifdef THRESH_BINARY - VT vecValue = sdata > vthresh ? max_val : (VT)(0); + VT vecValue = sdata > vthresh ? (VT)max_val : (VT)(0); #elif defined THRESH_BINARY_INV - VT vecValue = sdata > vthresh ? (VT)(0) : max_val; + VT vecValue = sdata > vthresh ? (VT)(0) : (VT)max_val; #elif defined THRESH_TRUNC - VT vecValue = sdata > vthresh ? thresh : sdata; + VT vecValue = sdata > vthresh ? (VT)thresh : sdata; #elif defined THRESH_TOZERO VT vecValue = sdata > vthresh ? sdata : (VT)(0); #elif defined THRESH_TOZERO_INV From e38ba1999b9de2931739cd0e0bc5838f8c2039fb Mon Sep 17 00:00:00 2001 From: Konstantin Matskevich Date: Fri, 22 Nov 2013 14:47:58 +0400 Subject: [PATCH 19/27] facedetect --- samples/ocl/facedetect.cpp | 139 ++++++++++++++++++++++++++++++++++++- 1 file changed, 138 insertions(+), 1 deletion(-) diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 10c6c4f4d2..7e760dacc8 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -9,6 +9,118 @@ using namespace std; using namespace cv; #define LOOP_NUM 10 +///////////////////////////////////////detectfaces with multithreading//////////////////////////////////////////// +#define MAX_THREADS 8 + +#if defined _WIN32|| defined _WIN64 + #include + #include + HANDLE handleThreads[MAX_THREADS]; +#endif + +#if defined __linux__ || defined __APPLE__ + #include + #include +#endif + +using namespace cv; + +#if defined _WIN32|| defined _WIN64 + void detectFaces(void* str) +#elif defined __linux__ || defined __APPLE__ + void* detectFaces(void* str) +#endif +{ + std::string fileName = *(std::string*)str; + ocl::OclCascadeClassifier cascade; + cascade.load("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml" );//path to haarcascade_frontalface_alt.xml + Mat img = imread(fileName, CV_LOAD_IMAGE_COLOR); + if (img.empty()) + { + std::cout << "cann't open file " + fileName < oclfaces; + cascade.detectMultiScale(d_img, oclfaces, 1.1, 3, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30), Size(0, 0)); + + for(int i = 0; irun(); + } + int idx; + std::string fileName; +protected: + Thread():thread(NULL){} +}; + +class Thread_Win : public Thread +{ +private: + friend class Thread; + Thread_Win(){} +public: + ~Thread_Win(){}; + void run() + { +#if defined _WIN32|| defined _WIN64 + handleThreads[idx] = (HANDLE)_beginthread(detectFaces, 0, (void*)&fileName); + WaitForMultipleObjects(MAX_THREADS, handleThreads, TRUE, INFINITE); +#endif + } +}; + +class Thread_Lin : public Thread +{ + private: + friend class Thread; + Thread_Lin(){} +public: + ~Thread_Lin(){}; + void run() + { +#if defined __linux__ || defined __APPLE__ + pthread_t thread; + pthread_create(&thread, NULL, detectFaces, (void*)&fileName); + pthread_join (thread, NULL); +#endif + } +}; + +Thread::Thread(int _idx, std::string _fileName) +{ +#if defined _WIN32|| defined _WIN64 + thread = new Thread_Win(); +#endif +#if defined __linux__ || defined __APPLE__ + thread = new Thread_Lin(); +#endif + thread->idx = _idx; + thread->fileName = _fileName; +} + +///////////////////////////simple-threading faces detecting/////////////////////////////// + const static Scalar colors[] = { CV_RGB(0,0,255), CV_RGB(0,128,255), CV_RGB(0,255,255), @@ -58,7 +170,7 @@ static void Draw(Mat& img, vector& faces, double scale); // Else if will return (total diff of each cpu and gpu rects covered pixels)/(total cpu rects covered pixels) double checkRectSimilarity(Size sz, vector& cpu_rst, vector& gpu_rst); -int main( int argc, const char** argv ) +int facedetect_one_thread(int argc, const char** argv ) { const char* keys = "{ h | help | false | print help message }" @@ -176,9 +288,34 @@ int main( int argc, const char** argv ) } cvDestroyWindow("result"); + std::cout<< "simple-threading sample was finished" < threads; + for(int i = 0; irun(); + } + for(int i = 0; i& faces, ocl::OclCascadeClassifier& cascade, double scale, bool calTime) From 0a1ff0d42de3b9b40d5c153a6795e04f9a9da469 Mon Sep 17 00:00:00 2001 From: Konstantin Matskevich Date: Mon, 2 Dec 2013 11:15:46 +0400 Subject: [PATCH 20/27] multithreading facedetector --- samples/ocl/facedetect.cpp | 242 ++++++++++++++----------------------- 1 file changed, 89 insertions(+), 153 deletions(-) diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 7e760dacc8..0f452b945f 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -5,121 +5,15 @@ #include #include -using namespace std; -using namespace cv; -#define LOOP_NUM 10 - -///////////////////////////////////////detectfaces with multithreading//////////////////////////////////////////// -#define MAX_THREADS 8 - -#if defined _WIN32|| defined _WIN64 - #include - #include - HANDLE handleThreads[MAX_THREADS]; -#endif - -#if defined __linux__ || defined __APPLE__ - #include - #include +#if defined(_MSC_VER) && (_MSC_VER >= 1700) + # include #endif +using namespace std; using namespace cv; +#define LOOP_NUM 10 -#if defined _WIN32|| defined _WIN64 - void detectFaces(void* str) -#elif defined __linux__ || defined __APPLE__ - void* detectFaces(void* str) -#endif -{ - std::string fileName = *(std::string*)str; - ocl::OclCascadeClassifier cascade; - cascade.load("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml" );//path to haarcascade_frontalface_alt.xml - Mat img = imread(fileName, CV_LOAD_IMAGE_COLOR); - if (img.empty()) - { - std::cout << "cann't open file " + fileName < oclfaces; - cascade.detectMultiScale(d_img, oclfaces, 1.1, 3, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30), Size(0, 0)); - - for(int i = 0; irun(); - } - int idx; - std::string fileName; -protected: - Thread():thread(NULL){} -}; - -class Thread_Win : public Thread -{ -private: - friend class Thread; - Thread_Win(){} -public: - ~Thread_Win(){}; - void run() - { -#if defined _WIN32|| defined _WIN64 - handleThreads[idx] = (HANDLE)_beginthread(detectFaces, 0, (void*)&fileName); - WaitForMultipleObjects(MAX_THREADS, handleThreads, TRUE, INFINITE); -#endif - } -}; - -class Thread_Lin : public Thread -{ - private: - friend class Thread; - Thread_Lin(){} -public: - ~Thread_Lin(){}; - void run() - { -#if defined __linux__ || defined __APPLE__ - pthread_t thread; - pthread_create(&thread, NULL, detectFaces, (void*)&fileName); - pthread_join (thread, NULL); -#endif - } -}; - -Thread::Thread(int _idx, std::string _fileName) -{ -#if defined _WIN32|| defined _WIN64 - thread = new Thread_Win(); -#endif -#if defined __linux__ || defined __APPLE__ - thread = new Thread_Lin(); -#endif - thread->idx = _idx; - thread->fileName = _fileName; -} - -///////////////////////////simple-threading faces detecting/////////////////////////////// +///////////////////////////single-threading faces detecting/////////////////////////////// const static Scalar colors[] = { CV_RGB(0,0,255), CV_RGB(0,128,255), @@ -134,7 +28,7 @@ const static Scalar colors[] = { CV_RGB(0,0,255), int64 work_begin = 0; int64 work_end = 0; -string outputName; +string inputName, outputName, cascadeName; static void workBegin() { @@ -170,35 +64,11 @@ static void Draw(Mat& img, vector& faces, double scale); // Else if will return (total diff of each cpu and gpu rects covered pixels)/(total cpu rects covered pixels) double checkRectSimilarity(Size sz, vector& cpu_rst, vector& gpu_rst); -int facedetect_one_thread(int argc, const char** argv ) +static int facedetect_one_thread(bool useCPU, double scale ) { - const char* keys = - "{ h | help | false | print help message }" - "{ i | input | | specify input image }" - "{ t | template | haarcascade_frontalface_alt.xml |" - " specify template file path }" - "{ c | scale | 1.0 | scale image }" - "{ s | use_cpu | false | use cpu or gpu to process the image }" - "{ o | output | facedetect_output.jpg |" - " specify output image save path(only works when input is images) }"; - - CommandLineParser cmd(argc, argv, keys); - if (cmd.get("help")) - { - cout << "Usage : facedetect [options]" << endl; - cout << "Available options:" << endl; - cmd.printParams(); - return EXIT_SUCCESS; - } - CvCapture* capture = 0; Mat frame, frameCopy, image; - bool useCPU = cmd.get("s"); - string inputName = cmd.get("i"); - outputName = cmd.get("o"); - string cascadeName = cmd.get("t"); - double scale = cmd.get("c"); ocl::OclCascadeClassifier cascade; CascadeClassifier cpu_cascade; @@ -288,32 +158,98 @@ int facedetect_one_thread(int argc, const char** argv ) } cvDestroyWindow("result"); - std::cout<< "simple-threading sample was finished" <= 1700) + +#define MAX_THREADS 10 + +static void detectFaces(std::string fileName) { - std::vector threads; - for(int i = 0; irun(); - } - for(int i = 0; i oclfaces; + cascade.detectMultiScale(d_img, oclfaces, 1.1, 3, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30), Size(0, 0)); + + for(unsigned int i = 0; i threads; + for(int i = 0; i= 1 }"; + + CommandLineParser cmd(argc, argv, keys); + if (cmd.get("help")) + { + cout << "Usage : facedetect [options]" << endl; + cout << "Available options:" << endl; + cmd.printParams(); + return EXIT_SUCCESS; + } + bool useCPU = cmd.get("s"); + inputName = cmd.get("i"); + outputName = cmd.get("o"); + cascadeName = cmd.get("t"); + double scale = cmd.get("c"); + int n = cmd.get("n"); + + if(n > 1) + { +#if defined(_MSC_VER) && (_MSC_VER >= 1700) + std::cout<<"multi-threaded sample is running" <& faces, From 3dcddad88aa13b729313939648c29f420a9f8054 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 5 Dec 2013 13:52:26 +0400 Subject: [PATCH 21/27] ocl: added workaround into Haar kernels --- modules/ocl/src/opencl/haarobjectdetect.cl | 86 ++++++++------- .../src/opencl/haarobjectdetect_scaled2.cl | 101 +++++++++--------- 2 files changed, 100 insertions(+), 87 deletions(-) diff --git a/modules/ocl/src/opencl/haarobjectdetect.cl b/modules/ocl/src/opencl/haarobjectdetect.cl index a62b3af8cb..980e85dd27 100644 --- a/modules/ocl/src/opencl/haarobjectdetect.cl +++ b/modules/ocl/src/opencl/haarobjectdetect.cl @@ -62,13 +62,13 @@ typedef struct __attribute__((aligned (128) )) GpuHidHaarTreeNode GpuHidHaarTreeNode; -typedef struct __attribute__((aligned (32))) GpuHidHaarClassifier -{ - int count __attribute__((aligned (4))); - GpuHidHaarTreeNode* node __attribute__((aligned (8))); - float* alpha __attribute__((aligned (8))); -} -GpuHidHaarClassifier; +//typedef struct __attribute__((aligned (32))) GpuHidHaarClassifier +//{ +// int count __attribute__((aligned (4))); +// GpuHidHaarTreeNode* node __attribute__((aligned (8))); +// float* alpha __attribute__((aligned (8))); +//} +//GpuHidHaarClassifier; typedef struct __attribute__((aligned (64))) GpuHidHaarStageClassifier @@ -84,22 +84,22 @@ typedef struct __attribute__((aligned (64))) GpuHidHaarStageClassifier GpuHidHaarStageClassifier; -typedef struct __attribute__((aligned (64))) GpuHidHaarClassifierCascade -{ - int count __attribute__((aligned (4))); - int is_stump_based __attribute__((aligned (4))); - int has_tilted_features __attribute__((aligned (4))); - int is_tree __attribute__((aligned (4))); - int pq0 __attribute__((aligned (4))); - int pq1 __attribute__((aligned (4))); - int pq2 __attribute__((aligned (4))); - int pq3 __attribute__((aligned (4))); - int p0 __attribute__((aligned (4))); - int p1 __attribute__((aligned (4))); - int p2 __attribute__((aligned (4))); - int p3 __attribute__((aligned (4))); - float inv_window_area __attribute__((aligned (4))); -} GpuHidHaarClassifierCascade; +//typedef struct __attribute__((aligned (64))) GpuHidHaarClassifierCascade +//{ +// int count __attribute__((aligned (4))); +// int is_stump_based __attribute__((aligned (4))); +// int has_tilted_features __attribute__((aligned (4))); +// int is_tree __attribute__((aligned (4))); +// int pq0 __attribute__((aligned (4))); +// int pq1 __attribute__((aligned (4))); +// int pq2 __attribute__((aligned (4))); +// int pq3 __attribute__((aligned (4))); +// int p0 __attribute__((aligned (4))); +// int p1 __attribute__((aligned (4))); +// int p2 __attribute__((aligned (4))); +// int p3 __attribute__((aligned (4))); +// float inv_window_area __attribute__((aligned (4))); +//} GpuHidHaarClassifierCascade; #ifdef PACKED_CLASSIFIER @@ -196,10 +196,12 @@ __kernel void gpuRunHaarClassifierCascadePacked( for(int stageloop = start_stage; (stageloop < end_stage) && result; stageloop++ ) {// iterate until candidate is exist float stage_sum = 0.0f; - int2 stageinfo = *(global int2*)(stagecascadeptr+stageloop); - float stagethreshold = as_float(stageinfo.y); + __global GpuHidHaarStageClassifier* stageinfo = (__global GpuHidHaarStageClassifier*) + ((__global uchar*)stagecascadeptr+stageloop*sizeof(GpuHidHaarStageClassifier)); + int stagecount = stageinfo->count; + float stagethreshold = stageinfo->threshold; int lcl_off = (lid_y*DATA_SIZE_X)+(lid_x); - for(int nodeloop = 0; nodeloop < stageinfo.x; nodecounter++,nodeloop++ ) + for(int nodeloop = 0; nodeloop < stagecount; nodecounter++,nodeloop++ ) { // simple macro to extract shorts from int #define M0(_t) ((_t)&0xFFFF) @@ -355,14 +357,17 @@ __kernel void __attribute__((reqd_work_group_size(8,8,1)))gpuRunHaarClassifierCa variance_norm_factor = variance_norm_factor * correction - mean * mean; variance_norm_factor = variance_norm_factor >=0.f ? sqrt(variance_norm_factor) : 1.f; - for(int stageloop = start_stage; (stageloop < split_stage) && result; stageloop++ ) + for(int stageloop = start_stage; (stageloop < split_stage) && result; stageloop++ ) { float stage_sum = 0.f; - int2 stageinfo = *(global int2*)(stagecascadeptr+stageloop); - float stagethreshold = as_float(stageinfo.y); - for(int nodeloop = 0; nodeloop < stageinfo.x; ) + __global GpuHidHaarStageClassifier* stageinfo = (__global GpuHidHaarStageClassifier*) + ((__global uchar*)stagecascadeptr+stageloop*sizeof(GpuHidHaarStageClassifier)); + int stagecount = stageinfo->count; + float stagethreshold = stageinfo->threshold; + for(int nodeloop = 0; nodeloop < stagecount; ) { - __global GpuHidHaarTreeNode* currentnodeptr = (nodeptr + nodecounter); + __global GpuHidHaarTreeNode* currentnodeptr = (__global GpuHidHaarTreeNode*) + (((__global uchar*)nodeptr) + nodecounter * sizeof(GpuHidHaarTreeNode)); int4 info1 = *(__global int4*)(&(currentnodeptr->p[0][0])); int4 info2 = *(__global int4*)(&(currentnodeptr->p[1][0])); @@ -418,7 +423,7 @@ __kernel void __attribute__((reqd_work_group_size(8,8,1)))gpuRunHaarClassifierCa #endif } - result = (stage_sum >= stagethreshold); + result = (stage_sum >= stagethreshold) ? 1 : 0; } if(factor < 2) { @@ -447,14 +452,17 @@ __kernel void __attribute__((reqd_work_group_size(8,8,1)))gpuRunHaarClassifierCa lclcount[0]=0; barrier(CLK_LOCAL_MEM_FENCE); - int2 stageinfo = *(global int2*)(stagecascadeptr+stageloop); - float stagethreshold = as_float(stageinfo.y); + //int2 stageinfo = *(global int2*)(stagecascadeptr+stageloop); + __global GpuHidHaarStageClassifier* stageinfo = (__global GpuHidHaarStageClassifier*) + ((__global uchar*)stagecascadeptr+stageloop*sizeof(GpuHidHaarStageClassifier)); + int stagecount = stageinfo->count; + float stagethreshold = stageinfo->threshold; int perfscale = queuecount > 4 ? 3 : 2; int queuecount_loop = (queuecount + (1<> perfscale; int lcl_compute_win = lcl_sz >> perfscale; int lcl_compute_win_id = (lcl_id >>(6-perfscale)); - int lcl_loops = (stageinfo.x + lcl_compute_win -1) >> (6-perfscale); + int lcl_loops = (stagecount + lcl_compute_win -1) >> (6-perfscale); int lcl_compute_id = lcl_id - (lcl_compute_win_id << (6-perfscale)); for(int queueloop=0; queueloopp[0][0])); int4 info2 = *(__global int4*)(&(currentnodeptr->p[1][0])); @@ -549,7 +557,7 @@ __kernel void __attribute__((reqd_work_group_size(8,8,1)))gpuRunHaarClassifierCa queuecount = lclcount[0]; barrier(CLK_LOCAL_MEM_FENCE); - nodecounter += stageinfo.x; + nodecounter += stagecount; }//end for(int stageloop = splitstage; stageloop< endstage && queuecount>0;stageloop++) if(lcl_id> 16; int totalgrp = scaleinfo1.y & 0xffff; float factor = as_float(scaleinfo1.w); @@ -174,15 +173,18 @@ __kernel void gpuRunHaarClassifierCascade_scaled2( for (int stageloop = start_stage; (stageloop < end_stage) && result; stageloop++) { float stage_sum = 0.f; - int stagecount = stagecascadeptr[stageloop].count; + __global GpuHidHaarStageClassifier* stageinfo = (__global GpuHidHaarStageClassifier*) + (((__global uchar*)stagecascadeptr_)+stageloop*sizeof(GpuHidHaarStageClassifier)); + int stagecount = stageinfo->count; for (int nodeloop = 0; nodeloop < stagecount;) { - __global GpuHidHaarTreeNode *currentnodeptr = (nodeptr + nodecounter); + __global GpuHidHaarTreeNode* currentnodeptr = (__global GpuHidHaarTreeNode*) + (((__global uchar*)nodeptr_) + nodecounter * sizeof(GpuHidHaarTreeNode)); int4 info1 = *(__global int4 *)(&(currentnodeptr->p[0][0])); int4 info2 = *(__global int4 *)(&(currentnodeptr->p[1][0])); int4 info3 = *(__global int4 *)(&(currentnodeptr->p[2][0])); float4 w = *(__global float4 *)(&(currentnodeptr->weight[0])); - float3 alpha3 = *(__global float3 *)(&(currentnodeptr->alpha[0])); + float3 alpha3 = *(__global float3*)(&(currentnodeptr->alpha[0])); float nodethreshold = w.w * variance_norm_factor; info1.x += p_offset; @@ -204,7 +206,7 @@ __kernel void gpuRunHaarClassifierCascade_scaled2( sum[clamp(mad24(info3.w, step, info3.x), 0, max_idx)] + sum[clamp(mad24(info3.w, step, info3.z), 0, max_idx)]) * w.z; - bool passThres = classsum >= nodethreshold; + bool passThres = (classsum >= nodethreshold) ? 1 : 0; #if STUMP_BASED stage_sum += passThres ? alpha3.y : alpha3.x; @@ -234,7 +236,8 @@ __kernel void gpuRunHaarClassifierCascade_scaled2( } #endif } - result = (int)(stage_sum >= stagecascadeptr[stageloop].threshold); + + result = (stage_sum >= stageinfo->threshold) ? 1 : 0; } barrier(CLK_LOCAL_MEM_FENCE); @@ -281,11 +284,14 @@ __kernel void gpuRunHaarClassifierCascade_scaled2( } } } -__kernel void gpuscaleclassifier(global GpuHidHaarTreeNode *orinode, global GpuHidHaarTreeNode *newnode, float scale, float weight_scale, int nodenum) +__kernel void gpuscaleclassifier(global GpuHidHaarTreeNode *orinode, global GpuHidHaarTreeNode *newnode, float scale, float weight_scale, const int nodenum) { - int counter = get_global_id(0); + const int counter = get_global_id(0); int tr_x[3], tr_y[3], tr_h[3], tr_w[3], i = 0; - GpuHidHaarTreeNode t1 = *(orinode + counter); + GpuHidHaarTreeNode t1 = *(__global GpuHidHaarTreeNode*) + (((__global uchar*)orinode) + counter * sizeof(GpuHidHaarTreeNode)); + __global GpuHidHaarTreeNode* pNew = (__global GpuHidHaarTreeNode*) + (((__global uchar*)newnode) + (counter + nodenum) * sizeof(GpuHidHaarTreeNode)); #pragma unroll for (i = 0; i < 3; i++) @@ -297,22 +303,21 @@ __kernel void gpuscaleclassifier(global GpuHidHaarTreeNode *orinode, global GpuH } t1.weight[0] = -(t1.weight[1] * tr_h[1] * tr_w[1] + t1.weight[2] * tr_h[2] * tr_w[2]) / (tr_h[0] * tr_w[0]); - counter += nodenum; #pragma unroll for (i = 0; i < 3; i++) { - newnode[counter].p[i][0] = tr_x[i]; - newnode[counter].p[i][1] = tr_y[i]; - newnode[counter].p[i][2] = tr_x[i] + tr_w[i]; - newnode[counter].p[i][3] = tr_y[i] + tr_h[i]; - newnode[counter].weight[i] = t1.weight[i] * weight_scale; + pNew->p[i][0] = tr_x[i]; + pNew->p[i][1] = tr_y[i]; + pNew->p[i][2] = tr_x[i] + tr_w[i]; + pNew->p[i][3] = tr_y[i] + tr_h[i]; + pNew->weight[i] = t1.weight[i] * weight_scale; } - newnode[counter].left = t1.left; - newnode[counter].right = t1.right; - newnode[counter].threshold = t1.threshold; - newnode[counter].alpha[0] = t1.alpha[0]; - newnode[counter].alpha[1] = t1.alpha[1]; - newnode[counter].alpha[2] = t1.alpha[2]; + pNew->left = t1.left; + pNew->right = t1.right; + pNew->threshold = t1.threshold; + pNew->alpha[0] = t1.alpha[0]; + pNew->alpha[1] = t1.alpha[1]; + pNew->alpha[2] = t1.alpha[2]; } From 3bc952ed34b8f198da7c679f03a51c27f984fb76 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Thu, 5 Dec 2013 19:27:10 -0200 Subject: [PATCH 22/27] ocl::BruteForceMatcher fix wrong use of oclMat::ptr(). The oclMat::ptr() method was mistakenly used in ocl::BruteForceMatcher to pass a pointer to a oclMat object. The ptr() method returns a uchar pointer to the cl_mem data structure and this method will be removed. --- modules/ocl/src/brute_force_matcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ocl/src/brute_force_matcher.cpp b/modules/ocl/src/brute_force_matcher.cpp index b1efe8ca64..b51d4f194c 100644 --- a/modules/ocl/src/brute_force_matcher.cpp +++ b/modules/ocl/src/brute_force_matcher.cpp @@ -677,7 +677,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchCollection(const oclMat &query, c ensureSizeIsEnough(1, nQuery, CV_32S, imgIdx); ensureSizeIsEnough(1, nQuery, CV_32F, distance); - matchDispatcher(query, (const oclMat *)trainCollection.ptr(), trainCollection.cols, masks, trainIdx, imgIdx, distance, distType); + matchDispatcher(query, &trainCollection, trainCollection.cols, masks, trainIdx, imgIdx, distance, distType); return; } From 7a78559708776b28d33c2ff8a5d46a0699f748f2 Mon Sep 17 00:00:00 2001 From: Konstantin Matskevich Date: Fri, 6 Dec 2013 12:12:24 +0400 Subject: [PATCH 23/27] some fixes --- samples/ocl/facedetect.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 0f452b945f..78a0775151 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -74,7 +74,7 @@ static int facedetect_one_thread(bool useCPU, double scale ) if( !cascade.load( cascadeName ) || !cpu_cascade.load(cascadeName) ) { - cout << "ERROR: Could not load classifier cascade" << endl; + cout << "ERROR: Could not load classifier cascade: " << cascadeName << endl; return EXIT_FAILURE; } @@ -170,7 +170,12 @@ static int facedetect_one_thread(bool useCPU, double scale ) static void detectFaces(std::string fileName) { ocl::OclCascadeClassifier cascade; - cascade.load(cascadeName); + if(!cascade.load(cascadeName)) + { + std::cout << "ERROR: Could not load classifier cascade: " << cascadeName << std::endl; + return; + } + Mat img = imread(fileName, CV_LOAD_IMAGE_COLOR); if (img.empty()) { @@ -187,8 +192,16 @@ static void detectFaces(std::string fileName) for(unsigned int i = 0; i 0 && outputName[n-1] != '.') + n--; + if( n == 0 ) + { + std::cout << "Invalid output file name: " << outputName << std::endl; + return; + } + imwrite(outputName.substr(0,n-1) + "_" + std::to_string(_threadid) + outputName.substr(n-1, outputName.length()-1), img); } static void facedetect_multithreading(int nthreads) From 894724eaf0641a2b511797dbc28cc5a97c486fe0 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Fri, 6 Dec 2013 14:49:36 +0400 Subject: [PATCH 24/27] minor improvements --- samples/ocl/facedetect.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 78a0775151..fbb08cb1e5 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -190,18 +190,21 @@ static void detectFaces(std::string fileName) cascade.detectMultiScale(d_img, oclfaces, 1.1, 3, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30), Size(0, 0)); for(unsigned int i = 0; i 0 && outputName[n-1] != '.') - n--; - if( n == 0 ) + std::string::size_type pos = outputName.rfind('.'); + std::string outputNameTid = outputName + '-' + std::to_string(_threadid); + if(pos == std::string::npos) { std::cout << "Invalid output file name: " << outputName << std::endl; - return; } - - imwrite(outputName.substr(0,n-1) + "_" + std::to_string(_threadid) + outputName.substr(n-1, outputName.length()-1), img); + else + { + outputNameTid = outputName.substr(0, pos) + "_" + std::to_string(_threadid) + outputName.substr(pos); + imwrite(outputNameTid, img); + } + imshow(outputNameTid, img); + waitKey(0); } static void facedetect_multithreading(int nthreads) @@ -212,8 +215,6 @@ static void facedetect_multithreading(int nthreads) threads.push_back(std::thread(detectFaces, inputName)); for(int i = 0; i Date: Fri, 6 Dec 2013 09:31:18 -0200 Subject: [PATCH 25/27] Removing ocl::oclMat::ptr() method. The method ocl::oclMat::ptr() is being removed because it returns a pointer to a row of oclMat::data. The data attribute is a cl_mem structure and cannot be iterated outside an OpenCL kernel. --- modules/ocl/doc/data_structures.rst | 8 ----- .../include/opencv2/ocl/matrix_operations.hpp | 30 ------------------- modules/ocl/include/opencv2/ocl/ocl.hpp | 8 ----- 3 files changed, 46 deletions(-) diff --git a/modules/ocl/doc/data_structures.rst b/modules/ocl/doc/data_structures.rst index 01a16739ba..bde3d14af4 100644 --- a/modules/ocl/doc/data_structures.rst +++ b/modules/ocl/doc/data_structures.rst @@ -144,14 +144,6 @@ OpenCV C++ 1-D or 2-D dense array class :: //! 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; diff --git a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp index ad3a16755f..e234a45aa1 100644 --- a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp +++ b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp @@ -456,36 +456,6 @@ namespace cv return data == 0; } - - - inline uchar *oclMat::ptr(int y) - { - CV_DbgAssert( (unsigned)y < (unsigned)rows ); - CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n"); - return data + step * y; - } - - inline const uchar *oclMat::ptr(int y) const - { - CV_DbgAssert( (unsigned)y < (unsigned)rows ); - CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n"); - return data + step * y; - } - - template inline _Tp *oclMat::ptr(int y) - { - CV_DbgAssert( (unsigned)y < (unsigned)rows ); - CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n"); - return (_Tp *)(data + step * y); - } - - template inline const _Tp *oclMat::ptr(int y) const - { - CV_DbgAssert( (unsigned)y < (unsigned)rows ); - CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n"); - return (const _Tp *)(data + step * y); - } - inline oclMat oclMat::t() const { oclMat tmp; diff --git a/modules/ocl/include/opencv2/ocl/ocl.hpp b/modules/ocl/include/opencv2/ocl/ocl.hpp index b8c9b85354..eb310a26e7 100644 --- a/modules/ocl/include/opencv2/ocl/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl/ocl.hpp @@ -379,14 +379,6 @@ namespace cv //! 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; From f2cf9dd8bfb30e89b113805fb3d0be1d5667e5f3 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Fri, 6 Dec 2013 16:21:22 +0400 Subject: [PATCH 26/27] updating version to 2.4.7.2 --- modules/core/include/opencv2/core/version.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/version.hpp b/modules/core/include/opencv2/core/version.hpp index 99241a9fa2..c5a28612d7 100644 --- a/modules/core/include/opencv2/core/version.hpp +++ b/modules/core/include/opencv2/core/version.hpp @@ -50,7 +50,7 @@ #define CV_VERSION_EPOCH 2 #define CV_VERSION_MAJOR 4 #define CV_VERSION_MINOR 7 -#define CV_VERSION_REVISION 0 +#define CV_VERSION_REVISION 2 #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) From 9f04222a75b308b8d9e6865fef8d9efc9be414e0 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 6 Dec 2013 18:01:15 +0400 Subject: [PATCH 27/27] OpenCV Manager version++. --- modules/core/include/opencv2/core/version.hpp | 2 +- .../service/engine/AndroidManifest.xml | 4 +-- platforms/android/service/readme.txt | 28 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/core/include/opencv2/core/version.hpp b/modules/core/include/opencv2/core/version.hpp index 99241a9fa2..c5a28612d7 100644 --- a/modules/core/include/opencv2/core/version.hpp +++ b/modules/core/include/opencv2/core/version.hpp @@ -50,7 +50,7 @@ #define CV_VERSION_EPOCH 2 #define CV_VERSION_MAJOR 4 #define CV_VERSION_MINOR 7 -#define CV_VERSION_REVISION 0 +#define CV_VERSION_REVISION 2 #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) diff --git a/platforms/android/service/engine/AndroidManifest.xml b/platforms/android/service/engine/AndroidManifest.xml index 162d31eb02..7cae6ce8a0 100644 --- a/platforms/android/service/engine/AndroidManifest.xml +++ b/platforms/android/service/engine/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="216@ANDROID_PLATFORM_VERSION_CODE@" + android:versionName="2.16" > diff --git a/platforms/android/service/readme.txt b/platforms/android/service/readme.txt index 1e757a0e5f..a280b506f0 100644 --- a/platforms/android/service/readme.txt +++ b/platforms/android/service/readme.txt @@ -14,20 +14,20 @@ manually using adb tool: .. code-block:: sh - adb install OpenCV-2.4.7-android-sdk/apk/OpenCV_2.4.7_Manager_2.14_.apk + adb install OpenCV-2.4.7.1-android-sdk/apk/OpenCV_2.4.7.1_Manager_2.15_.apk Use the table below to determine proper OpenCV Manager package for your device: -+------------------------------+--------------+----------------------------------------------------+ -| Hardware Platform | Android ver. | Package name | -+==============================+==============+====================================================+ -| armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.7_Manager_2.14_armv7a-neon.apk | -+------------------------------+--------------+----------------------------------------------------+ -| armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.7_Manager_2.14_armv7a-neon-android8.apk | -+------------------------------+--------------+----------------------------------------------------+ -| armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.7_Manager_2.14_armeabi.apk | -+------------------------------+--------------+----------------------------------------------------+ -| Intel x86 | >= 2.3 | OpenCV_2.4.7_Manager_2.14_x86.apk | -+------------------------------+--------------+----------------------------------------------------+ -| MIPS | >= 2.3 | OpenCV_2.4.7_Manager_2.14_mips.apk | -+------------------------------+--------------+----------------------------------------------------+ ++------------------------------+--------------+------------------------------------------------------+ +| Hardware Platform | Android ver. | Package name | ++==============================+==============+======================================================+ +| armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.7.1_Manager_2.15_armv7a-neon.apk | ++------------------------------+--------------+------------------------------------------------------+ +| armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.7.1_Manager_2.15_armv7a-neon-android8.apk | ++------------------------------+--------------+------------------------------------------------------+ +| armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.7.1_Manager_2.15_armeabi.apk | ++------------------------------+--------------+------------------------------------------------------+ +| Intel x86 | >= 2.3 | OpenCV_2.4.7.1_Manager_2.15_x86.apk | ++------------------------------+--------------+------------------------------------------------------+ +| MIPS | >= 2.3 | OpenCV_2.4.7.1_Manager_2.15_mips.apk | ++------------------------------+--------------+------------------------------------------------------+