From 7e6947a940b7b7f41b9949016c43bc201b66eaa1 Mon Sep 17 00:00:00 2001 From: Martijn Liem Date: Wed, 23 Jul 2014 12:33:51 +0200 Subject: [PATCH 01/12] Bugfix for bug #3767 Fixed a memory leak in cap_dshow.cpp in videoInput::setVideoSettingCamera(). The leak was caused by not releasing an IBaseFilter object created in a call to getDevice(). Tho object is now properly released. Conflicts: modules/highgui/src/cap_dshow.cpp --- modules/videoio/src/cap_dshow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/videoio/src/cap_dshow.cpp b/modules/videoio/src/cap_dshow.cpp index c8c63fcb7..88814c83e 100644 --- a/modules/videoio/src/cap_dshow.cpp +++ b/modules/videoio/src/cap_dshow.cpp @@ -1839,6 +1839,8 @@ bool videoInput::setVideoSettingCamera(int deviceID, long Property, long lValue, hr = VDList[deviceID]->pVideoInputFilter->QueryInterface(IID_IAMCameraControl, (void**)&pIAMCameraControl); if (FAILED(hr)) { DebugPrintOut("Error\n"); + if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter->Release(); + if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter = NULL; return false; } else @@ -1857,6 +1859,8 @@ bool videoInput::setVideoSettingCamera(int deviceID, long Property, long lValue, pIAMCameraControl->Set(Property, lValue, Flags); } pIAMCameraControl->Release(); + if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter->Release(); + if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter = NULL; return true; } } From 5141141e2ba22fa14dfec61eb1f660ab7f080b98 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 14 Jul 2014 21:27:23 +0400 Subject: [PATCH 02/12] Deb package build fix for CUDA 6.5 and newer. (cherry picked from commit e650d87e470b2e6a8f87ad4dd81977748a136aee) (cherry picked from commit ca9c52ac9778d01eba933a786b4303c79d0162be) Conflicts: cmake/OpenCVPackaging.cmake --- cmake/OpenCVPackaging.cmake | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVPackaging.cmake b/cmake/OpenCVPackaging.cmake index d88826464..59d602c5d 100644 --- a/cmake/OpenCVPackaging.cmake +++ b/cmake/OpenCVPackaging.cmake @@ -78,8 +78,22 @@ set(CPACK_COMPONENT_TESTS_DEPENDS libs) if(HAVE_CUDA) string(REPLACE "." "-" cuda_version_suffix ${CUDA_VERSION}) - set(CPACK_DEB_LIBS_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}") - set(CPACK_DEB_DEV_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}") + if(${CUDA_VERSION} VERSION_LESS "6.5") + set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}") + set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}") + else() + set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-cudart-${cuda_version_suffix}, cuda-npp-${cuda_version_suffix}") + set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-cudart-dev-${cuda_version_suffix}, cuda-npp-dev-${cuda_version_suffix}") + if(HAVE_CUFFT) + set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cufft-${cuda_version_suffix}") + set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cufft-dev-${cuda_version_suffix}") + endif() + if(HAVE_HAVE_CUBLAS) + set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cublas-${cuda_version_suffix}") + set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cublas-dev-${cuda_version_suffix}") + endif() + endif() + set(CPACK_COMPONENT_dev_DEPENDS libs) endif() if(NOT OPENCV_CUSTOM_PACKAGE_INFO) From 6e1a5953429c6a95cc4d370ce35ac781b87b683b Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 13 Aug 2014 13:46:43 +0400 Subject: [PATCH 03/12] GCC 4.8 warning array subscript is above array bounds fixed. tiff test fixed --- modules/imgcodecs/test/test_grfmt.cpp | 2 ++ modules/imgproc/src/floodfill.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp index 92238a95f..54b7c215d 100644 --- a/modules/imgcodecs/test/test_grfmt.cpp +++ b/modules/imgcodecs/test/test_grfmt.cpp @@ -42,6 +42,8 @@ #include "test_precomp.hpp" +#include + using namespace cv; using namespace std; diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index 54a1fc976..69228b339 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -484,6 +484,12 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, int depth = img.depth(); int cn = img.channels(); + if ( (cn != 1) && (cn != 3) ) + { + CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" ); + return; + } + if( connectivity == 0 ) connectivity = 4; else if( connectivity != 4 && connectivity != 8 ) From cb55d60f98db479a0e7b24a3b9733823d42e9649 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Mon, 18 Aug 2014 13:33:40 +0200 Subject: [PATCH 04/12] fixing GT and GE comparison symbol Conflicts: modules/gpu/doc/per_element_operations.rst --- modules/cudaarithm/include/opencv2/cudaarithm.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cudaarithm/include/opencv2/cudaarithm.hpp b/modules/cudaarithm/include/opencv2/cudaarithm.hpp index 6e475db98..d377a70e7 100644 --- a/modules/cudaarithm/include/opencv2/cudaarithm.hpp +++ b/modules/cudaarithm/include/opencv2/cudaarithm.hpp @@ -211,8 +211,8 @@ CV_EXPORTS void pow(InputArray src, double power, OutputArray dst, Stream& strea @param dst Destination matrix that has the same size and type as the input array(s). @param cmpop Flag specifying the relation between the elements to be checked: - **CMP_EQ:** a(.) == b(.) -- **CMP_GT:** a(.) \< b(.) -- **CMP_GE:** a(.) \<= b(.) +- **CMP_GT:** a(.) \> b(.) +- **CMP_GE:** a(.) \>= b(.) - **CMP_LT:** a(.) \< b(.) - **CMP_LE:** a(.) \<= b(.) - **CMP_NE:** a(.) != b(.) From 3c2e12a74421533fd10b577d7160a9fdecbe9574 Mon Sep 17 00:00:00 2001 From: jormansa Date: Mon, 15 Sep 2014 18:09:44 +0200 Subject: [PATCH 05/12] bug fixed Conflicts: modules/highgui/src/cap_ffmpeg_impl.hpp --- modules/videoio/src/cap_ffmpeg_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index f49301a8a..e9a6721d3 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -649,7 +649,7 @@ bool CvCapture_FFMPEG::grabFrame() int got_picture; int count_errs = 0; - const int max_number_of_attempts = 1 << 16; + const int max_number_of_attempts = 1 << 9; if( !ic || !video_st ) return false; From a9ae0c8e8270fd97349036a3c1d513f294f89557 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 30 Sep 2014 14:34:00 +0400 Subject: [PATCH 06/12] Test fisheye.rectify disabled for Tegra. --- modules/calib3d/test/test_fisheye.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/calib3d/test/test_fisheye.cpp b/modules/calib3d/test/test_fisheye.cpp index d4212e94f..ba05f1ee2 100644 --- a/modules/calib3d/test/test_fisheye.cpp +++ b/modules/calib3d/test/test_fisheye.cpp @@ -385,7 +385,12 @@ TEST_F(fisheyeTest, EtimateUncertainties) CV_Assert(errors.alpha == 0); } +#ifdef HAVE_TEGRA_OPTIMIZATION +// not passing accuracy constrains +TEST_F(fisheyeTest, DISABLED_rectify) +#else TEST_F(fisheyeTest, rectify) +#endif { const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY"); From a04a0514b9575ee7bb823090cf8a88c094d1376a Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 1 Oct 2014 09:13:35 +0400 Subject: [PATCH 07/12] Turn off superres accuracy tests if video i/o is not supported. --- modules/superres/test/test_precomp.hpp | 13 +++++++++++++ modules/superres/test/test_superres.cpp | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/modules/superres/test/test_precomp.hpp b/modules/superres/test/test_precomp.hpp index 9e89b428e..b1c825746 100644 --- a/modules/superres/test/test_precomp.hpp +++ b/modules/superres/test/test_precomp.hpp @@ -59,4 +59,17 @@ #include "cvconfig.h" #include "../src/input_array_utility.hpp" +#if defined(HAVE_XINE) || \ + defined(HAVE_GSTREAMER) || \ + defined(HAVE_QUICKTIME) || \ + defined(HAVE_QTKIT) || \ + defined(HAVE_AVFOUNDATION) || \ + defined(HAVE_FFMPEG) || \ + defined(HAVE_MSMF) || \ + defined(HAVE_VFW) +# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1 +#else +# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0 +#endif + #endif diff --git a/modules/superres/test/test_superres.cpp b/modules/superres/test/test_superres.cpp index 74a90bdc2..56e9f542f 100644 --- a/modules/superres/test/test_superres.cpp +++ b/modules/superres/test/test_superres.cpp @@ -43,6 +43,8 @@ #include "test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" +#if BUILD_WITH_VIDEO_INPUT_SUPPORT + class AllignedFrameSource : public cv::superres::FrameSource { public: @@ -292,3 +294,5 @@ OCL_TEST_F(SuperResolution, BTVL1) } } // namespace cvtest::ocl #endif + +#endif // BUILD_WITH_VIDEO_INPUT_SUPPORT From 8138e26163e39c327c3e645ad1cccc896fa10dae Mon Sep 17 00:00:00 2001 From: Niklas Frisk Date: Tue, 7 Oct 2014 09:40:56 +0200 Subject: [PATCH 08/12] Fixes #3910, flags in _prepareImgAndDrawKeypoints are now binary OR'ed instead of added. Conflicts: modules/features2d/src/draw.cpp --- modules/features2d/src/draw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/features2d/src/draw.cpp b/modules/features2d/src/draw.cpp index 6673e4631..63410e713 100644 --- a/modules/features2d/src/draw.cpp +++ b/modules/features2d/src/draw.cpp @@ -159,10 +159,10 @@ static void _prepareImgAndDrawKeypoints( InputArray img1, const std::vector Date: Wed, 8 Oct 2014 23:31:30 +0200 Subject: [PATCH 09/12] Don't allocate lots of memory when reading TIFFs with infinite rows per strip. Some TIFF images consist of only one strip. The magic value 2**32-1 for the "rows per strip" tag reflects that fact, effectively meaning "infinite". Conflicts: modules/highgui/src/grfmt_tiff.cpp modules/highgui/test/test_grfmt.cpp fix whitespace fix compile error --- modules/imgcodecs/src/grfmt_tiff.cpp | 4 +++- modules/imgcodecs/test/test_grfmt.cpp | 30 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index 8f33757be..59b40ceff 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -48,6 +48,7 @@ #include "precomp.hpp" #include "grfmt_tiff.hpp" #include +#include namespace cv { @@ -242,7 +243,8 @@ bool TiffDecoder::readData( Mat& img ) if( tile_width0 <= 0 ) tile_width0 = m_width; - if( tile_height0 <= 0 ) + if( tile_height0 <= 0 || + (!is_tiled && tile_height0 == std::numeric_limits::max()) ) tile_height0 = m_height; AutoBuffer _buffer( size_t(8) * tile_height0*tile_width0); diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp index 54b7c215d..ae0b428ec 100644 --- a/modules/imgcodecs/test/test_grfmt.cpp +++ b/modules/imgcodecs/test/test_grfmt.cpp @@ -675,6 +675,36 @@ TEST(Imgcodecs_Tiff, decode_tile_remainder) CV_GrfmtReadTifTiledWithNotFullTiles test; test.safe_run(); } +TEST(Imgcodecs_Tiff, decode_infinite_rowsperstrip) +{ + const uchar sample_data[142] = { + 0x49, 0x49, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x56, 0x54, + 0x56, 0x5a, 0x59, 0x55, 0x5a, 0x00, 0x0a, 0x00, 0x00, 0x01, + 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, + 0x00, 0x00, 0x02, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x03, 0x01, 0x03, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, + 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x15, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x16, 0x01, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x17, 0x01, 0x04, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x03, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 + }; + + const string filename = cv::tempfile(".tiff"); + std::ofstream outfile(filename.c_str(), std::ofstream::binary); + outfile.write(reinterpret_cast(sample_data), sizeof sample_data); + outfile.close(); + + EXPECT_NO_THROW(cv::imread(filename, IMREAD_UNCHANGED)); + + remove(filename.c_str()); +} + class CV_GrfmtReadTifMultiPage : public cvtest::BaseTest { private: From efa2baed832a6c0a4b19653f638acf49aa0f069c Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 6 Oct 2014 07:56:30 +0000 Subject: [PATCH 10/12] TCP instead of UDP Conflicts: modules/highgui/src/cap_ffmpeg_impl.hpp --- modules/videoio/src/cap_ffmpeg_impl.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index e9a6721d3..1504d2ae6 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -270,6 +270,10 @@ struct CvCapture_FFMPEG and so the filename is needed to reopen the file on backward seeking. */ char * filename; + +#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0) + AVDictionary *dict; +#endif }; void CvCapture_FFMPEG::init() @@ -290,6 +294,10 @@ void CvCapture_FFMPEG::init() avcodec = 0; frame_number = 0; eps_zero = 0.000025; + +#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0) + dict = NULL; +#endif } @@ -347,6 +355,11 @@ void CvCapture_FFMPEG::close() packet.data = NULL; } +#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0) + if (dict != NULL) + av_dict_free(&dict); +#endif + init(); } @@ -554,6 +567,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) close(); #if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0) + av_dict_set(&dict, "rtsp_transport", "tcp", 0); int err = avformat_open_input(&ic, _filename, NULL, NULL); #else int err = av_open_input_file(&ic, _filename, NULL, 0, NULL); From 653810e4df77175a51a024448d86c08ee22b27c1 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 17 Oct 2014 13:23:23 +0400 Subject: [PATCH 11/12] fix installation layout for debian packages: Install symlinks to shared libraries as a part of development package, not runtime package. It is default behavior for debian packages. --- cmake/OpenCVModule.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index d1558f406..a1a1b9020 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -782,9 +782,14 @@ macro(_ocv_create_module) ocv_install_target(${the_module} EXPORT OpenCVModules OPTIONAL RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs - LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs + LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs NAMELINK_SKIP ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev ) + get_target_property(_target_type ${the_module} TYPE) + if("${_target_type}" STREQUAL "SHARED_LIBRARY") + install(TARGETS ${the_module} + LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev NAMELINK_ONLY) + endif() foreach(m ${OPENCV_MODULE_${the_module}_CHILDREN} ${the_module}) # only "public" headers need to be installed From 3ec0e0943c25ccb2f0ec22cfbcbf1cf4760435b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=BChrk?= Date: Sun, 19 Oct 2014 01:22:04 +0200 Subject: [PATCH 12/12] TIFF loader: Allocate large enough buffer when (bpp * ncn) > 8. Conflicts: modules/highgui/src/grfmt_tiff.cpp floodfill return value removed --- modules/imgcodecs/src/grfmt_tiff.cpp | 11 ++++++----- modules/imgproc/src/floodfill.cpp | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index 59b40ceff..fc6f2368a 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -247,7 +247,8 @@ bool TiffDecoder::readData( Mat& img ) (!is_tiled && tile_height0 == std::numeric_limits::max()) ) tile_height0 = m_height; - AutoBuffer _buffer( size_t(8) * tile_height0*tile_width0); + const size_t buffer_size = bpp * ncn * tile_height0 * tile_width0; + AutoBuffer _buffer( buffer_size ); uchar* buffer = _buffer; ushort* buffer16 = (ushort*)buffer; float* buffer32 = (float*)buffer; @@ -313,9 +314,9 @@ bool TiffDecoder::readData( Mat& img ) case 16: { if( !is_tiled ) - ok = (int)TIFFReadEncodedStrip( tif, tileidx, (uint32*)buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedStrip( tif, tileidx, (uint32*)buffer, buffer_size ) >= 0; else - ok = (int)TIFFReadEncodedTile( tif, tileidx, (uint32*)buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedTile( tif, tileidx, (uint32*)buffer, buffer_size ) >= 0; if( !ok ) { @@ -384,9 +385,9 @@ bool TiffDecoder::readData( Mat& img ) case 64: { if( !is_tiled ) - ok = (int)TIFFReadEncodedStrip( tif, tileidx, buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedStrip( tif, tileidx, buffer, buffer_size ) >= 0; else - ok = (int)TIFFReadEncodedTile( tif, tileidx, buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedTile( tif, tileidx, buffer, buffer_size ) >= 0; if( !ok || ncn != 1 ) { diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index 69228b339..6d8491a2a 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -487,7 +487,6 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, if ( (cn != 1) && (cn != 3) ) { CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" ); - return; } if( connectivity == 0 )