From d0210f510e837ae3a4dd0d9a9ea505ae3f062751 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 14 Aug 2015 16:43:10 +0300 Subject: [PATCH 01/53] OpenCV version++. --- 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 50562ec5ad..7457da76a9 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 12 -#define CV_VERSION_REVISION 0 +#define CV_VERSION_REVISION 1 #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) From fc0e0239b8d6d3d65f59a2f062bd133d6cc845d9 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 14 Aug 2015 17:57:54 +0300 Subject: [PATCH 02/53] fixed valgrind warning in polylines (cherry picked from commit 855765986e9cd5c730730dd1f45175b182e737fa) --- modules/core/src/drawing.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index bd42ac5066..bd8f171b16 100644 --- a/modules/core/src/drawing.cpp +++ b/modules/core/src/drawing.cpp @@ -2216,6 +2216,7 @@ void cv::polylines(InputOutputArray _img, InputArrayOfArrays pts, Mat p = pts.getMat(manyContours ? i : -1); if( p.total() == 0 ) { + ptsptr[i] = NULL; npts[i] = 0; continue; } From ecc53dd7a45f2573e35a897612100ece84dbc0f2 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 15 Aug 2015 00:35:38 +0300 Subject: [PATCH 03/53] fixed memory leak in core ds tests (cherry picked from commit 7719da95526b81af0195a3576774eaac605cd045) --- modules/core/test/test_ds.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/core/test/test_ds.cpp b/modules/core/test/test_ds.cpp index adc8f1a42c..ded52583a2 100644 --- a/modules/core/test/test_ds.cpp +++ b/modules/core/test/test_ds.cpp @@ -493,6 +493,7 @@ class Core_SeqBaseTest : public Core_DynStructBaseTest { public: Core_SeqBaseTest(); + virtual ~Core_SeqBaseTest(); void clear(); void run( int ); @@ -503,11 +504,14 @@ protected: int test_seq_ops( int iters ); }; - Core_SeqBaseTest::Core_SeqBaseTest() { } +Core_SeqBaseTest::~Core_SeqBaseTest() +{ + clear(); +} void Core_SeqBaseTest::clear() { @@ -1208,6 +1212,7 @@ class Core_SetTest : public Core_DynStructBaseTest { public: Core_SetTest(); + virtual ~Core_SetTest(); void clear(); void run( int ); @@ -1221,6 +1226,10 @@ Core_SetTest::Core_SetTest() { } +Core_SetTest::~Core_SetTest() +{ + clear(); +} void Core_SetTest::clear() { @@ -1419,6 +1428,7 @@ class Core_GraphTest : public Core_DynStructBaseTest { public: Core_GraphTest(); + virtual ~Core_GraphTest(); void clear(); void run( int ); @@ -1432,6 +1442,10 @@ Core_GraphTest::Core_GraphTest() { } +Core_GraphTest::~Core_GraphTest() +{ + clear(); +} void Core_GraphTest::clear() { @@ -2044,6 +2058,8 @@ void Core_GraphScanTest::run( int ) CV_TS_SEQ_CHECK_CONDITION( vtx_count == 0 && edge_count == 0, "Not every vertex/edge has been visited" ); update_progressbar(); + + cvReleaseGraphScanner( &scanner ); } // for a random graph the test just checks that every graph vertex and @@ -2108,8 +2124,6 @@ void Core_GraphScanTest::run( int ) catch(int) { } - - cvReleaseGraphScanner( &scanner ); } From bf94e6a91cea3bc4742aa04308855b4cbd0bed27 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 15 Aug 2015 10:06:09 +0300 Subject: [PATCH 04/53] fixed memory leaks in cvtyuv tests (cherry picked from commit b2489d31d66599ac2aaa79af2b753a24649776aa) --- modules/imgproc/test/test_cvtyuv.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/test/test_cvtyuv.cpp b/modules/imgproc/test/test_cvtyuv.cpp index 0cce64cdba..7407523fe1 100644 --- a/modules/imgproc/test/test_cvtyuv.cpp +++ b/modules/imgproc/test/test_cvtyuv.cpp @@ -548,7 +548,7 @@ void referenceRGB2YUV(const Mat& rgb, Mat& yuv, RGBreader* rgbReader, YUVwriter* struct ConversionYUV { - ConversionYUV( const int code ) + explicit ConversionYUV( const int code ) { yuvReader_ = YUVreader :: getReader(code); yuvWriter_ = YUVwriter :: getWriter(code); @@ -557,6 +557,24 @@ struct ConversionYUV grayWriter_ = GRAYwriter:: getWriter(code); } + ~ConversionYUV() + { + if (yuvReader_) + delete yuvReader_; + + if (yuvWriter_) + delete yuvWriter_; + + if (rgbReader_) + delete rgbReader_; + + if (rgbReader_) + delete rgbReader_; + + if (grayWriter_) + delete grayWriter_; + } + int getDcn() { return (rgbWriter_ != 0) ? rgbWriter_->channels() : ((grayWriter_ != 0) ? grayWriter_->channels() : yuvWriter_->channels()); From ba3b902da7801fdae78a667c47e81f71f5d212b0 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 15 Aug 2015 10:09:31 +0300 Subject: [PATCH 05/53] fixed memory leaks in floodfill tests (cherry picked from commit d1b882ddcf54e52ac70bb17540c84c4a93553add) --- modules/imgproc/test/test_floodfill.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/imgproc/test/test_floodfill.cpp b/modules/imgproc/test/test_floodfill.cpp index e46e9e120c..8293a12afd 100644 --- a/modules/imgproc/test/test_floodfill.cpp +++ b/modules/imgproc/test/test_floodfill.cpp @@ -501,6 +501,8 @@ _exit_: comp[6] = s1; comp[7] = s2; comp[8] = 0; + + cvReleaseMemStorage(&st); } From 08e38e9ff93b5e88dfe17b184f4e4527aa12c020 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 15 Aug 2015 10:11:52 +0300 Subject: [PATCH 06/53] fixed memory leaks in warpAffine tests (cherry picked from commit b70e27e076a7eea6a1ccc6bb5f367e539e1aa51c) --- modules/imgproc/test/test_imgwarp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 705bf0a7bc..99cffbc37d 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1426,6 +1426,9 @@ TEST(Imgproc_cvWarpAffine, regression) int h = src->height; cv2DRotationMatrix(cvPoint2D32f(w*0.5f, h*0.5f), 45.0, 1.0, &M); cvWarpAffine(src, dst, &M); + + cvReleaseImage(&src); + cvReleaseImage(&dst); } TEST(Imgproc_fitLine_vector_3d, regression) From 486c40f578e5f8f4428c86eda083ee11212ae068 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 15 Aug 2015 14:30:27 +0300 Subject: [PATCH 07/53] fixed uninitialized values warning in bad arg test class (cherry picked from commit 47cee8715bb086f6b0ca0f5b301d2eec87ce9f2a) --- modules/ts/src/ts.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ts/src/ts.cpp b/modules/ts/src/ts.cpp index ee8f01171f..bfeae74bb2 100644 --- a/modules/ts/src/ts.cpp +++ b/modules/ts/src/ts.cpp @@ -323,6 +323,7 @@ BadArgTest::BadArgTest() progress = -1; test_case_idx = -1; freq = cv::getTickFrequency(); + t = -1; // oldErrorCbk = 0; // oldErrorCbkData = 0; } @@ -338,6 +339,7 @@ int BadArgTest::run_test_case( int expected_code, const string& _descr ) { test_case_idx = 0; progress = 0; + t = 0; dt = 0; } else From 69c50e01815346475c43407d97ea17fea8973632 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 15 Aug 2015 16:25:25 +0300 Subject: [PATCH 08/53] fixed typo (cherry picked from commit 370d1ff21a99046021da39b74f4081a5b69ce57e) --- modules/features2d/test/test_nearestneighbors.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/features2d/test/test_nearestneighbors.cpp b/modules/features2d/test/test_nearestneighbors.cpp index 8d1ecfd79a..2c64e648f2 100644 --- a/modules/features2d/test/test_nearestneighbors.cpp +++ b/modules/features2d/test/test_nearestneighbors.cpp @@ -65,13 +65,13 @@ protected: virtual void run( int start_from ); virtual void createModel( const Mat& data ) = 0; virtual int findNeighbors( Mat& points, Mat& neighbors ) = 0; - virtual int checkGetPoins( const Mat& data ); + virtual int checkGetPoints( const Mat& data ); virtual int checkFindBoxed(); virtual int checkFind( const Mat& data ); virtual void releaseModel() = 0; }; -int NearestNeighborTest::checkGetPoins( const Mat& ) +int NearestNeighborTest::checkGetPoints( const Mat& ) { return cvtest::TS::OK; } @@ -129,7 +129,7 @@ void NearestNeighborTest::run( int /*start_from*/ ) { createModel( desc ); - tempCode = checkGetPoins( desc ); + tempCode = checkGetPoints( desc ); if( tempCode != cvtest::TS::OK ) { ts->printf( cvtest::TS::LOG, "bad accuracy of GetPoints \n" ); @@ -162,7 +162,7 @@ public: CV_KDTreeTest_CPP() {} protected: virtual void createModel( const Mat& data ); - virtual int checkGetPoins( const Mat& data ); + virtual int checkGetPoints( const Mat& data ); virtual int findNeighbors( Mat& points, Mat& neighbors ); virtual int checkFindBoxed(); virtual void releaseModel(); @@ -175,7 +175,7 @@ void CV_KDTreeTest_CPP::createModel( const Mat& data ) tr = new KDTree( data, false ); } -int CV_KDTreeTest_CPP::checkGetPoins( const Mat& data ) +int CV_KDTreeTest_CPP::checkGetPoints( const Mat& data ) { Mat res1( data.size(), data.type() ), res3( data.size(), data.type() ); From 16bcc30e429321eeea995575ff9361e2cc4ef250 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 16 Aug 2015 11:46:48 +0300 Subject: [PATCH 09/53] typo (cherry picked from commit 793bdaada7f170cf3fbaf3b421bb3054f37e8a63) --- modules/imgproc/test/test_cvtyuv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/test/test_cvtyuv.cpp b/modules/imgproc/test/test_cvtyuv.cpp index 7407523fe1..5db4972692 100644 --- a/modules/imgproc/test/test_cvtyuv.cpp +++ b/modules/imgproc/test/test_cvtyuv.cpp @@ -568,8 +568,8 @@ struct ConversionYUV if (rgbReader_) delete rgbReader_; - if (rgbReader_) - delete rgbReader_; + if (rgbWriter_) + delete rgbWriter_; if (grayWriter_) delete grayWriter_; From 3231c2f99562eb115296f1432a734fc23b333861 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 30 Jul 2015 18:03:48 +0300 Subject: [PATCH 10/53] NearestNeighborTest: use ts->get_rng() instead of (implicit) theRNG() This ensures that test data is not dependent on the order the tests are executed in. (cherry picked from commit 1245cd175283b11800bbbdc52287957cc3d76417) --- modules/features2d/test/test_nearestneighbors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/features2d/test/test_nearestneighbors.cpp b/modules/features2d/test/test_nearestneighbors.cpp index 2c64e648f2..b63bc6433e 100644 --- a/modules/features2d/test/test_nearestneighbors.cpp +++ b/modules/features2d/test/test_nearestneighbors.cpp @@ -125,7 +125,7 @@ int NearestNeighborTest::checkFind( const Mat& data ) void NearestNeighborTest::run( int /*start_from*/ ) { int code = cvtest::TS::OK, tempCode; Mat desc( featuresCount, dims, CV_32FC1 ); - randu( desc, Scalar(minValue), Scalar(maxValue) ); + ts->get_rng().fill( desc, RNG::UNIFORM, minValue, maxValue ); createModel( desc ); From c16f465ff5b3379fb027f6256793d18cb7853d0d Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 20 Aug 2015 12:20:38 +0300 Subject: [PATCH 11/53] fixed "Conditional jump or move depends on uninitialised value" warning (cherry picked from commit f100cdb6d4373c93abc2b5613fae505ed3ce876d) --- modules/imgproc/test/test_imgwarp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 99cffbc37d..a14ea532a9 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1420,6 +1420,8 @@ TEST(Imgproc_cvWarpAffine, regression) IplImage* src = cvCreateImage(cvSize(100, 100), IPL_DEPTH_8U, 1); IplImage* dst = cvCreateImage(cvSize(100, 100), IPL_DEPTH_8U, 1); + cvZero(src); + float m[6]; CvMat M = cvMat( 2, 3, CV_32F, m ); int w = src->width; From d28e6c9b3693b02766031967dd5f0c7fd8056fc4 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 20 Aug 2015 13:28:10 +0300 Subject: [PATCH 12/53] fixed memory leak caused by illegal memory access (cherry picked from commit 4722b2d0e5b2caf053e53612ea277451c5cc53a0) --- modules/imgproc/test/test_imgwarp_strict.cpp | 34 +++++--------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp index c122d0b58b..365f851d5e 100644 --- a/modules/imgproc/test/test_imgwarp_strict.cpp +++ b/modules/imgproc/test/test_imgwarp_strict.cpp @@ -644,8 +644,7 @@ private: }; CV_Remap_Test::CV_Remap_Test() : - CV_ImageWarpBaseTest(), mapx(), mapy(), - borderType(-1), borderValue() + CV_ImageWarpBaseTest(), borderType(-1) { funcs[0] = &CV_Remap_Test::remap_nearest; funcs[1] = &CV_Remap_Test::remap_generic; @@ -666,7 +665,7 @@ void CV_Remap_Test::generate_test_data() // generating the mapx, mapy matrices static const int mapx_types[] = { CV_16SC2, CV_32FC1, CV_32FC2 }; mapx.create(dst.size(), mapx_types[rng.uniform(0, sizeof(mapx_types) / sizeof(int))]); - mapy = Mat(); + mapy.release(); const int n = std::min(std::min(src.cols, src.rows) / 10 + 1, 2); float _n = 0; //static_cast(-n); @@ -693,7 +692,7 @@ void CV_Remap_Test::generate_test_data() { MatIterator_ begin_y = mapy.begin(), end_y = mapy.end(); for ( ; begin_y != end_y; ++begin_y) - begin_y[0] = static_cast(rng.uniform(0, 1024)); + *begin_y = static_cast(rng.uniform(0, 1024)); } break; @@ -701,7 +700,7 @@ void CV_Remap_Test::generate_test_data() { MatIterator_ begin_y = mapy.begin(), end_y = mapy.end(); for ( ; begin_y != end_y; ++begin_y) - begin_y[0] = static_cast(rng.uniform(0, 1024)); + *begin_y = static_cast(rng.uniform(0, 1024)); } break; } @@ -718,8 +717,8 @@ void CV_Remap_Test::generate_test_data() MatIterator_ begin_y = mapy.begin(); for ( ; begin_x != end_x; ++begin_x, ++begin_y) { - begin_x[0] = rng.uniform(_n, fscols); - begin_y[0] = rng.uniform(_n, fsrows); + *begin_x = rng.uniform(_n, fscols); + *begin_y = rng.uniform(_n, fsrows); } } break; @@ -731,8 +730,8 @@ void CV_Remap_Test::generate_test_data() fsrows = static_cast(std::max(src.rows - 1 + n, 0)); for ( ; begin_x != end_x; ++begin_x) { - begin_x[0] = rng.uniform(_n, fscols); - begin_x[1] = rng.uniform(_n, fsrows); + (*begin_x)[0] = rng.uniform(_n, fscols); + (*begin_x)[1] = rng.uniform(_n, fsrows); } } break; @@ -777,23 +776,6 @@ void CV_Remap_Test::prepare_test_data_for_reference_func() { CV_ImageWarpBaseTest::prepare_test_data_for_reference_func(); convert_maps(); -/* - const int ksize = 3; - Mat kernel = getStructuringElement(CV_MOP_ERODE, Size(ksize, ksize)); - Mat mask(src.size(), CV_8UC1, Scalar::all(255)), dst_mask; - cv::erode(src, erode_src, kernel); - cv::erode(mask, dst_mask, kernel, Point(-1, -1), 1, BORDER_CONSTANT, Scalar::all(0)); - bitwise_not(dst_mask, mask); - src.copyTo(erode_src, mask); - dst_mask.release(); - - mask = Scalar::all(0); - kernel = getStructuringElement(CV_MOP_DILATE, kernel.size()); - cv::dilate(src, dilate_src, kernel); - cv::dilate(mask, dst_mask, kernel, Point(-1, -1), 1, BORDER_CONSTANT, Scalar::all(255)); - src.copyTo(dilate_src, dst_mask); - dst_mask.release(); -*/ } void CV_Remap_Test::run_reference_func() From 226ff9391724ae20250d77df2f4febd21fd3b9bf Mon Sep 17 00:00:00 2001 From: a-andre Date: Sun, 2 Aug 2015 13:13:58 +0200 Subject: [PATCH 13/53] install new headers like "opencv2/core.hpp" --- cmake/OpenCVModule.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index a70065750f..ec834d9090 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -488,7 +488,7 @@ macro(ocv_glob_module_sources) file(GLOB_RECURSE lib_srcs "src/*.cpp") file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h") - file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") + file(GLOB lib_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h") file(GLOB_RECURSE lib_srcs_apple "src/*.mm") if (APPLE) @@ -629,7 +629,7 @@ macro(ocv_create_module) if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};") foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS}) string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}") - if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$") + if(hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$") install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev) endif() endforeach() From a14e524b32d9252b7c58181d9752804371c82e4f Mon Sep 17 00:00:00 2001 From: a-andre Date: Tue, 18 Aug 2015 18:48:32 +0200 Subject: [PATCH 14/53] fix documentation builder warnings --- modules/core/include/opencv2/core.hpp | 3 --- modules/core/include/opencv2/core/core.hpp | 3 --- modules/imgproc/include/opencv2/imgproc.hpp | 4 ---- modules/imgproc/include/opencv2/imgproc/imgproc.hpp | 4 ---- 4 files changed, 14 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 98564c1a98..12773f8c1b 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -1,6 +1,3 @@ -/*! \file core.hpp - \brief The Core Functionality - */ /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 67905ec466..3e9c92d097 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -1,6 +1,3 @@ -/*! \file core.hpp - \brief The Core Functionality - */ /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index b07ece09b8..112f723274 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -1,7 +1,3 @@ -/*! \file imgproc.hpp - \brief The Image Processing - */ - /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp index 339476a633..f46cc643c8 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp @@ -1,7 +1,3 @@ -/*! \file imgproc.hpp - \brief The Image Processing - */ - /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. From 6613d142617ab35db3fbc36f0ff40cb2d1068fef Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 25 Aug 2015 18:50:06 +0300 Subject: [PATCH 15/53] Add missing packages to the Debian conflict list And refactor the code to make sure that the dev and runtime package lists are in sync. --- cmake/OpenCVPackaging.cmake | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cmake/OpenCVPackaging.cmake b/cmake/OpenCVPackaging.cmake index bc59f00f8c..be52aee04b 100644 --- a/cmake/OpenCVPackaging.cmake +++ b/cmake/OpenCVPackaging.cmake @@ -115,15 +115,14 @@ if(HAVE_TBB AND NOT BUILD_TBB) endif() endif() -set(STD_OPENCV_LIBS opencv-data libopencv-calib3d2.4 libopencv-contrib2.4 libopencv-core2.4 - libopencv-features2d2.4 libopencv-flann2.4 libopencv-gpu2.4 libopencv-imgproc2.4 - libopencv-ml2.4 libopencv-ocl2.4 libopencv-stitching2.4 libopencv-ts2.4 libopencv-videostab2.4) - -set(STD_OPENCV_DEV libopencv-calib3d-dev libopencv-contrib-dev libopencv-core-dev - libopencv-dev libopencv-features2d-dev libopencv-flann-dev libopencv-gpu-dev - libopencv-highgui-dev libopencv-imgproc-dev libopencv-legacy-dev libopencv-ml-dev - libopencv-objdetect-dev libopencv-ocl-dev libopencv-photo-dev libopencv-stitching-dev - libopencv-superres-dev libopencv-ts-dev libopencv-video-dev libopencv-videostab-dev) +set(STD_OPENCV_LIBS opencv-data) +set(STD_OPENCV_DEV libopencv-dev) + +foreach(module calib3d contrib core features2d flann gpu highgui imgproc legacy + ml objdetect ocl photo stitching superres ts video videostab) + list(APPEND STD_OPENCV_LIBS "libopencv-${module}2.4") + list(APPEND STD_OPENCV_DEV "libopencv-${module}-dev") +endforeach() string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_CONFLICTS "${STD_OPENCV_LIBS}") string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_PROVIDES "${STD_OPENCV_LIBS}") From d122510c4f666a22e792a9b54044198f9c673f24 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 26 Aug 2015 13:42:21 +0300 Subject: [PATCH 16/53] Only conflict with packages corresponding to modules that are built --- cmake/OpenCVPackaging.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVPackaging.cmake b/cmake/OpenCVPackaging.cmake index be52aee04b..f6d5bd04a0 100644 --- a/cmake/OpenCVPackaging.cmake +++ b/cmake/OpenCVPackaging.cmake @@ -120,8 +120,10 @@ set(STD_OPENCV_DEV libopencv-dev) foreach(module calib3d contrib core features2d flann gpu highgui imgproc legacy ml objdetect ocl photo stitching superres ts video videostab) - list(APPEND STD_OPENCV_LIBS "libopencv-${module}2.4") - list(APPEND STD_OPENCV_DEV "libopencv-${module}-dev") + if(HAVE_opencv_${module}) + list(APPEND STD_OPENCV_LIBS "libopencv-${module}2.4") + list(APPEND STD_OPENCV_DEV "libopencv-${module}-dev") + endif() endforeach() string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_CONFLICTS "${STD_OPENCV_LIBS}") From 1d58e1a14a1c44a4c1b57c6a665acc7ea40d74ab Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 27 Aug 2015 16:09:37 +0300 Subject: [PATCH 17/53] fix potential out-of-border access in gpu StereoBeliefPropagation --- modules/gpu/src/stereobp.cpp | 8 ++++---- modules/gpu/test/test_calib3d.cpp | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/gpu/src/stereobp.cpp b/modules/gpu/src/stereobp.cpp index 1677f33446..3b827a3129 100644 --- a/modules/gpu/src/stereobp.cpp +++ b/modules/gpu/src/stereobp.cpp @@ -213,8 +213,8 @@ namespace if (rthis.levels > 1) { - int less_rows = (rows + 1) / 2; - int less_cols = (cols + 1) / 2; + int less_rows = rows / 2; + int less_cols = cols / 2; u2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); d2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); @@ -283,8 +283,8 @@ namespace for (int i = 1; i < rthis.levels; ++i) { - cols_all[i] = (cols_all[i-1] + 1) / 2; - rows_all[i] = (rows_all[i-1] + 1) / 2; + cols_all[i] = cols_all[i-1] / 2; + rows_all[i] = rows_all[i-1] / 2; datas[i].create(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type); diff --git a/modules/gpu/test/test_calib3d.cpp b/modules/gpu/test/test_calib3d.cpp index ea4039a0cd..80882d431d 100644 --- a/modules/gpu/test/test_calib3d.cpp +++ b/modules/gpu/test/test_calib3d.cpp @@ -114,7 +114,9 @@ GPU_TEST_P(StereoBeliefPropagation, Regression) cv::Mat h_disp(disp); h_disp.convertTo(h_disp, disp_gold.depth()); - EXPECT_MAT_NEAR(disp_gold, h_disp, 0.0); + cv::Rect roi(0, 0, disp_gold.cols - 20, disp_gold.rows - 20); + + EXPECT_MAT_NEAR(disp_gold(roi), h_disp(roi), 0.0); } INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBeliefPropagation, ALL_DEVICES); From 6dcd455ac4cf279b880458a24e055370b61bb1f5 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 31 Aug 2015 17:20:52 +0300 Subject: [PATCH 18/53] fixed memory leaks in modules/features2d/test/test_nearestneighbors.cpp --- .../test/test_lshindex_flannbased_matcher.cpp | 12 +++++++++++- modules/features2d/test/test_nearestneighbors.cpp | 13 ++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/features2d/test/test_lshindex_flannbased_matcher.cpp b/modules/features2d/test/test_lshindex_flannbased_matcher.cpp index ddc81b0c5d..d1c6ea7e43 100644 --- a/modules/features2d/test/test_lshindex_flannbased_matcher.cpp +++ b/modules/features2d/test/test_lshindex_flannbased_matcher.cpp @@ -303,7 +303,8 @@ public: // // constructor // - CV_FeatureDetectorMatcherBaseTest(testparam* _tp, double _accuracy_margin, cv::Feature2D* _fe, cv::DescriptorMatcher *_flmatcher, string _flmatchername, int norm_type_for_bfmatcher) : + CV_FeatureDetectorMatcherBaseTest(testparam* _tp, double _accuracy_margin, cv::Feature2D* _fe, + cv::DescriptorMatcher *_flmatcher, string _flmatchername, int norm_type_for_bfmatcher) : tp(_tp), target_accuracy_margin_from_bfmatcher(_accuracy_margin), fe(_fe), @@ -318,6 +319,15 @@ public: bfmatcher = new cv::BFMatcher(norm_type_for_bfmatcher); } + virtual ~CV_FeatureDetectorMatcherBaseTest() + { + if (bfmatcher) + { + delete bfmatcher; + bfmatcher = NULL; + } + } + // // Main Test method // diff --git a/modules/features2d/test/test_nearestneighbors.cpp b/modules/features2d/test/test_nearestneighbors.cpp index b63bc6433e..bb1d51bf60 100644 --- a/modules/features2d/test/test_nearestneighbors.cpp +++ b/modules/features2d/test/test_nearestneighbors.cpp @@ -159,7 +159,7 @@ void NearestNeighborTest::run( int /*start_from*/ ) { class CV_KDTreeTest_CPP : public NearestNeighborTest { public: - CV_KDTreeTest_CPP() {} + CV_KDTreeTest_CPP() : NearestNeighborTest(), tr(NULL) {} protected: virtual void createModel( const Mat& data ); virtual int checkGetPoints( const Mat& data ); @@ -244,7 +244,7 @@ void CV_KDTreeTest_CPP::releaseModel() class CV_FlannTest : public NearestNeighborTest { public: - CV_FlannTest() {} + CV_FlannTest() : NearestNeighborTest(), index(NULL) { } protected: void createIndex( const Mat& data, const IndexParams& params ); int knnSearch( Mat& points, Mat& neighbors ); @@ -255,6 +255,9 @@ protected: void CV_FlannTest::createIndex( const Mat& data, const IndexParams& params ) { + // release previously allocated index + releaseModel(); + index = new Index( data, params ); } @@ -321,7 +324,11 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors ) void CV_FlannTest::releaseModel() { - delete index; + if (index) + { + delete index; + index = NULL; + } } //--------------------------------------- From 7e4e8921bc0749c030ba3913ae23af2204fd58c4 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 31 Aug 2015 17:30:42 +0300 Subject: [PATCH 19/53] fixed memory leak in descriptor regression tests --- .../features2d/test/test_descriptors_regression.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/features2d/test/test_descriptors_regression.cpp b/modules/features2d/test/test_descriptors_regression.cpp index 2185625ae9..a1c07f86bc 100644 --- a/modules/features2d/test/test_descriptors_regression.cpp +++ b/modules/features2d/test/test_descriptors_regression.cpp @@ -61,7 +61,7 @@ static void writeMatInBin( const Mat& mat, const string& filename ) fwrite( (void*)&mat.rows, sizeof(int), 1, f ); fwrite( (void*)&mat.cols, sizeof(int), 1, f ); fwrite( (void*)&type, sizeof(int), 1, f ); - int dataSize = (int)(mat.step * mat.rows * mat.channels()); + int dataSize = (int)(mat.step * mat.rows); fwrite( (void*)&dataSize, sizeof(int), 1, f ); fwrite( (void*)mat.data, 1, dataSize, f ); fclose(f); @@ -80,12 +80,15 @@ static Mat readMatFromBin( const string& filename ) size_t elements_read4 = fread( (void*)&dataSize, sizeof(int), 1, f ); CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1); - uchar* data = (uchar*)cvAlloc(dataSize); - size_t elements_read = fread( (void*)data, 1, dataSize, f ); + Mat returnMat(rows, cols, type); + CV_Assert(returnMat.step * returnMat.rows == (size_t)(dataSize)); + + size_t elements_read = fread( (void*)returnMat.data, 1, dataSize, f ); CV_Assert(elements_read == (size_t)(dataSize)); + fclose(f); - return Mat( rows, cols, type, data ); + return returnMat; } return Mat(); } From b5e42d8cc149796adb9cdc8400df6d6f1a9a324f Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 1 Sep 2015 11:26:25 +0300 Subject: [PATCH 20/53] fixed memory leak in ml module (cherry picked from commit d7bb1025f32ed268da7230cae3e8cb413dbab282) --- modules/ml/src/ertrees.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/ml/src/ertrees.cpp b/modules/ml/src/ertrees.cpp index d911834ee5..fe3e04ce90 100644 --- a/modules/ml/src/ertrees.cpp +++ b/modules/ml/src/ertrees.cpp @@ -537,6 +537,9 @@ void CvERTreeTrainData::set_data( const CvMat* _train_data, int _tflag, if( data ) delete data; + if ( pair16u32s_ptr ) + cvFree( &pair16u32s_ptr ); + if (_fdst) cvFree( &_fdst ); if (_idst) From ac33cd688cffd1c3fd541a67a758a84c90cf7bd7 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 1 Sep 2015 12:29:52 +0300 Subject: [PATCH 21/53] fixed memory leak in ANN (cherry picked from commit dfb49097e3013fa279d5882700601f5cabd6cbd8) --- modules/ml/src/ann_mlp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/ml/src/ann_mlp.cpp b/modules/ml/src/ann_mlp.cpp index 7323ab57a7..69e4448169 100644 --- a/modules/ml/src/ann_mlp.cpp +++ b/modules/ml/src/ann_mlp.cpp @@ -1535,6 +1535,10 @@ void CvANN_MLP::read( CvFileStorage* fs, CvFileNode* node ) _layer_sizes = (CvMat*)cvReadByName( fs, node, "layer_sizes" ); CV_CALL( create( _layer_sizes, SIGMOID_SYM, 0, 0 )); + + cvReleaseMat( &_layer_sizes ); + _layer_sizes = NULL; + l_count = layer_sizes->cols; CV_CALL( read_params( fs, node )); From 3c3bc123fc8508e1845d0a3e1ea85f66b1a36fc9 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 1 Sep 2015 13:04:33 +0300 Subject: [PATCH 22/53] release filestorage before exception (cherry picked from commit 3a1bb933401446b442348026b9cb680d35f3f449) --- modules/ml/src/svm.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/ml/src/svm.cpp b/modules/ml/src/svm.cpp index 0a5bfffa31..594a43a895 100644 --- a/modules/ml/src/svm.cpp +++ b/modules/ml/src/svm.cpp @@ -2315,7 +2315,12 @@ void CvSVM::write( CvFileStorage* fs, const char* name ) const params.svm_type == CvSVM::ONE_CLASS ? 1 : 0; const CvSVMDecisionFunc* df = decision_func; if( !isSvmModelApplicable(sv_total, var_all, var_count, class_count) ) + { + cvReleaseFileStorage( &fs ); + fs = NULL; + CV_ERROR( CV_StsParseError, "SVM model data is invalid, check sv_count, var_* and class_count tags" ); + } cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_SVM ); From 54693b3fa70c90acffbf9e13d135c5cc0a4665bd Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 1 Sep 2015 11:40:23 +0300 Subject: [PATCH 23/53] fixed memory leak in GBTrees (cherry picked from commit 1b8c2589c057f862008cd1a3be5c8802b7bf1994) --- modules/ml/src/gbt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ml/src/gbt.cpp b/modules/ml/src/gbt.cpp index 131eb43fee..aeaf6695af 100644 --- a/modules/ml/src/gbt.cpp +++ b/modules/ml/src/gbt.cpp @@ -1292,13 +1292,18 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector *resp ) return -FLT_MAX; float* pred_resp = 0; + bool needsFreeing = false; + if (resp) { resp->resize(n); pred_resp = &((*resp)[0]); } else + { pred_resp = new float[n]; + needsFreeing = true; + } Sample_predictor predictor = Sample_predictor(this, pred_resp, _data->get_values(), _data->get_missing(), _sample_idx); @@ -1331,6 +1336,9 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector *resp ) err = err / (float)n; } + if (needsFreeing) + delete[]pred_resp; + return err; } From d50c07e303d5bacbdfc5cfdda4767e7485106beb Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 1 Sep 2015 13:22:49 +0300 Subject: [PATCH 24/53] fixed "Conditional jump or move depends on uninitialised value(s)" in GBD (cherry picked from commit 887736bcd4365cff0531e6f763b604a1c6e92e25) --- modules/ml/src/gbt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ml/src/gbt.cpp b/modules/ml/src/gbt.cpp index aeaf6695af..9ed6b4c986 100644 --- a/modules/ml/src/gbt.cpp +++ b/modules/ml/src/gbt.cpp @@ -259,7 +259,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag, for (int i=1; idata.fl[i]) - class_labels->data.i[k]) && (kdata.fl[i]) - class_labels->data.i[k])) k++; if (k == j) { From c36582d2df34ed1da9bb04393b65124e37eee497 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 1 Sep 2015 16:17:18 +0300 Subject: [PATCH 25/53] fixed memory leak in flann index (cherry picked from commit 32d7c1950a562d038ff6f8b810ee46298a83fc39) --- modules/flann/src/miniflann.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/flann/src/miniflann.cpp b/modules/flann/src/miniflann.cpp index 5ce3e9051a..9bf503364d 100644 --- a/modules/flann/src/miniflann.cpp +++ b/modules/flann/src/miniflann.cpp @@ -318,12 +318,14 @@ buildIndex_(void*& index, const Mat& wholedata, const Mat& data, const IndexPara ::cvflann::Matrix dataset((ElementType*)data.data, data.rows, data.cols); - IndexType* _index = NULL; - if( !index || getParam(params, "algorithm", FLANN_INDEX_LINEAR) != FLANN_INDEX_LSH) // currently, additional index support is the lsh algorithm only. + // currently, additional index support is the lsh algorithm only. + if( !index || getParam(params, "algorithm", FLANN_INDEX_LINEAR) != FLANN_INDEX_LSH) { - _index = new IndexType(dataset, get_params(params), dist); + Ptr _index = makePtr(dataset, get_params(params), dist); _index->buildIndex(); index = _index; + // HACK to prevent object destruction + _index.obj = NULL; } else // build additional lsh index { From a81f0a51237b8772cfc350a9a91fb15a42215781 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 3 Sep 2015 13:25:29 +0300 Subject: [PATCH 26/53] fixed uninitialized memory writing/reading in flann (cherry picked from commit 3934d61de7d34e9ac8040cf5ced349a51ad2e520) --- modules/flann/include/opencv2/flann/kmeans_index.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/flann/include/opencv2/flann/kmeans_index.h b/modules/flann/include/opencv2/flann/kmeans_index.h index 9c0f4e2df8..e119ceb291 100644 --- a/modules/flann/include/opencv2/flann/kmeans_index.h +++ b/modules/flann/include/opencv2/flann/kmeans_index.h @@ -384,6 +384,8 @@ public: } root_ = pool_.allocate(); + std::memset(root_, 0, sizeof(KMeansNode)); + computeNodeStatistics(root_, indices_, (int)size_); computeClustering(root_, indices_, (int)size_, branching_,0); } @@ -823,11 +825,11 @@ private: variance -= distance_(centers[c], ZeroIterator(), veclen_); node->childs[c] = pool_.allocate(); + std::memset(node->childs[c], 0, sizeof(KMeansNode)); node->childs[c]->radius = radiuses[c]; node->childs[c]->pivot = centers[c]; node->childs[c]->variance = variance; node->childs[c]->mean_radius = mean_radius; - node->childs[c]->indices = NULL; computeClustering(node->childs[c],indices+start, end-start, branching, level+1); start=end; } From 0422054aa196347b706d682e223605d76ca38c64 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 3 Sep 2015 19:13:00 +0300 Subject: [PATCH 27/53] fixed warnings in gpu module (cherry picked from commit 6a05939e1ce552008ecf95451ddf362f2be7a4c3) --- modules/gpu/src/element_operations.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/gpu/src/element_operations.cpp b/modules/gpu/src/element_operations.cpp index 780745d733..280f85a36a 100644 --- a/modules/gpu/src/element_operations.cpp +++ b/modules/gpu/src/element_operations.cpp @@ -2804,7 +2804,7 @@ void cv::gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, St } else { - const int elem_size = src.elemSize1(); + const int elem_size = static_cast(src.elemSize1()); const int num_channels = src.channels(); const int bcols = src.cols * num_channels; @@ -2895,7 +2895,7 @@ void cv::gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c } else { - const int elem_size = src1.elemSize1(); + const int elem_size = static_cast(src1.elemSize1()); const int num_channels = src1.channels(); const int bcols = src1.cols * num_channels; @@ -2979,7 +2979,7 @@ void cv::gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, co } else { - const int elem_size = src1.elemSize1(); + const int elem_size = static_cast(src1.elemSize1()); const int num_channels = src1.channels(); const int bcols = src1.cols * num_channels; @@ -3063,7 +3063,7 @@ void cv::gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c } else { - const int elem_size = src1.elemSize1(); + const int elem_size = static_cast(src1.elemSize1()); const int num_channels = src1.channels(); const int bcols = src1.cols * num_channels; From f4ffcae8d98035cb79d64eb37de5eab6b55690e1 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 3 Sep 2015 17:21:04 +0300 Subject: [PATCH 28/53] initialize padding of CvString with zeros (cherry picked from commit 7b1eb3af7bb82dfd9258f6abdec350688cf65b51) --- modules/core/src/datastructs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp index 76c3b2c371..ddadd39691 100644 --- a/modules/core/src/datastructs.cpp +++ b/modules/core/src/datastructs.cpp @@ -346,6 +346,7 @@ CV_IMPL CvString cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, int len ) { CvString str; + memset(&str, 0, sizeof(CvString)); str.len = len >= 0 ? len : (int)strlen(ptr); str.ptr = (char*)cvMemStorageAlloc( storage, str.len + 1 ); From c7b471f10f41bfbb63309bce7378582f220e1593 Mon Sep 17 00:00:00 2001 From: Elena Shipunova Date: Mon, 7 Sep 2015 13:50:30 +0300 Subject: [PATCH 29/53] do not proceed with removing zero-length slice (cherry picked from commit 036c3b4e6d45dcf81181bb2658601f758c976088) --- modules/core/src/datastructs.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp index ddadd39691..3e0bf47f4c 100644 --- a/modules/core/src/datastructs.cpp +++ b/modules/core/src/datastructs.cpp @@ -1689,6 +1689,9 @@ cvSeqRemoveSlice( CvSeq* seq, CvSlice slice ) slice.end_index = slice.start_index + length; + if ( slice.start_index == slice.end_index ) + return; + if( slice.end_index < total ) { CvSeqReader reader_to, reader_from; From 558054a53d9df34960b587b0bbeaeadcde1b729d Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 8 Sep 2015 16:04:28 +0300 Subject: [PATCH 30/53] fix for gpu::StereoBeliefPropogation: use continuous memory for internal buffers (cherry picked from commit e2a9df408f712f694206974a1f24a864881371c3) --- modules/gpu/src/stereobp.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/gpu/src/stereobp.cpp b/modules/gpu/src/stereobp.cpp index 3b827a3129..dde69d6d44 100644 --- a/modules/gpu/src/stereobp.cpp +++ b/modules/gpu/src/stereobp.cpp @@ -158,7 +158,7 @@ namespace init(stream); - datas[0].create(rows * rthis.ndisp, cols, rthis.msg_type); + createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, datas[0]); comp_data_callers[rthis.msg_type == CV_32F][left.channels()](left, right, datas[0], StreamAccessor::getStream(stream)); @@ -187,10 +187,10 @@ namespace private: void init(Stream& stream) { - u.create(rows * rthis.ndisp, cols, rthis.msg_type); - d.create(rows * rthis.ndisp, cols, rthis.msg_type); - l.create(rows * rthis.ndisp, cols, rthis.msg_type); - r.create(rows * rthis.ndisp, cols, rthis.msg_type); + createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, u); + createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, d); + createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, l); + createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, r); if (rthis.levels & 1) { @@ -216,10 +216,10 @@ namespace int less_rows = rows / 2; int less_cols = cols / 2; - u2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); - d2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); - l2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); - r2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); + createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, u2); + createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, d2); + createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, l2); + createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, r2); if ((rthis.levels & 1) == 0) { @@ -286,7 +286,7 @@ namespace cols_all[i] = cols_all[i-1] / 2; rows_all[i] = rows_all[i-1] / 2; - datas[i].create(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type); + createContinuous(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type, datas[i]); data_step_down_callers[funcIdx](cols_all[i], rows_all[i], rows_all[i-1], datas[i-1], datas[i], cudaStream); } From c22cc67ba8b549e4883e2f6a40495ba3db465a77 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 10 Sep 2015 10:05:04 +0300 Subject: [PATCH 31/53] revert previous change in gpu::StereoBeliefPropogation (cherry picked from commit f903192c17b1c70182c0c25bb156900ea82b731b) --- modules/gpu/src/stereobp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/gpu/src/stereobp.cpp b/modules/gpu/src/stereobp.cpp index dde69d6d44..0864fbcadc 100644 --- a/modules/gpu/src/stereobp.cpp +++ b/modules/gpu/src/stereobp.cpp @@ -213,8 +213,8 @@ namespace if (rthis.levels > 1) { - int less_rows = rows / 2; - int less_cols = cols / 2; + int less_rows = (rows + 1) / 2; + int less_cols = (cols + 1) / 2; createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, u2); createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, d2); @@ -283,8 +283,8 @@ namespace for (int i = 1; i < rthis.levels; ++i) { - cols_all[i] = cols_all[i-1] / 2; - rows_all[i] = rows_all[i-1] / 2; + cols_all[i] = (cols_all[i-1] + 1) / 2; + rows_all[i] = (rows_all[i-1] + 1) / 2; createContinuous(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type, datas[i]); From 3494d640df0a6f3df03f29fcfc059a25c365fba5 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 10 Sep 2015 10:05:25 +0300 Subject: [PATCH 32/53] add extra checks to data_step_down to prevent out-of-border access (cherry picked from commit 3ef067cc65cd548a968588f72d3b9ecc92a0e9bb) --- modules/gpu/src/cuda/stereobp.cu | 18 +++++++++--------- modules/gpu/src/stereobp.cpp | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/gpu/src/cuda/stereobp.cu b/modules/gpu/src/cuda/stereobp.cu index 05a19b4199..d011c7f4fe 100644 --- a/modules/gpu/src/cuda/stereobp.cu +++ b/modules/gpu/src/cuda/stereobp.cu @@ -255,7 +255,7 @@ namespace cv { namespace gpu { namespace device /////////////////////////////////////////////////////////////// template - __global__ void data_step_down(int dst_cols, int dst_rows, int src_rows, const PtrStep src, PtrStep dst) + __global__ void data_step_down(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStep src, PtrStep dst) { const int x = blockIdx.x * blockDim.x + threadIdx.x; const int y = blockIdx.y * blockDim.y + threadIdx.y; @@ -264,10 +264,10 @@ namespace cv { namespace gpu { namespace device { for (int d = 0; d < cndisp; ++d) { - float dst_reg = src.ptr(d * src_rows + (2*y+0))[(2*x+0)]; - dst_reg += src.ptr(d * src_rows + (2*y+1))[(2*x+0)]; - dst_reg += src.ptr(d * src_rows + (2*y+0))[(2*x+1)]; - dst_reg += src.ptr(d * src_rows + (2*y+1))[(2*x+1)]; + float dst_reg = src.ptr(d * src_rows + ::min(2*y+0, src_rows-1))[::min(2*x+0, src_cols-1)]; + dst_reg += src.ptr(d * src_rows + ::min(2*y+1, src_rows-1))[::min(2*x+0, src_cols-1)]; + dst_reg += src.ptr(d * src_rows + ::min(2*y+0, src_rows-1))[::min(2*x+1, src_cols-1)]; + dst_reg += src.ptr(d * src_rows + ::min(2*y+1, src_rows-1))[::min(2*x+1, src_cols-1)]; dst.ptr(d * dst_rows + y)[x] = saturate_cast(dst_reg); } @@ -275,7 +275,7 @@ namespace cv { namespace gpu { namespace device } template - void data_step_down_gpu(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream) + void data_step_down_gpu(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream) { dim3 threads(32, 8, 1); dim3 grid(1, 1, 1); @@ -283,15 +283,15 @@ namespace cv { namespace gpu { namespace device grid.x = divUp(dst_cols, threads.x); grid.y = divUp(dst_rows, threads.y); - data_step_down<<>>(dst_cols, dst_rows, src_rows, (PtrStepSz)src, (PtrStepSz)dst); + data_step_down<<>>(dst_cols, dst_rows, src_cols, src_rows, (PtrStepSz)src, (PtrStepSz)dst); cudaSafeCall( cudaGetLastError() ); if (stream == 0) cudaSafeCall( cudaDeviceSynchronize() ); } - template void data_step_down_gpu(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); - template void data_step_down_gpu(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); + template void data_step_down_gpu(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); + template void data_step_down_gpu(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); /////////////////////////////////////////////////////////////// /////////////////// level up messages //////////////////////// diff --git a/modules/gpu/src/stereobp.cpp b/modules/gpu/src/stereobp.cpp index 0864fbcadc..2bcefe3770 100644 --- a/modules/gpu/src/stereobp.cpp +++ b/modules/gpu/src/stereobp.cpp @@ -67,7 +67,7 @@ namespace cv { namespace gpu { namespace device template void comp_data_gpu(const PtrStepSzb& left, const PtrStepSzb& right, const PtrStepSzb& data, cudaStream_t stream); template - void data_step_down_gpu(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); + void data_step_down_gpu(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); template void level_up_messages_gpu(int dst_idx, int dst_cols, int dst_rows, int src_rows, PtrStepSzb* mus, PtrStepSzb* mds, PtrStepSzb* mls, PtrStepSzb* mrs, cudaStream_t stream); template @@ -253,7 +253,7 @@ namespace void calcBP(GpuMat& disp, Stream& stream) { - typedef void (*data_step_down_t)(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); + typedef void (*data_step_down_t)(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream); static const data_step_down_t data_step_down_callers[2] = { data_step_down_gpu, data_step_down_gpu @@ -288,7 +288,7 @@ namespace createContinuous(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type, datas[i]); - data_step_down_callers[funcIdx](cols_all[i], rows_all[i], rows_all[i-1], datas[i-1], datas[i], cudaStream); + data_step_down_callers[funcIdx](cols_all[i], rows_all[i], cols_all[i-1], rows_all[i-1], datas[i-1], datas[i], cudaStream); } PtrStepSzb mus[] = {u, u2}; From 7746d9b7ccfad2a7ae901aadd934f81b93eb701f Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 2 Sep 2015 18:15:05 +0300 Subject: [PATCH 33/53] fix for corrent modules dependencies (cherry picked from commit 1c3d83df54d2f39c9403126bf3c1374eaf749dee) --- cmake/OpenCVModule.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index ec834d9090..cae2a39c9d 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -49,6 +49,8 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD if(HAVE_${mod}) unset(HAVE_${mod} CACHE) endif() + unset(OPENCV_MODULE_${mod}_DEPS CACHE) + unset(OPENCV_MODULE_${mod}_DEPS_EXT CACHE) unset(OPENCV_MODULE_${mod}_REQ_DEPS CACHE) unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE) unset(OPENCV_MODULE_${mod}_PRIVATE_REQ_DEPS CACHE) From e6f3f3c029bc7cc5e5fe1aad072f96d08a8ebba0 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 17 Sep 2015 14:02:36 +0300 Subject: [PATCH 34/53] OpenCV version++. --- 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 7457da76a9..096b66e97a 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 12 -#define CV_VERSION_REVISION 1 +#define CV_VERSION_REVISION 2 #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) From 7d28541bbeed68647d0294a829f3d8dc9253cf2c Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 17 Sep 2015 18:17:06 +0300 Subject: [PATCH 35/53] test2.py: fail if a downloaded image can't be decoded (cherry picked from commit 56f17e4921a379317a0602d92d7ca3677cabe9d6) --- modules/python/test/test2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/python/test/test2.py b/modules/python/test/test2.py index 9126160948..d0912cd618 100644 --- a/modules/python/test/test2.py +++ b/modules/python/test/test2.py @@ -22,7 +22,9 @@ class NewOpenCVTests(unittest.TestCase): def get_sample(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR): if not filename in self.image_cache: filedata = urllib.urlopen("https://raw.github.com/Itseez/opencv/2.4/" + filename).read() - self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor) + image = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor) + self.assertFalse(image is None) + self.image_cache[filename] = image return self.image_cache[filename] def setUp(self): From c5d009d6c4ddf03f4b45acc544b436ca004a41f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hajo=20Nils=20Krabbenho=CC=88ft?= Date: Wed, 16 Sep 2015 22:04:42 +0200 Subject: [PATCH 36/53] fix crash for large BW tif images (cherry picked from commit d38fee759928d631ea2947c67e5ee9eb347693b6) --- modules/highgui/src/grfmt_tiff.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/highgui/src/grfmt_tiff.cpp b/modules/highgui/src/grfmt_tiff.cpp index eeee318c79..067f22de2f 100644 --- a/modules/highgui/src/grfmt_tiff.cpp +++ b/modules/highgui/src/grfmt_tiff.cpp @@ -221,6 +221,11 @@ bool TiffDecoder::readData( Mat& img ) (!is_tiled && tile_height0 == std::numeric_limits::max()) ) tile_height0 = m_height; + if(dst_bpp == 8) { + // we will use TIFFReadRGBA* functions, so allocate temporary buffer for 32bit RGBA + bpp = 8; + ncn = 4; + } const size_t buffer_size = bpp * ncn * tile_height0 * tile_width0; AutoBuffer _buffer( buffer_size ); uchar* buffer = _buffer; From 2fc0ce5c246a70c83691e7f1afd689457e25e70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hajo=20Nils=20Krabbenho=CC=88ft?= Date: Wed, 16 Sep 2015 22:19:51 +0200 Subject: [PATCH 37/53] buffer_size should be in bytes, not bits (cherry picked from commit 7825cbeb7d70c2e1e558808d7433ece414394177) --- modules/highgui/src/grfmt_tiff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/grfmt_tiff.cpp b/modules/highgui/src/grfmt_tiff.cpp index 067f22de2f..c7639fe345 100644 --- a/modules/highgui/src/grfmt_tiff.cpp +++ b/modules/highgui/src/grfmt_tiff.cpp @@ -226,7 +226,7 @@ bool TiffDecoder::readData( Mat& img ) bpp = 8; ncn = 4; } - const size_t buffer_size = bpp * ncn * tile_height0 * tile_width0; + const size_t buffer_size = (bpp/bitsPerByte) * ncn * tile_height0 * tile_width0; AutoBuffer _buffer( buffer_size ); uchar* buffer = _buffer; ushort* buffer16 = (ushort*)buffer; From 33cd7f38a8f19b308cc72fc141eab5b5df798ad3 Mon Sep 17 00:00:00 2001 From: robertxwu Date: Mon, 21 Sep 2015 13:57:25 -0700 Subject: [PATCH 38/53] re-submit (cherry picked from commit 4a68cc1675990c46cf53a66f137cb8da09022e4b) --- modules/calib3d/src/calibinit.cpp | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index 5e6ea1d289..000ac5435d 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -152,7 +152,7 @@ struct CvCBQuad //static CvMat* debug_img = 0; static int icvGenerateQuads( CvCBQuad **quads, CvCBCorner **corners, - CvMemStorage *storage, CvMat *image, int flags ); + CvMemStorage *storage, CvMat *image, int flags, int *max_quad_buf_size); /*static int icvGenerateQuadsEx( CvCBQuad **out_quads, CvCBCorner **out_corners, @@ -172,7 +172,7 @@ static int icvCleanFoundConnectedQuads( int quad_count, static int icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads, int *all_count, CvCBQuad **all_quads, CvCBCorner **corners, - CvSize pattern_size, CvMemStorage* storage ); + CvSize pattern_size, int max_quad_buf_size, CvMemStorage* storage ); static void icvOrderQuad(CvCBQuad *quad, CvCBCorner *corner, int common); @@ -183,7 +183,7 @@ static int icvTrimRow(CvCBQuad **quads, int count, int row, int dir); #endif static int icvAddOuterQuad(CvCBQuad *quad, CvCBQuad **quads, int quad_count, - CvCBQuad **all_quads, int all_count, CvCBCorner **corners); + CvCBQuad **all_quads, int all_count, CvCBCorner **corners, int max_quad_buf_size); static void icvRemoveQuadFromGroup(CvCBQuad **quads, int count, CvCBQuad *q0); @@ -313,6 +313,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size, // making it difficult to detect smaller squares. for( k = 0; k < 6; k++ ) { + int max_quad_buf_size = 0; for( dilations = min_dilations; dilations <= max_dilations; dilations++ ) { if (found) @@ -368,7 +369,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size, cvRectangle( thresh_img, cvPoint(0,0), cvPoint(thresh_img->cols-1, thresh_img->rows-1), CV_RGB(255,255,255), 3, 8); - quad_count = icvGenerateQuads( &quads, &corners, storage, thresh_img, flags ); + quad_count = icvGenerateQuads( &quads, &corners, storage, thresh_img, flags, &max_quad_buf_size); PRINTF("Quad count: %d/%d\n", quad_count, expected_corners_num); } @@ -408,8 +409,8 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size, // allocate extra for adding in icvOrderFoundQuads cvFree(&quad_group); cvFree(&corner_group); - quad_group = (CvCBQuad**)cvAlloc( sizeof(quad_group[0]) * (quad_count+quad_count / 2)); - corner_group = (CvCBCorner**)cvAlloc( sizeof(corner_group[0]) * (quad_count+quad_count / 2)*4 ); + quad_group = (CvCBQuad**)cvAlloc( sizeof(quad_group[0]) * max_quad_buf_size); + corner_group = (CvCBCorner**)cvAlloc( sizeof(corner_group[0]) * max_quad_buf_size * 4 ); for( group_idx = 0; ; group_idx++ ) { @@ -424,7 +425,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size, // maybe delete or add some PRINTF("Starting ordering of inner quads\n"); count = icvOrderFoundConnectedQuads(count, quad_group, &quad_count, &quads, &corners, - pattern_size, storage ); + pattern_size, max_quad_buf_size, storage ); PRINTF("Orig count: %d After ordering: %d\n", icount, count); @@ -623,7 +624,7 @@ icvCheckBoardMonotony( CvPoint2D32f* corners, CvSize pattern_size ) static int icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads, int *all_count, CvCBQuad **all_quads, CvCBCorner **corners, - CvSize pattern_size, CvMemStorage* storage ) + CvSize pattern_size, int max_quad_buf_size, CvMemStorage* storage ) { cv::Ptr temp_storage = cvCreateChildMemStorage( storage ); CvSeq* stack = cvCreateSeq( 0, sizeof(*stack), sizeof(void*), temp_storage ); @@ -803,15 +804,18 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads, if (found > 0) { PRINTF("Found %d inner quads not connected to outer quads, repairing\n", found); - for (int i=0; icount < 4 && quads[i]->ordered) { - int added = icvAddOuterQuad(quads[i],quads,quad_count,all_quads,*all_count,corners); + int added = icvAddOuterQuad(quads[i],quads,quad_count,all_quads,*all_count,corners, max_quad_buf_size); *all_count += added; quad_count += added; } } + + if (*all_count >= max_quad_buf_size) + return 0; } @@ -854,11 +858,11 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads, static int icvAddOuterQuad( CvCBQuad *quad, CvCBQuad **quads, int quad_count, - CvCBQuad **all_quads, int all_count, CvCBCorner **corners ) + CvCBQuad **all_quads, int all_count, CvCBCorner **corners, int max_quad_buf_size ) { int added = 0; - for (int i=0; i<4; i++) // find no-neighbor corners + for (int i=0; i<4 && all_count < max_quad_buf_size; i++) // find no-neighbor corners { if (!quad->neighbors[i]) // ok, create and add neighbor { @@ -1649,7 +1653,7 @@ static void icvFindQuadNeighbors( CvCBQuad *quads, int quad_count ) static int icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners, - CvMemStorage *storage, CvMat *image, int flags ) + CvMemStorage *storage, CvMat *image, int flags, int *max_quad_buf_size ) { int quad_count = 0; cv::Ptr temp_storage; @@ -1754,8 +1758,9 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners, cvEndFindContours( &scanner ); // allocate quad & corner buffers - *out_quads = (CvCBQuad*)cvAlloc((root->total+root->total / 2) * sizeof((*out_quads)[0])); - *out_corners = (CvCBCorner*)cvAlloc((root->total+root->total / 2) * 4 * sizeof((*out_corners)[0])); + *max_quad_buf_size = MAX(1, (root->total+root->total / 2)) * 2; + *out_quads = (CvCBQuad*)cvAlloc(*max_quad_buf_size * sizeof((*out_quads)[0])); + *out_corners = (CvCBCorner*)cvAlloc(*max_quad_buf_size * 4 * sizeof((*out_corners)[0])); // Create array of quads structures for( idx = 0; idx < root->total; idx++ ) From 2243bfa181dec54bf6cecca4f99a94296f807127 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 15 Aug 2015 18:30:08 +0300 Subject: [PATCH 39/53] repaired gstreamer camera capture: 1. Enabled property retrieval: height, width, FPS 2. Fixed issue when isOpened returns always true even for non-existing devices 3. Ability to work with non-0 device. Camera capture index is taken into account (cherry picked from commit dbd7912b88e36a045d1086d54f77467de5ab006f) --- modules/highgui/src/cap.cpp | 6 +- modules/highgui/src/cap_gstreamer.cpp | 130 ++++++++++++++++---------- 2 files changed, 83 insertions(+), 53 deletions(-) diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index 491e388559..5c17848e8d 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -238,10 +238,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) #endif #ifdef HAVE_GSTREAMER - capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, 0); + capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, + reinterpret_cast(index)); if (capture) return capture; - capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, 0); + capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, + reinterpret_cast(index)); if (capture) return capture; #endif diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp index cae719996e..fe4eaf25e3 100644 --- a/modules/highgui/src/cap_gstreamer.cpp +++ b/modules/highgui/src/cap_gstreamer.cpp @@ -371,9 +371,7 @@ void CvCapture_GStreamer::startPipeline() if (status == GST_STATE_CHANGE_ASYNC) { // wait for status update - GstState st1; - GstState st2; - status = gst_element_get_state(pipeline, &st1, &st2, GST_CLOCK_TIME_NONE); + status = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); } if (status == GST_STATE_CHANGE_FAILURE) { @@ -568,21 +566,39 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) GstElementFactory * testfac; GstStateChangeReturn status; - if (type == CV_CAP_GSTREAMER_V4L){ + int cameraID = -1; + if (type == CV_CAP_GSTREAMER_V4L || + type == CV_CAP_GSTREAMER_V4L2) + { + cameraID = static_cast(reinterpret_cast(filename)); + } + + std::stringstream stdstream; + std::string stdfilename; + + if (type == CV_CAP_GSTREAMER_V4L) + { testfac = gst_element_factory_find("v4lsrc"); if (!testfac){ return false; } g_object_unref(G_OBJECT(testfac)); - filename = "v4lsrc ! "COLOR_ELEM" ! appsink"; + + stdstream << "v4lsrc device=/dev/video" << cameraID << " ! " << COLOR_ELEM << " ! appsink"; + stdfilename = stdstream.str(); + filename = stdfilename.c_str(); } - if (type == CV_CAP_GSTREAMER_V4L2){ + else if (type == CV_CAP_GSTREAMER_V4L2) + { testfac = gst_element_factory_find("v4l2src"); if (!testfac){ return false; } g_object_unref(G_OBJECT(testfac)); - filename = "v4l2src ! "COLOR_ELEM" ! appsink"; + + stdstream << "v4l2src device=/dev/video" << cameraID << " ! " << COLOR_ELEM << " ! appsink"; + stdfilename = stdstream.str(); + filename = stdfilename.c_str(); } @@ -620,7 +636,9 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) stream = true; manualpipeline = true; } - } else { + } + else + { stream = true; uri = g_strdup(filename); } @@ -641,64 +659,77 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) uridecodebin = gst_element_make_from_uri(GST_URI_SRC, uri, "src", NULL); #endif element_from_uri = true; - }else{ + } + else + { uridecodebin = gst_element_factory_make("uridecodebin", NULL); g_object_set(G_OBJECT(uridecodebin), "uri", uri, NULL); } g_free(protocol); - if(!uridecodebin) { + if(!uridecodebin) + { //fprintf(stderr, "GStreamer: Error opening bin: %s\n", err->message); close(); return false; } } - if(manualpipeline) + if (manualpipeline) { GstIterator *it = NULL; #if GST_VERSION_MAJOR == 0 it = gst_bin_iterate_sinks(GST_BIN(uridecodebin)); - if(gst_iterator_next(it, (gpointer *)&sink) != GST_ITERATOR_OK) { + if (gst_iterator_next(it, (gpointer *)&sink) != GST_ITERATOR_OK) + { CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n"); return false; } #else - it = gst_bin_iterate_sinks (GST_BIN(uridecodebin)); + it = gst_bin_iterate_elements(GST_BIN(uridecodebin)); - gboolean done = FALSE; + gboolean done = false; GstElement *element = NULL; gchar* name = NULL; GValue value = G_VALUE_INIT; - while (!done) { - switch (gst_iterator_next (it, &value)) { + while (!done) + { + switch (gst_iterator_next (it, &value)) + { case GST_ITERATOR_OK: - element = GST_ELEMENT (g_value_get_object (&value)); - name = gst_element_get_name(element); - if (name){ - if(strstr(name, "opencvsink") != NULL || strstr(name, "appsink") != NULL) { - sink = GST_ELEMENT ( gst_object_ref (element) ); - done = TRUE; + element = GST_ELEMENT (g_value_get_object (&value)); + name = gst_element_get_name(element); + if (name) + { + if (strstr(name, "opencvsink") != NULL || strstr(name, "appsink") != NULL) + { + sink = GST_ELEMENT ( gst_object_ref (element) ); + done = sink && color; + } + else if (strstr(name, COLOR_ELEM) != NULL) + { + color = GST_ELEMENT ( gst_object_ref (element) ); + done = sink && color; + } + g_free(name); } - g_free(name); - } - g_value_unset (&value); + g_value_unset (&value); - break; + break; case GST_ITERATOR_RESYNC: - gst_iterator_resync (it); - break; + gst_iterator_resync (it); + break; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: - done = TRUE; - break; - } + done = TRUE; + break; + } } gst_iterator_free (it); - - if (!sink){ + if (!sink) + { CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n"); return false; } @@ -715,18 +746,23 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) gst_bin_add_many(GST_BIN(pipeline), uridecodebin, color, sink, NULL); - if(element_from_uri) { - if(!gst_element_link(uridecodebin, color)) { + if(element_from_uri) + { + if(!gst_element_link(uridecodebin, color)) + { CV_ERROR(CV_StsError, "GStreamer: cannot link color -> sink\n"); gst_object_unref(pipeline); pipeline = NULL; return false; } - }else{ + } + else + { g_signal_connect(uridecodebin, "pad-added", G_CALLBACK(newPad), color); } - if(!gst_element_link(color, sink)) { + if(!gst_element_link(color, sink)) + { CV_ERROR(CV_StsError, "GStreamer: cannot link color -> sink\n"); gst_object_unref(pipeline); pipeline = NULL; @@ -754,16 +790,13 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) gst_app_sink_set_caps(GST_APP_SINK(sink), caps); gst_caps_unref(caps); - // For video files only: set pipeline to PAUSED state to get its duration - if (file) { - status = gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PAUSED); + status = gst_element_set_state(GST_ELEMENT(pipeline), + file ? GST_STATE_PAUSED : GST_STATE_PLAYING); if (status == GST_STATE_CHANGE_ASYNC) { // wait for status update - GstState st1; - GstState st2; - status = gst_element_get_state(pipeline, &st1, &st2, GST_CLOCK_TIME_NONE); + status = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); } if (status == GST_STATE_CHANGE_FAILURE) { @@ -814,14 +847,9 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) fps = (double)num/(double)denom; - // GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); - } - else - { - duration = -1; - width = -1; - height = -1; - fps = -1; + // GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline") + + stopPipeline(); } __END__; From 9a3e53e7386b7a94976d216dae41ddb48600db3d Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 16 Aug 2015 21:01:22 +0300 Subject: [PATCH 40/53] repaired GStreamer 0.10 version (cherry picked from commit c19ed39a785d7ac9e39c117cfacc3827024619f7) --- cmake/OpenCVFindLibsVideo.cmake | 6 +++--- modules/highgui/src/cap_gstreamer.cpp | 30 +++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 1654df73ca..514aa5cd3d 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -12,8 +12,8 @@ endif(WITH_VFW) # --- GStreamer --- ocv_clear_vars(HAVE_GSTREAMER) -# try to find gstreamer 1.x first -if(WITH_GSTREAMER) +# try to find gstreamer 1.x first if 0.10 was not requested +if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10) CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE) CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO) CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP) @@ -29,7 +29,7 @@ if(WITH_GSTREAMER) set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION}) endif() -endif(WITH_GSTREAMER) +endif() # gstreamer support was requested but could not find gstreamer 1.x, # so fallback/try to find gstreamer 0.10 diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp index fe4eaf25e3..957587c219 100644 --- a/modules/highgui/src/cap_gstreamer.cpp +++ b/modules/highgui/src/cap_gstreamer.cpp @@ -75,10 +75,13 @@ #if GST_VERSION_MAJOR == 0 #define COLOR_ELEM "ffmpegcolorspace" +#define COLOR_ELEM_NAME "ffmpegcsp" #elif FULL_GST_VERSION < VERSION_NUM(1,5,0) #define COLOR_ELEM "videoconvert" +#define COLOR_ELEM_NAME COLOR_ELEM #else #define COLOR_ELEM "autovideoconvert" +#define COLOR_ELEM_NAME COLOR_ELEM #endif void toFraction(double decimal, double &numerator, double &denominator); @@ -677,28 +680,27 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) if (manualpipeline) { - GstIterator *it = NULL; -#if GST_VERSION_MAJOR == 0 - it = gst_bin_iterate_sinks(GST_BIN(uridecodebin)); - if (gst_iterator_next(it, (gpointer *)&sink) != GST_ITERATOR_OK) - { - CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n"); - return false; - } -#else - it = gst_bin_iterate_elements(GST_BIN(uridecodebin)); + GstIterator *it = gst_bin_iterate_elements(GST_BIN(uridecodebin)); - gboolean done = false; GstElement *element = NULL; + gboolean done = false; gchar* name = NULL; +#if GST_VERSION_MAJOR > 0 GValue value = G_VALUE_INIT; +#endif while (!done) { +#if GST_VERSION_MAJOR > 0 switch (gst_iterator_next (it, &value)) { case GST_ITERATOR_OK: element = GST_ELEMENT (g_value_get_object (&value)); +#else + switch (gst_iterator_next (it, (gpointer *)&element)) + { + case GST_ITERATOR_OK: +#endif name = gst_element_get_name(element); if (name) { @@ -707,14 +709,16 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) sink = GST_ELEMENT ( gst_object_ref (element) ); done = sink && color; } - else if (strstr(name, COLOR_ELEM) != NULL) + else if (strstr(name, COLOR_ELEM_NAME) != NULL) { color = GST_ELEMENT ( gst_object_ref (element) ); done = sink && color; } g_free(name); } +#if GST_VERSION_MAJOR > 0 g_value_unset (&value); +#endif break; case GST_ITERATOR_RESYNC: @@ -733,7 +737,7 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n"); return false; } -#endif + pipeline = uridecodebin; } else From 56654ae360b7ecdb658398fd5efd5a0c76ada71d Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 16 Aug 2015 21:25:36 +0300 Subject: [PATCH 41/53] added some property setting and getting (cherry picked from commit 75fcedf0edbc83a900918de1a25195eaefc214f5) --- modules/highgui/src/cap_gstreamer.cpp | 50 +++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp index 957587c219..cab652dfd2 100644 --- a/modules/highgui/src/cap_gstreamer.cpp +++ b/modules/highgui/src/cap_gstreamer.cpp @@ -145,6 +145,7 @@ protected: gpointer data); GstElement* pipeline; GstElement* uridecodebin; + GstElement* v4l2src; GstElement* color; GstElement* sink; #if GST_VERSION_MAJOR > 0 @@ -168,6 +169,7 @@ void CvCapture_GStreamer::init() { pipeline = NULL; uridecodebin = NULL; + v4l2src = NULL; color = NULL; sink = NULL; #if GST_VERSION_MAJOR > 0 @@ -707,14 +709,18 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) if (strstr(name, "opencvsink") != NULL || strstr(name, "appsink") != NULL) { sink = GST_ELEMENT ( gst_object_ref (element) ); - done = sink && color; } else if (strstr(name, COLOR_ELEM_NAME) != NULL) { color = GST_ELEMENT ( gst_object_ref (element) ); - done = sink && color; + } + else if (strstr(name, "v4l") != NULL) + { + v4l2src = GST_ELEMENT ( gst_object_ref (element) ); } g_free(name); + + done = sink && color && v4l2src; } #if GST_VERSION_MAJOR > 0 g_value_unset (&value); @@ -884,7 +890,7 @@ double CvCapture_GStreamer::getProperty( int propId ) if(!pipeline) { CV_WARN("GStreamer: no pipeline"); - return false; + return 0; } switch(propId) { @@ -893,7 +899,7 @@ double CvCapture_GStreamer::getProperty( int propId ) status = gst_element_query_position(sink, FORMAT, &value); if(!status) { CV_WARN("GStreamer: unable to query position of stream"); - return false; + return 0; } return value * 1e-6; // nano seconds to milli seconds case CV_CAP_PROP_POS_FRAMES: @@ -901,7 +907,7 @@ double CvCapture_GStreamer::getProperty( int propId ) status = gst_element_query_position(sink, FORMAT, &value); if(!status) { CV_WARN("GStreamer: unable to query position of stream"); - return false; + return 0; } return value; case CV_CAP_PROP_POS_AVI_RATIO: @@ -909,7 +915,7 @@ double CvCapture_GStreamer::getProperty( int propId ) status = gst_element_query_position(sink, FORMAT, &value); if(!status) { CV_WARN("GStreamer: unable to query position of stream"); - return false; + return 0; } return ((double) value) / GST_FORMAT_PERCENT_MAX; case CV_CAP_PROP_FRAME_WIDTH: @@ -928,6 +934,21 @@ double CvCapture_GStreamer::getProperty( int propId ) case CV_CAP_PROP_CONTRAST: case CV_CAP_PROP_SATURATION: case CV_CAP_PROP_HUE: + if (v4l2src) + { + const gchar * propName = + propId == CV_CAP_PROP_BRIGHTNESS ? "brightness" : + propId == CV_CAP_PROP_CONTRAST ? "contrast" : + propId == CV_CAP_PROP_SATURATION ? "saturation" : + propId == CV_CAP_PROP_HUE ? "hue" : NULL; + + if (propName) + { + gint32 value32 = 0; + g_object_get(G_OBJECT(v4l2src), propName, &value32, NULL); + return value32; + } + } case CV_CAP_PROP_GAIN: case CV_CAP_PROP_CONVERT_RGB: break; @@ -944,7 +965,7 @@ double CvCapture_GStreamer::getProperty( int propId ) #undef FORMAT - return false; + return 0; } /*! @@ -1023,6 +1044,21 @@ bool CvCapture_GStreamer::setProperty( int propId, double value ) case CV_CAP_PROP_CONTRAST: case CV_CAP_PROP_SATURATION: case CV_CAP_PROP_HUE: + if (v4l2src) + { + const gchar * propName = + propId == CV_CAP_PROP_BRIGHTNESS ? "brightness" : + propId == CV_CAP_PROP_CONTRAST ? "contrast" : + propId == CV_CAP_PROP_SATURATION ? "saturation" : + propId == CV_CAP_PROP_HUE ? "hue" : NULL; + + if (propName) + { + gint32 value32 = cv::saturate_cast(value); + g_object_set(G_OBJECT(v4l2src), propName, &value32, NULL); + return true; + } + } case CV_CAP_PROP_GAIN: case CV_CAP_PROP_CONVERT_RGB: break; From 1ea65689519c1f907d6ff2a01f46485be0ee6076 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 24 Sep 2015 15:52:17 +0300 Subject: [PATCH 42/53] Fixed wrong-name-for-changelog-of-native-package warning for deb packages. (cherry picked from commit cb1dc7cb6e8886f02864467aeae6c584a7eccc76) --- cmake/OpenCVPackaging.cmake | 13 +++++++++++++ cmake/templates/changelog.Debian.in | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVPackaging.cmake b/cmake/OpenCVPackaging.cmake index f6d5bd04a0..a1151c1cf3 100644 --- a/cmake/OpenCVPackaging.cmake +++ b/cmake/OpenCVPackaging.cmake @@ -201,6 +201,19 @@ if(CPACK_GENERATOR STREQUAL "DEB") install(FILES "${DEBIAN_CHANGELOG_OUT_FILE_GZ}" DESTINATION "share/doc/${CPACK_DEBIAN_COMPONENT_${comp_upcase}_NAME}" COMPONENT "${comp}") + + set(CHANGELOG_OUT_FILE "${CMAKE_BINARY_DIR}/deb-packages-gen/${comp}/changelog") + set(CHANGELOG_OUT_FILE_GZ "${CMAKE_BINARY_DIR}/deb-packages-gen/${comp}/changelog.gz") + file(WRITE ${CHANGELOG_OUT_FILE} "Upstream changelog stub. See https://github.com/Itseez/opencv/wiki/ChangeLog") + + execute_process(COMMAND "${GZIP_TOOL}" "-cf9" "${CHANGELOG_OUT_FILE}" + OUTPUT_FILE "${CHANGELOG_OUT_FILE_GZ}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") + + install(FILES "${CHANGELOG_OUT_FILE_GZ}" + DESTINATION "share/doc/${CPACK_DEBIAN_COMPONENT_${comp_upcase}_NAME}" + COMPONENT "${comp}") + endforeach() endif() diff --git a/cmake/templates/changelog.Debian.in b/cmake/templates/changelog.Debian.in index 70486e8090..a47ec42bc8 100644 --- a/cmake/templates/changelog.Debian.in +++ b/cmake/templates/changelog.Debian.in @@ -1,4 +1,5 @@ @CHANGELOG_PACKAGE_NAME@ (@CPACK_PACKAGE_VERSION@) unstable; urgency=low - * Debian changelog stub. See upstream changelog or release notes in user + * Debian changelog stub. See https://github.com/Itseez/opencv/wiki/ChangeLog + or release notes in user documentation for more details. -- @CPACK_PACKAGE_CONTACT@ @CHANGELOG_PACKAGE_DATE@ From 15b313ce4bd08cb380dba6a569eb816e31ceb084 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 12 Oct 2015 00:11:45 +0300 Subject: [PATCH 43/53] fixed memory leak in findHomography tests (cherry picked from commit ec5244a73abf36014fdd2763ff1f16e5e986cbb4) --- modules/calib3d/test/test_homography.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/calib3d/test/test_homography.cpp b/modules/calib3d/test/test_homography.cpp index f68af1d7c1..2db0a3c1ab 100644 --- a/modules/calib3d/test/test_homography.cpp +++ b/modules/calib3d/test/test_homography.cpp @@ -12,6 +12,7 @@ // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2015, Itseez 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, @@ -562,6 +563,9 @@ void CV_HomographyTest::run(int) default: continue; } } + + delete[]src_data; + src_data = NULL; } } From 96a2edb3756af078d8d7752e2911687df6d1bf0f Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 12 Oct 2015 00:37:46 +0300 Subject: [PATCH 44/53] delete video readers (cherry picked from commit 0d5b739d35e7a0c2d2b88db58994397ae969f468) --- modules/highgui/test/test_ffmpeg.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/highgui/test/test_ffmpeg.cpp b/modules/highgui/test/test_ffmpeg.cpp index 09de119ac6..31108f857c 100644 --- a/modules/highgui/test/test_ffmpeg.cpp +++ b/modules/highgui/test/test_ffmpeg.cpp @@ -396,6 +396,10 @@ TEST(Highgui_Video_parallel_writers_and_readers, accuracy) if (code == 1) std::cerr << "Couldn't delete " << *i << std::endl; } + + // delete the readers + for (std::vector::iterator i = readers.begin(), end = readers.end(); i != end; ++i) + delete *i; } #endif From a5c20f859281a93689cb6f1b46006c2233e8bd44 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 12 Oct 2015 11:37:26 +0300 Subject: [PATCH 45/53] Debian formatted copyright file added to all debian packages. (cherry picked from commit 9d24b3c3b0133c29a642aa5a0d2a0634333287f3) --- cmake/OpenCVPackaging.cmake | 9 +++++++- cmake/templates/copyright | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 cmake/templates/copyright diff --git a/cmake/OpenCVPackaging.cmake b/cmake/OpenCVPackaging.cmake index a1151c1cf3..e64d447bfa 100644 --- a/cmake/OpenCVPackaging.cmake +++ b/cmake/OpenCVPackaging.cmake @@ -19,6 +19,7 @@ OpenCV makes it easy for businesses to utilize and modify the code.") set(CPACK_PACKAGE_VERSION_MINOR "${OPENCV_VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${OPENCV_VERSION_PATCH}") set(CPACK_PACKAGE_VERSION "${OPENCV_VCSVERSION}") + set(OPENCV_DEBIAN_COPYRIGHT_FILE "") endif(NOT OPENCV_CUSTOM_PACKAGE_INFO) set(CPACK_STRIP_FILES 1) @@ -192,7 +193,7 @@ if(CPACK_GENERATOR STREQUAL "DEB") set(DEBIAN_CHANGELOG_OUT_FILE "${CMAKE_BINARY_DIR}/deb-packages-gen/${comp}/changelog.Debian") set(DEBIAN_CHANGELOG_OUT_FILE_GZ "${CMAKE_BINARY_DIR}/deb-packages-gen/${comp}/changelog.Debian.gz") set(CHANGELOG_PACKAGE_NAME "${CPACK_DEBIAN_COMPONENT_${comp_upcase}_NAME}") - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/changelog.Debian.in" "${DEBIAN_CHANGELOG_OUT_FILE}" @ONLY) + configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/changelog.Debian.in" "${DEBIAN_CHANGELOG_OUT_FILE}" @ONLY) execute_process(COMMAND "${GZIP_TOOL}" "-cf9" "${DEBIAN_CHANGELOG_OUT_FILE}" OUTPUT_FILE "${DEBIAN_CHANGELOG_OUT_FILE_GZ}" @@ -214,6 +215,12 @@ if(CPACK_GENERATOR STREQUAL "DEB") DESTINATION "share/doc/${CPACK_DEBIAN_COMPONENT_${comp_upcase}_NAME}" COMPONENT "${comp}") + if(OPENCV_DEBIAN_COPYRIGHT_FILE) + install(FILES "${OPENCV_DEBIAN_COPYRIGHT_FILE}" + DESTINATION "share/doc/${CPACK_DEBIAN_COMPONENT_${comp_upcase}_NAME}" + COMPONENT "${comp}") + endif() + endforeach() endif() diff --git a/cmake/templates/copyright b/cmake/templates/copyright new file mode 100644 index 0000000000..5e66dab7fc --- /dev/null +++ b/cmake/templates/copyright @@ -0,0 +1,43 @@ +Format: http://dep.debian.net/deps/dep5 + +Files: * +Copyright: 2000-2015, Intel Corporation + 2009-2011, Willow Garage Inc. + 2009-2015, NVIDIA Corporation + 2010-2013, Advanced Micro Devices, Inc. + 2015, OpenCV Foundation + 2015, Itseez Inc. +License: BSD-3-clause + By downloading, copying, installing or using the software you agree to this + license. If you do not agree to this license, do not download, install, copy + or use the software. +. +. + License Agreement + For Open Source Computer Vision Library + (3-clause BSD License) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: +. + \* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +. + \* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +. + \* Neither the names of the copyright holders nor the names of the + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + This software is provided by the copyright holders and contributors "as is" + and any express or implied warranties, including, but not limited to, the + implied warranties of merchantability and fitness for a particular purpose are + disclaimed. In no event shall copyright holders or contributors be liable for + any direct, indirect, incidental, special, exemplary, or consequential damages + (including, but not limited to, procurement of substitute goods or services; + loss of use, data, or profits; or business interruption) however caused + and on any theory of liability, whether in contract, strict liability, + or tort (including negligence or otherwise) arising in any way out of + the use of this software, even if advised of the possibility of such damage. From 8a37fc82238a8ade347ea1af483227db28737f0d Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 13 Oct 2015 15:02:38 +0300 Subject: [PATCH 46/53] Added missing copyright headers. (cherry picked from commit 408107ce6d16ae118167ffe22fda6bdcdb9514cb) --- include/opencv/cxmisc.h | 42 +++++++++++++++++++++ modules/flann/include/opencv2/flann/dummy.h | 29 ++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/include/opencv/cxmisc.h b/include/opencv/cxmisc.h index 6446944643..3a76656290 100644 --- a/include/opencv/cxmisc.h +++ b/include/opencv/cxmisc.h @@ -1,3 +1,45 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// + * // + * // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. + * // + * // By downloading, copying, installing or using the software you agree to this license. + * // If you do not agree to this license, do not download, install, + * // copy or use the software. + * // + * // + * // License Agreement + * // For Open Source Computer Vision Library + * // + * // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. + * // Copyright (C) 2009, Willow Garage 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, + * // are permitted provided that the following conditions are met: + * // + * // * Redistribution's of source code must retain the above copyright notice, + * // this list of conditions and the following disclaimer. + * // + * // * Redistribution's in binary form must reproduce the above copyright notice, + * // this list of conditions and the following disclaimer in the documentation + * // and/or other materials provided with the distribution. + * // + * // * The name of the copyright holders may not be used to endorse or promote products + * // derived from this software without specific prior written permission. + * // + * // This software is provided by the copyright holders and contributors "as is" and + * // any express or implied warranties, including, but not limited to, the implied + * // warranties of merchantability and fitness for a particular purpose are disclaimed. + * // In no event shall the Intel Corporation or contributors be liable for any direct, + * // indirect, incidental, special, exemplary, or consequential damages + * // (including, but not limited to, procurement of substitute goods or services; + * // loss of use, data, or profits; or business interruption) however caused + * // and on any theory of liability, whether in contract, strict liability, + * // or tort (including negligence or otherwise) arising in any way out of + * // the use of this software, even if advised of the possibility of such damage. + * // + * //M*/ + #ifndef __OPENCV_OLD_CXMISC_H__ #define __OPENCV_OLD_CXMISC_H__ diff --git a/modules/flann/include/opencv2/flann/dummy.h b/modules/flann/include/opencv2/flann/dummy.h index 26bd3fa5dd..339098180c 100644 --- a/modules/flann/include/opencv2/flann/dummy.h +++ b/modules/flann/include/opencv2/flann/dummy.h @@ -1,3 +1,32 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *************************************************************************/ #ifndef OPENCV_FLANN_DUMMY_H_ #define OPENCV_FLANN_DUMMY_H_ From 2d3e1703707a0734de106759ecce4bd5275eb825 Mon Sep 17 00:00:00 2001 From: a-andre Date: Tue, 13 Oct 2015 18:16:14 +0200 Subject: [PATCH 47/53] install opencv2/highgui.hpp header (cherry picked from commit d16fb3051296feebd04cdd7a372e0049629c155f) --- modules/highgui/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 7905872b80..44cf98c613 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -64,7 +64,7 @@ set(highgui_srcs src/window.cpp ) -file(GLOB highgui_ext_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") +file(GLOB highgui_ext_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") if(HAVE_QT5) set(CMAKE_AUTOMOC ON) From ca50969c2b9bd71f2f6ce7569f8ad595b1bf5244 Mon Sep 17 00:00:00 2001 From: Aaron Simmons Date: Tue, 13 Oct 2015 17:42:40 -0600 Subject: [PATCH 48/53] brining over fix in master (#4140) for libz import on 64-bit android (cherry picked from commit 55a9fdf0512a6bd3fd82591f48db0942cbd4fc38) --- cmake/OpenCVFindLibsGrfmt.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index f27a302ab7..43c3b16cc1 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -8,7 +8,8 @@ if(BUILD_ZLIB) else() include(FindZLIB) if(ZLIB_FOUND AND ANDROID) - if(ZLIB_LIBRARY STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so") + if(ZLIB_LIBRARIES STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so" OR + ZLIB_LIBRARIES STREQUAL "${ANDROID_SYSROOT}/usr/lib64/libz.so") set(ZLIB_LIBRARY z) set(ZLIB_LIBRARIES z) endif() From 42447a7610af61e07e3ee210fcfd62920319751e Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 13 Oct 2015 16:32:53 +0300 Subject: [PATCH 49/53] Set of lintain warning fixes for -samples debian package. (cherry picked from commit ff002203029220cd63bbb383b3f286a1ee7c35f3) --- samples/CMakeLists.txt | 2 +- samples/c/CMakeLists.txt | 7 ++++--- samples/cpp/CMakeLists.txt | 4 ++-- samples/gpu/CMakeLists.txt | 4 ++-- samples/gpu/performance/CMakeLists.txt | 4 ++-- samples/ocl/CMakeLists.txt | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index d2089de768..1754649f10 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -22,7 +22,7 @@ endif() if(INSTALL_C_EXAMPLES) install(FILES "CMakeLists.txt" DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) endif() if(INSTALL_PYTHON_EXAMPLES) diff --git a/samples/c/CMakeLists.txt b/samples/c/CMakeLists.txt index 61f23666f3..cb653c752c 100644 --- a/samples/c/CMakeLists.txt +++ b/samples/c/CMakeLists.txt @@ -52,8 +52,9 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) endif() if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32) - file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd *.txt) + file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* *.cmd *.txt) install(FILES ${C_SAMPLES} - DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/c - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) + DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/c" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) + install(PROGRAMS build_all.sh DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/c" COMPONENT samples) endif () diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 65e402bc13..fa52ac4860 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -93,6 +93,6 @@ endif() if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32) file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd *.txt) install(FILES ${C_SAMPLES} - DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/cpp - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) + DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/cpp" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) endif() diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt index dc7464f942..cdf9ee8562 100644 --- a/samples/gpu/CMakeLists.txt +++ b/samples/gpu/CMakeLists.txt @@ -112,6 +112,6 @@ if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32) list_filterout(install_list ".*driver_api_stereo_multi.cpp") endif() install(FILES ${install_list} - DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) + DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) endif() diff --git a/samples/gpu/performance/CMakeLists.txt b/samples/gpu/performance/CMakeLists.txt index 4a1603a916..d0810af22d 100644 --- a/samples/gpu/performance/CMakeLists.txt +++ b/samples/gpu/performance/CMakeLists.txt @@ -29,7 +29,7 @@ endif() if(INSTALL_C_EXAMPLES AND NOT WIN32) file(GLOB GPU_FILES performance/*.cpp performance/*.h performance/CMakeLists.txt) install(FILES ${GPU_FILES} - DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu/performance - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ + DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu/performance" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) endif() diff --git a/samples/ocl/CMakeLists.txt b/samples/ocl/CMakeLists.txt index 10db9b10fb..706c4ae0bd 100644 --- a/samples/ocl/CMakeLists.txt +++ b/samples/ocl/CMakeLists.txt @@ -54,6 +54,6 @@ endif() if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32) file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd *.txt) install(FILES ${install_list} - DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/ocl - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) + DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/ocl" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) endif() From 966d35a9fbd5102605c6742f493c405190b8a6cc Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 14 Oct 2015 12:52:32 +0300 Subject: [PATCH 50/53] Made samples build independent from nonfree module. (cherry picked from commit bba8c0beacf34143509b60aaf5321c56b2a21013) --- samples/CMakeLists.txt | 10 +++- samples/c/CMakeLists.txt | 2 +- samples/c/find_obj.cpp | 36 ++++++++---- samples/c/find_obj_calonder.cpp | 31 +++++++--- samples/c/one_way_sample.cpp | 30 +++++++--- samples/cpp/CMakeLists.txt | 5 +- samples/cpp/bagofwords_classification.cpp | 58 ++++++++++++------- samples/cpp/descriptor_extractor_matcher.cpp | 13 ++++- samples/cpp/fabmap_sample.cpp | 18 +++++- samples/cpp/freak_demo.cpp | 28 ++++++--- samples/cpp/generic_descriptor_match.cpp | 26 +++++++-- samples/cpp/matcher_simple.cpp | 22 +++++-- .../features2D/SURF_FlannMatcher.cpp | 27 ++++++--- .../features2D/SURF_Homography.cpp | 29 +++++++--- .../features2D/SURF_descriptor.cpp | 23 ++++++-- .../features2D/SURF_detector.cpp | 23 ++++++-- samples/ocl/CMakeLists.txt | 5 +- samples/ocl/surf_matcher.cpp | 27 ++++++--- 18 files changed, 302 insertions(+), 111 deletions(-) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 1754649f10..df01dc76b6 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -68,8 +68,14 @@ endif() add_subdirectory(c) add_subdirectory(cpp) -add_subdirectory(ocl) -add_subdirectory(gpu) +ocv_check_dependencies(opencv_ocl) +if (OCV_DEPENDENCIES_FOUND) + add_subdirectory(ocl) +endif() +ocv_check_dependencies(opencv_gpu) +if (OCV_DEPENDENCIES_FOUND) + add_subdirectory(gpu) +endif() # # END OF BUILD CASE 2: Build samples with library binaries diff --git a/samples/c/CMakeLists.txt b/samples/c/CMakeLists.txt index cb653c752c..b26e4ab662 100644 --- a/samples/c/CMakeLists.txt +++ b/samples/c/CMakeLists.txt @@ -4,7 +4,7 @@ # ---------------------------------------------------------------------------- SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc - opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree + opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_features2d opencv_calib3d opencv_legacy opencv_contrib) ocv_check_dependencies(${OPENCV_C_SAMPLES_REQUIRED_DEPS}) diff --git a/samples/c/find_obj.cpp b/samples/c/find_obj.cpp index e0431fc6d4..e0ae60cacc 100644 --- a/samples/c/find_obj.cpp +++ b/samples/c/find_obj.cpp @@ -4,19 +4,31 @@ * Author: Liu Liu * liuliu.1987+opencv@gmail.com */ -#include "opencv2/objdetect/objdetect.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/nonfree/nonfree.hpp" -#include "opencv2/imgproc/imgproc_c.h" -#include "opencv2/legacy/legacy.hpp" -#include "opencv2/legacy/compat.hpp" - -#include -#include + +#include "opencv2/opencv_modules.hpp" #include +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n"); + return -1; +} + +#else + +# include "opencv2/objdetect/objdetect.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/calib3d/calib3d.hpp" +# include "opencv2/nonfree/nonfree.hpp" +# include "opencv2/imgproc/imgproc_c.h" +# include "opencv2/legacy/legacy.hpp" +# include "opencv2/legacy/compat.hpp" + +# include + using namespace std; static void help() { @@ -320,3 +332,5 @@ int main(int argc, char** argv) return 0; } + +#endif diff --git a/samples/c/find_obj_calonder.cpp b/samples/c/find_obj_calonder.cpp index 02cd266526..685e703c54 100644 --- a/samples/c/find_obj_calonder.cpp +++ b/samples/c/find_obj_calonder.cpp @@ -1,12 +1,25 @@ -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/core/core.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/nonfree/nonfree.hpp" -#include "opencv2/legacy/legacy.hpp" - +#include "opencv2/opencv_modules.hpp" #include -#include + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl; + return -1; +} + +#else + +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/core/core.hpp" +# include "opencv2/imgproc/imgproc.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/nonfree/nonfree.hpp" +# include "opencv2/legacy/legacy.hpp" + +# include +# include using namespace std; using namespace cv; @@ -164,3 +177,5 @@ int main( int argc, char **argv ) return 0; } + +#endif diff --git a/samples/c/one_way_sample.cpp b/samples/c/one_way_sample.cpp index ad0153ba0c..6db28baf36 100644 --- a/samples/c/one_way_sample.cpp +++ b/samples/c/one_way_sample.cpp @@ -7,16 +7,28 @@ * */ -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/imgproc/imgproc_c.h" -#include "opencv2/nonfree/nonfree.hpp" -#include "opencv2/legacy/legacy.hpp" -#include "opencv2/legacy/compat.hpp" +#include "opencv2/opencv_modules.hpp" +#include + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n"); + return -1; +} + +#else + +# include "opencv2/imgproc/imgproc.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/imgproc/imgproc_c.h" +# include "opencv2/nonfree/nonfree.hpp" +# include "opencv2/legacy/legacy.hpp" +# include "opencv2/legacy/compat.hpp" #include -#include static void help() { @@ -116,3 +128,5 @@ Mat DrawCorrespondences(const Mat& img1, const vector& features1, cons return img_corr; } + +#endif diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index fa52ac4860..5eff52a90f 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -4,8 +4,9 @@ # ---------------------------------------------------------------------------- SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc - opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree - opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching opencv_videostab) + opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo + opencv_features2d opencv_calib3d opencv_legacy opencv_contrib + opencv_stitching opencv_videostab) ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) diff --git a/samples/cpp/bagofwords_classification.cpp b/samples/cpp/bagofwords_classification.cpp index db194b536c..d351baaa96 100644 --- a/samples/cpp/bagofwords_classification.cpp +++ b/samples/cpp/bagofwords_classification.cpp @@ -1,29 +1,41 @@ #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 -#define _OCL_SVM_ 1 //select whether using ocl::svm method or not, default is using -#include "opencv2/ocl/ocl.hpp" -#endif - -#include #include -#include -#include -#if defined WIN32 || defined _WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#undef min -#undef max -#include "sys/types.h" -#endif -#include +#ifndef HAVE_OPENCV_NONFREE -#define DEBUG_DESC_PROGRESS +int main(int, char**) +{ + std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl; + return -1; +} + +#else + +# 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 +# define _OCL_SVM_ 1 //select whether using ocl::svm method or not, default is using +# include "opencv2/ocl/ocl.hpp" +# endif + +# include +# include +# include + + +# if defined WIN32 || defined _WIN32 +# define WIN32_LEAN_AND_MEAN +# include +# undef min +# undef max +# include "sys/types.h" +# endif +# include + +# define DEBUG_DESC_PROGRESS using namespace cv; using namespace std; @@ -2623,3 +2635,5 @@ int main(int argc, char** argv) } return 0; } + +#endif diff --git a/samples/cpp/descriptor_extractor_matcher.cpp b/samples/cpp/descriptor_extractor_matcher.cpp index 98c6452234..4a9a63403a 100644 --- a/samples/cpp/descriptor_extractor_matcher.cpp +++ b/samples/cpp/descriptor_extractor_matcher.cpp @@ -1,8 +1,11 @@ +#include "opencv2/opencv_modules.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/calib3d/calib3d.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/features2d/features2d.hpp" -#include "opencv2/nonfree/nonfree.hpp" +#ifdef HAVE_OPENCV_NONFREE +# include "opencv2/nonfree/nonfree.hpp" +#endif #include @@ -17,14 +20,14 @@ static void help(char** argv) << "Case1: second image is obtained from the first (given) image using random generated homography matrix\n" << argv[0] << " [detectorType] [descriptorType] [matcherType] [matcherFilterType] [image] [evaluate(0 or 1)]\n" << "Example of case1:\n" - << "./descriptor_extractor_matcher SURF SURF FlannBased NoneFilter cola.jpg 0\n" + << "./descriptor_extractor_matcher ORB ORB FlannBased NoneFilter cola.jpg 0\n" << "\n" << "Case2: both images are given. If ransacReprojThreshold>=0 then homography matrix are calculated\n" << argv[0] << " [detectorType] [descriptorType] [matcherType] [matcherFilterType] [image1] [image2] [ransacReprojThreshold]\n" << "\n" << "Matches are filtered using homography matrix in case1 and case2 (if ransacReprojThreshold>=0)\n" << "Example of case2:\n" - << "./descriptor_extractor_matcher SURF SURF BruteForce CrossCheckFilter cola1.jpg cola2.jpg 3\n" + << "./descriptor_extractor_matcher ORB ORB BruteForce CrossCheckFilter cola1.jpg cola2.jpg 3\n" << "\n" << "Possible detectorType values: see in documentation on createFeatureDetector().\n" << "Possible descriptorType values: see in documentation on createDescriptorExtractor().\n" @@ -239,7 +242,11 @@ int main(int argc, char** argv) return -1; } +#ifdef HAVE_OPENCV_NONFREE cv::initModule_nonfree(); +#else + cout << "Warning: OpenCV is built without nonfree support SIFT, SURF and some other algorithms are not available." << endl; +#endif bool isWarpPerspective = argc == 7; double ransacReprojThreshold = -1; diff --git a/samples/cpp/fabmap_sample.cpp b/samples/cpp/fabmap_sample.cpp index bbe5f2b4c5..25b9dbd241 100644 --- a/samples/cpp/fabmap_sample.cpp +++ b/samples/cpp/fabmap_sample.cpp @@ -49,9 +49,21 @@ // //M*/ +#include "opencv2/opencv_modules.hpp" +#include -#include "opencv2/opencv.hpp" -#include "opencv2/nonfree/nonfree.hpp" +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl; + return -1; +} + +#else + +# include "opencv2/opencv.hpp" +# include "opencv2/nonfree/nonfree.hpp" using namespace cv; using namespace std; @@ -212,3 +224,5 @@ int main(int argc, char * argv[]) { return 0; } + +#endif diff --git a/samples/cpp/freak_demo.cpp b/samples/cpp/freak_demo.cpp index 6dbd9215ba..6a941598c3 100644 --- a/samples/cpp/freak_demo.cpp +++ b/samples/cpp/freak_demo.cpp @@ -34,15 +34,27 @@ // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. +#include "opencv2/opencv_modules.hpp" #include -#include -#include -#include -#include -#include -#include -#include +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl; + return -1; +} + +#else + +# include +# include + +# include +# include +# include +# include +# include using namespace cv; @@ -126,3 +138,5 @@ int main( int argc, char** argv ) { imshow("matches", imgMatch); waitKey(0); } + +#endif diff --git a/samples/cpp/generic_descriptor_match.cpp b/samples/cpp/generic_descriptor_match.cpp index 1cb03c6a9c..198f4046a8 100644 --- a/samples/cpp/generic_descriptor_match.cpp +++ b/samples/cpp/generic_descriptor_match.cpp @@ -1,11 +1,23 @@ -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/nonfree/nonfree.hpp" - +#include "opencv2/opencv_modules.hpp" #include +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n"); + return -1; +} + +#else + +# include "opencv2/opencv_modules.hpp" +# include "opencv2/calib3d/calib3d.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/imgproc/imgproc.hpp" +# include "opencv2/nonfree/nonfree.hpp" + using namespace cv; static void help() @@ -91,3 +103,5 @@ Mat DrawCorrespondences(const Mat& img1, const vector& features1, cons return img_corr; } + +#endif diff --git a/samples/cpp/matcher_simple.cpp b/samples/cpp/matcher_simple.cpp index 42e89fbaa6..2df32eb4b7 100644 --- a/samples/cpp/matcher_simple.cpp +++ b/samples/cpp/matcher_simple.cpp @@ -1,8 +1,20 @@ +#include "opencv2/opencv_modules.hpp" #include -#include "opencv2/core/core.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/nonfree/nonfree.hpp" + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n"); + return -1; +} + +#else + +# include "opencv2/core/core.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/nonfree/nonfree.hpp" using namespace cv; @@ -56,3 +68,5 @@ int main(int argc, char** argv) return 0; } + +#endif diff --git a/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp b/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp index 09346309ec..9cc17768aa 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_FlannMatcher.cpp @@ -4,12 +4,23 @@ * @author A. Huaman */ +#include "opencv2/opencv_modules.hpp" #include -#include -#include "opencv2/core/core.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/nonfree/features2d.hpp" + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n"); + return -1; +} + +#else + +# include "opencv2/core/core.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/nonfree/features2d.hpp" using namespace cv; @@ -28,7 +39,7 @@ int main( int argc, char** argv ) Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE ); if( !img_1.data || !img_2.data ) - { std::cout<< " --(!) Error reading images " << std::endl; return -1; } + { printf(" --(!) Error reading images \n"); return -1; } //-- Step 1: Detect the keypoints using SURF Detector int minHessian = 400; @@ -97,4 +108,6 @@ int main( int argc, char** argv ) * @function readme */ void readme() -{ std::cout << " Usage: ./SURF_FlannMatcher " << std::endl; } +{ printf(" Usage: ./SURF_FlannMatcher \n"); } + +#endif \ No newline at end of file diff --git a/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp b/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp index 4b29638a5f..11dd074951 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_Homography.cpp @@ -4,13 +4,24 @@ * @author A. Huaman */ +#include "opencv2/opencv_modules.hpp" #include -#include -#include "opencv2/core/core.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/nonfree/features2d.hpp" + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n"); + return -1; +} + +#else + +# include "opencv2/core/core.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/calib3d/calib3d.hpp" +# include "opencv2/nonfree/features2d.hpp" using namespace cv; @@ -29,7 +40,7 @@ int main( int argc, char** argv ) Mat img_scene = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE ); if( !img_object.data || !img_scene.data ) - { std::cout<< " --(!) Error reading images " << std::endl; return -1; } + { printf(" --(!) Error reading images \n"); return -1; } //-- Step 1: Detect the keypoints using SURF Detector int minHessian = 400; @@ -121,4 +132,6 @@ int main( int argc, char** argv ) * @function readme */ void readme() -{ std::cout << " Usage: ./SURF_Homography " << std::endl; } +{ printf(" Usage: ./SURF_Homography \n"); } + +#endif \ No newline at end of file diff --git a/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp b/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp index 527e5dd951..2fcd884ce8 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp @@ -4,12 +4,23 @@ * @author A. Huaman */ +#include "opencv2/opencv_modules.hpp" #include -#include -#include "opencv2/core/core.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/nonfree/features2d.hpp" + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n"); + return -1; +} + +#else + +# include "opencv2/core/core.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/nonfree/features2d.hpp" using namespace cv; @@ -70,3 +81,5 @@ int main( int argc, char** argv ) */ void readme() { std::cout << " Usage: ./SURF_descriptor " << std::endl; } + +#endif \ No newline at end of file diff --git a/samples/cpp/tutorial_code/features2D/SURF_detector.cpp b/samples/cpp/tutorial_code/features2D/SURF_detector.cpp index 2625f1df3b..21dc45a949 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_detector.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_detector.cpp @@ -4,12 +4,23 @@ * @author A. Huaman */ -#include +#include "opencv2/opencv_modules.hpp" #include -#include "opencv2/core/core.hpp" -#include "opencv2/features2d/features2d.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/nonfree/features2d.hpp" + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl; + return -1; +} + +#else + +# include "opencv2/core/core.hpp" +# include "opencv2/features2d/features2d.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/nonfree/features2d.hpp" using namespace cv; @@ -60,3 +71,5 @@ int main( int argc, char** argv ) */ void readme() { std::cout << " Usage: ./SURF_detector " << std::endl; } + +#endif diff --git a/samples/ocl/CMakeLists.txt b/samples/ocl/CMakeLists.txt index 706c4ae0bd..90856f7ca1 100644 --- a/samples/ocl/CMakeLists.txt +++ b/samples/ocl/CMakeLists.txt @@ -1,7 +1,6 @@ SET(OPENCV_OCL_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_features2d - opencv_calib3d opencv_legacy opencv_contrib opencv_ocl - opencv_nonfree) + opencv_calib3d opencv_legacy opencv_contrib opencv_ocl) ocv_check_dependencies(${OPENCV_OCL_SAMPLES_REQUIRED_DEPS}) @@ -52,7 +51,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) endif() if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32) - file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd *.txt) + file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* *.txt) install(FILES ${install_list} DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/ocl" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) diff --git a/samples/ocl/surf_matcher.cpp b/samples/ocl/surf_matcher.cpp index 6023de9039..19b7f564a8 100644 --- a/samples/ocl/surf_matcher.cpp +++ b/samples/ocl/surf_matcher.cpp @@ -1,11 +1,22 @@ +#include "opencv2/opencv_modules.hpp" #include -#include -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/ocl/ocl.hpp" -#include "opencv2/nonfree/ocl.hpp" -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/nonfree/nonfree.hpp" + +#ifndef HAVE_OPENCV_NONFREE + +int main(int, char**) +{ + std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl; + return -1; +} + +#else + +# include "opencv2/core/core.hpp" +# include "opencv2/highgui/highgui.hpp" +# include "opencv2/ocl/ocl.hpp" +# include "opencv2/nonfree/ocl.hpp" +# include "opencv2/calib3d/calib3d.hpp" +# include "opencv2/nonfree/nonfree.hpp" using namespace cv; using namespace cv::ocl; @@ -326,3 +337,5 @@ int main(int argc, char* argv[]) waitKey(0); return EXIT_SUCCESS; } + +#endif From 2e78a3e5e94f21f6488734bc992cf5a8a7a5a27a Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 14 Oct 2015 16:19:37 +0300 Subject: [PATCH 51/53] Fixed samples build with nonfree. (cherry picked from commit 341e7b3be24f921cdf0a63793afc2e694b4e98b6) --- samples/c/CMakeLists.txt | 2 +- samples/cpp/CMakeLists.txt | 2 +- samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp | 2 +- samples/ocl/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/c/CMakeLists.txt b/samples/c/CMakeLists.txt index b26e4ab662..bd82ba2637 100644 --- a/samples/c/CMakeLists.txt +++ b/samples/c/CMakeLists.txt @@ -16,7 +16,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") endif() - ocv_include_modules(${OPENCV_C_SAMPLES_REQUIRED_DEPS}) + ocv_include_modules(${OPENCV_C_SAMPLES_REQUIRED_DEPS} opencv_nonfree) # --------------------------------------------- # Define executable targets diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 5eff52a90f..6433d1fd30 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -15,7 +15,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) project(cpp_samples) ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp - ocv_include_modules(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) + ocv_include_modules(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS} opencv_nonfree) if(HAVE_opencv_gpu) ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") diff --git a/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp b/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp index 2fcd884ce8..aeabd8e346 100644 --- a/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp +++ b/samples/cpp/tutorial_code/features2D/SURF_descriptor.cpp @@ -80,6 +80,6 @@ int main( int argc, char** argv ) * @function readme */ void readme() -{ std::cout << " Usage: ./SURF_descriptor " << std::endl; } +{ printf(" Usage: ./SURF_descriptor \n"); } #endif \ No newline at end of file diff --git a/samples/ocl/CMakeLists.txt b/samples/ocl/CMakeLists.txt index 90856f7ca1..ee6d4f618c 100644 --- a/samples/ocl/CMakeLists.txt +++ b/samples/ocl/CMakeLists.txt @@ -10,7 +10,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) project("${project}_samples") - ocv_include_modules(${OPENCV_OCL_SAMPLES_REQUIRED_DEPS}) + ocv_include_modules(${OPENCV_OCL_SAMPLES_REQUIRED_DEPS} opencv_nonfree) if(HAVE_OPENCL) ocv_include_directories(${OPENCL_INCLUDE_DIR}) From 60eda6f25c93b37f620b9e12d7a95d753d30ef46 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 19 Oct 2015 13:36:44 +0300 Subject: [PATCH 52/53] export simple libs from OPENCV_LINKER_LIBS (fix #5541) (cherry picked from commit 937a096bf10bedd2d10803f67716393f9065abe8) --- cmake/OpenCVModule.cmake | 5 ++++- cmake/OpenCVUtils.cmake | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index cae2a39c9d..88ebe54f79 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -576,7 +576,10 @@ macro(ocv_create_module) if(NOT "${ARGN}" STREQUAL "SKIP_LINK") target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS}) target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS}) - target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN}) + set(extra_deps ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN}) + ocv_extract_simple_libs(extra_deps _simple_deps _other_deps) + target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${_simple_deps}) # this list goes to "export" + target_link_libraries(${the_module} ${extra_deps}) endif() add_dependencies(opencv_modules ${the_module}) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index c23ddccebe..0692b763d5 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -630,3 +630,21 @@ function(ocv_source_group group) file(GLOB srcs ${OCV_SOURCE_GROUP_GLOB}) source_group(${group} FILES ${srcs}) endfunction() + +# build the list of simple dependencies, that links via "-l" +# _all_libs - name of variable with input list +# _simple - name of variable with output list of simple libs +# _other - name of variable with _all_libs - _simple +macro(ocv_extract_simple_libs _all_libs _simple _other) + set(${_simple} "") + set(${_other} "") + foreach(_l ${${_all_libs}}) + if(TARGET ${_l}) + list(APPEND ${_other} ${_l}) + elseif(EXISTS "${_l}") + list(APPEND ${_other} ${_l}) + else() + list(APPEND ${_simple} ${_l}) + endif() + endforeach() +endmacro() From 8e40becab12c642e7bbafb9fe87698e8b6bf28da Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 23 Oct 2015 12:28:09 +0300 Subject: [PATCH 53/53] Debian packages with legacy C headers added to list of conflicts, relpaces, etc. (cherry picked from commit e245aed6bbebd69a63a00d45a66b358df4153888) --- cmake/OpenCVPackaging.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/OpenCVPackaging.cmake b/cmake/OpenCVPackaging.cmake index e64d447bfa..4e4b4d42c9 100644 --- a/cmake/OpenCVPackaging.cmake +++ b/cmake/OpenCVPackaging.cmake @@ -127,6 +127,8 @@ foreach(module calib3d contrib core features2d flann gpu highgui imgproc legacy endif() endforeach() +list(APPEND STD_OPENCV_DEV "libhighgui-dev" "libcv-dev" "libcvaux-dev") + string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_CONFLICTS "${STD_OPENCV_LIBS}") string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_PROVIDES "${STD_OPENCV_LIBS}") string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_REPLACES "${STD_OPENCV_LIBS}")