From 64fd54ffb4994103d82a34b4039d4938fdb87e46 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Fri, 24 Jan 2014 13:03:47 +0200 Subject: [PATCH 01/26] fix tiled read for reading tiles into partial blocks in image --- modules/highgui/src/grfmt_tiff.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/highgui/src/grfmt_tiff.cpp b/modules/highgui/src/grfmt_tiff.cpp index 5179531f50..4b4d8011e8 100644 --- a/modules/highgui/src/grfmt_tiff.cpp +++ b/modules/highgui/src/grfmt_tiff.cpp @@ -246,13 +246,15 @@ bool TiffDecoder::readData( Mat& img ) return false; } + uchar * bstart = buffer + (tile_height0 - tile_height) * tile_width0 * 4; + for( i = 0; i < tile_height; i++ ) if( color ) - icvCvt_BGRA2BGR_8u_C4C3R( buffer + i*tile_width*4, 0, + icvCvt_BGRA2BGR_8u_C4C3R( bstart + i*tile_width0*4, 0, data + x*3 + img.step*(tile_height - i - 1), 0, cvSize(tile_width,1), 2 ); else - icvCvt_BGRA2Gray_8u_C4C1R( buffer + i*tile_width*4, 0, + icvCvt_BGRA2Gray_8u_C4C1R( bstart + i*tile_width0*4, 0, data + x + img.step*(tile_height - i - 1), 0, cvSize(tile_width,1), 2 ); break; @@ -271,25 +273,27 @@ bool TiffDecoder::readData( Mat& img ) return false; } + uint16 * bstart = buffer16 + (tile_height0 - tile_height) * tile_width0 * ncn; + for( i = 0; i < tile_height; i++ ) { if( color ) { if( ncn == 1 ) { - icvCvt_Gray2BGR_16u_C1C3R(buffer16 + i*tile_width*ncn, 0, + icvCvt_Gray2BGR_16u_C1C3R(bstart + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x*3, 0, cvSize(tile_width,1) ); } else if( ncn == 3 ) { - icvCvt_RGB2BGR_16u_C3R(buffer16 + i*tile_width*ncn, 0, + icvCvt_RGB2BGR_16u_C3R(bstart + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x*3, 0, cvSize(tile_width,1) ); } else { - icvCvt_BGRA2BGR_16u_C4C3R(buffer16 + i*tile_width*ncn, 0, + icvCvt_BGRA2BGR_16u_C4C3R(bstart + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x*3, 0, cvSize(tile_width,1), 2 ); } @@ -299,12 +303,12 @@ bool TiffDecoder::readData( Mat& img ) if( ncn == 1 ) { memcpy((ushort*)(data + img.step*i)+x, - buffer16 + i*tile_width*ncn, + bstart + i*tile_width0*ncn, tile_width*sizeof(buffer16[0])); } else { - icvCvt_BGRA2Gray_16u_CnC1R(buffer16 + i*tile_width*ncn, 0, + icvCvt_BGRA2Gray_16u_CnC1R(bstart + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x, 0, cvSize(tile_width,1), ncn, 2 ); } @@ -327,18 +331,21 @@ bool TiffDecoder::readData( Mat& img ) return false; } + float * fstart = buffer32 + (tile_height0 - tile_height) * tile_width0 * sizeof(buffer32[0]); + double * dstart = buffer64 + (tile_height0 - tile_height) * tile_width0 * sizeof(buffer64[0]); + for( i = 0; i < tile_height; i++ ) { if(dst_bpp == 32) { memcpy((float*)(data + img.step*i)+x, - buffer32 + i*tile_width*ncn, + fstart + i*tile_width0*ncn, tile_width*sizeof(buffer32[0])); } else { memcpy((double*)(data + img.step*i)+x, - buffer64 + i*tile_width*ncn, + dstart + i*tile_width0*ncn, tile_width*sizeof(buffer64[0])); } } From d1606b4aa37f6d1d6daeebe039f593a37cbf607e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 30 Jan 2014 17:01:48 +0400 Subject: [PATCH 02/26] ocl: added SVM perf test --- modules/ocl/perf/perf_ml.cpp | 106 ++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/modules/ocl/perf/perf_ml.cpp b/modules/ocl/perf/perf_ml.cpp index db45eceb8f..13dcaa18f0 100644 --- a/modules/ocl/perf/perf_ml.cpp +++ b/modules/ocl/perf/perf_ml.cpp @@ -106,4 +106,108 @@ PERF_TEST_P(KNNFixture, KNN, }else OCL_PERF_ELSE SANITY_CHECK(best_label); -} \ No newline at end of file +} + + +typedef TestBaseWithParam > SVMFixture; + +// code is based on: samples\cpp\tutorial_code\ml\non_linear_svms\non_linear_svms.cpp +PERF_TEST_P(SVMFixture, DISABLED_SVM, + testing::Values(50, 100)) +{ + + const int NTRAINING_SAMPLES = get<0>(GetParam()); // Number of training samples per class + + #define FRAC_LINEAR_SEP 0.9f // Fraction of samples which compose the linear separable part + + const int WIDTH = 512, HEIGHT = 512; + + Mat trainData(2*NTRAINING_SAMPLES, 2, CV_32FC1); + Mat labels (2*NTRAINING_SAMPLES, 1, CV_32FC1); + + RNG rng(100); // Random value generation class + + // Set up the linearly separable part of the training data + int nLinearSamples = (int) (FRAC_LINEAR_SEP * NTRAINING_SAMPLES); + + // Generate random points for the class 1 + Mat trainClass = trainData.rowRange(0, nLinearSamples); + // The x coordinate of the points is in [0, 0.4) + Mat c = trainClass.colRange(0, 1); + rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(0.4 * WIDTH)); + // The y coordinate of the points is in [0, 1) + c = trainClass.colRange(1,2); + rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(HEIGHT)); + + // Generate random points for the class 2 + trainClass = trainData.rowRange(2*NTRAINING_SAMPLES-nLinearSamples, 2*NTRAINING_SAMPLES); + // The x coordinate of the points is in [0.6, 1] + c = trainClass.colRange(0 , 1); + rng.fill(c, RNG::UNIFORM, Scalar(0.6*WIDTH), Scalar(WIDTH)); + // The y coordinate of the points is in [0, 1) + c = trainClass.colRange(1,2); + rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(HEIGHT)); + + //------------------ Set up the non-linearly separable part of the training data --------------- + + // Generate random points for the classes 1 and 2 + trainClass = trainData.rowRange( nLinearSamples, 2*NTRAINING_SAMPLES-nLinearSamples); + // The x coordinate of the points is in [0.4, 0.6) + c = trainClass.colRange(0,1); + rng.fill(c, RNG::UNIFORM, Scalar(0.4*WIDTH), Scalar(0.6*WIDTH)); + // The y coordinate of the points is in [0, 1) + c = trainClass.colRange(1,2); + rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(HEIGHT)); + + //------------------------- Set up the labels for the classes --------------------------------- + labels.rowRange( 0, NTRAINING_SAMPLES).setTo(1); // Class 1 + labels.rowRange(NTRAINING_SAMPLES, 2*NTRAINING_SAMPLES).setTo(2); // Class 2 + + //------------------------ Set up the support vector machines parameters -------------------- + CvSVMParams params; + params.svm_type = SVM::C_SVC; + params.C = 0.1; + params.kernel_type = SVM::LINEAR; + params.term_crit = TermCriteria(CV_TERMCRIT_ITER, (int)1e7, 1e-6); + + Mat dst = Mat::zeros(HEIGHT, WIDTH, CV_8UC1); + + Mat samples(WIDTH*HEIGHT, 2, CV_32FC1); + int k = 0; + for (int i = 0; i < HEIGHT; ++i) + { + for (int j = 0; j < WIDTH; ++j) + { + samples.at(k, 0) = (float)i; + samples.at(k, 0) = (float)j; + k++; + } + } + Mat results(WIDTH*HEIGHT, 1, CV_32FC1); + + CvMat samples_ = samples; + CvMat results_ = results; + + if(RUN_PLAIN_IMPL) + { + CvSVM svm; + svm.train(trainData, labels, Mat(), Mat(), params); + TEST_CYCLE() + { + svm.predict(&samples_, &results_); + } + } + else if(RUN_OCL_IMPL) + { + CvSVM_OCL svm; + svm.train(trainData, labels, Mat(), Mat(), params); + OCL_TEST_CYCLE() + { + svm.predict(&samples_, &results_); + } + } + else + OCL_PERF_ELSE + + SANITY_CHECK_NOTHING(); +} From 8b8c3681484536fdc28d5fd0e8b7dd06ca2970f5 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 14 Feb 2014 17:56:03 +0400 Subject: [PATCH 03/26] fixed two warnings in gpu sources (-Wshadow, -Wno-sign-promo) --- cmake/OpenCVDetectCUDA.cmake | 3 +++ modules/core/CMakeLists.txt | 2 +- modules/nonfree/CMakeLists.txt | 2 +- modules/superres/CMakeLists.txt | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index b35a7977c3..56b142970e 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -180,6 +180,9 @@ if(CUDA_FOUND) # we remove -Wsign-promo as it generates warnings under linux string(REPLACE "-Wsign-promo" "" ${var} "${${var}}") + # we remove -Wno-sign-promo as it generates warnings under linux + string(REPLACE "-Wno-sign-promo" "" ${var} "${${var}}") + # we remove -Wno-delete-non-virtual-dtor because it's used for C++ compiler # but NVCC uses C compiler by default string(REPLACE "-Wno-delete-non-virtual-dtor" "" ${var} "${${var}}") diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index fe3eff33ab..d9de52da2f 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -25,7 +25,7 @@ endif() if(HAVE_CUDA) ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wshadow) endif() file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h") diff --git a/modules/nonfree/CMakeLists.txt b/modules/nonfree/CMakeLists.txt index 53fb2f73e9..b43273bc80 100644 --- a/modules/nonfree/CMakeLists.txt +++ b/modules/nonfree/CMakeLists.txt @@ -3,7 +3,7 @@ if(BUILD_ANDROID_PACKAGE) endif() set(the_description "Functionality with possible limitations on the use") -ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) +ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wshadow) if(ENABLE_DYNAMIC_CUDA) add_definitions(-DDYNAMIC_CUDA_SUPPORT) ocv_define_module(nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_ocl) diff --git a/modules/superres/CMakeLists.txt b/modules/superres/CMakeLists.txt index 3da8dc2c6e..82c61cccb4 100644 --- a/modules/superres/CMakeLists.txt +++ b/modules/superres/CMakeLists.txt @@ -3,5 +3,5 @@ if(ANDROID OR IOS) endif() set(the_description "Super Resolution") -ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 -Wundef) +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 -Wundef -Wshadow) ocv_define_module(superres opencv_imgproc opencv_video OPTIONAL opencv_gpu opencv_highgui opencv_ocl ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) From cce225f6e9cb18d5e6432e90faf8ca94f0267374 Mon Sep 17 00:00:00 2001 From: yash Date: Sat, 15 Feb 2014 12:48:42 +0530 Subject: [PATCH 04/26] fixed doc/tutorials/imgproc/histograms/template_matching/template_matching.rst --- .../imgproc/histograms/template_matching/template_matching.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tutorials/imgproc/histograms/template_matching/template_matching.rst b/doc/tutorials/imgproc/histograms/template_matching/template_matching.rst index cb7ece86f1..db6838a125 100644 --- a/doc/tutorials/imgproc/histograms/template_matching/template_matching.rst +++ b/doc/tutorials/imgproc/histograms/template_matching/template_matching.rst @@ -85,7 +85,7 @@ d. **method=CV\_TM\_CCORR\_NORMED** .. math:: - R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I'(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}} + R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}} e. **method=CV\_TM\_CCOEFF** From 9a98cd6e6520d348b0be067360236c50181e9983 Mon Sep 17 00:00:00 2001 From: Marijan Vukcevich Date: Tue, 4 Feb 2014 10:10:50 -0800 Subject: [PATCH 05/26] Update cap_ios_abstract_camera.mm AVCaptureVideoPreviewLayer setOrientation is depricated. This fixes the warning and provides backward compatibility. --- modules/highgui/src/cap_ios_abstract_camera.mm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/highgui/src/cap_ios_abstract_camera.mm b/modules/highgui/src/cap_ios_abstract_camera.mm index a77e200a82..6675a9db63 100644 --- a/modules/highgui/src/cap_ios_abstract_camera.mm +++ b/modules/highgui/src/cap_ios_abstract_camera.mm @@ -278,9 +278,21 @@ { self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession]; - if ([self.captureVideoPreviewLayer isOrientationSupported]) { - [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation]; - } + if ([self.captureVideoPreviewLayer respondsToSelector:@selector(connection)]) + { + if ([self.captureVideoPreviewLayer.connection isVideoOrientationSupported]) + { + [self.captureVideoPreviewLayer.connection setVideoOrientation:self.defaultAVCaptureVideoOrientation]; + } + } + else + { + // Deprecated in 6.0; here for backward compatibility + if ([self.captureVideoPreviewLayer isOrientationSupported]) + { + [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation]; + } + } if (parentView != nil) { self.captureVideoPreviewLayer.frame = self.parentView.bounds; From 01a980aa9e2293c079012ead3976ed51223dbcbb Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Mon, 17 Feb 2014 15:28:21 +0400 Subject: [PATCH 06/26] Fixed compilation with IPP on Linux. Added linking with Intel compiler runtime libraries. --- cmake/OpenCVFindIPP.cmake | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/cmake/OpenCVFindIPP.cmake b/cmake/OpenCVFindIPP.cmake index 772cae886f..db02e6acbf 100644 --- a/cmake/OpenCVFindIPP.cmake +++ b/cmake/OpenCVFindIPP.cmake @@ -163,9 +163,16 @@ function(set_ipp_new_libraries _LATEST_VERSION) ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}${IPP_SUFFIX}${IPP_LIB_SUFFIX} ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPI}${IPP_SUFFIX}${IPP_LIB_SUFFIX} ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPS}${IPP_SUFFIX}${IPP_LIB_SUFFIX} - ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX} - PARENT_SCOPE) + ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX}) + if (UNIX) + set(IPP_LIBRARIES + ${IPP_LIBRARIES} + ${IPP_LIB_PREFIX}irc${CMAKE_SHARED_LIBRARY_SUFFIX} + ${IPP_LIB_PREFIX}imf${CMAKE_SHARED_LIBRARY_SUFFIX} + ${IPP_LIB_PREFIX}svml${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE) return() endfunction() @@ -208,19 +215,39 @@ function(set_ipp_variables _LATEST_VERSION) set(IPP_INCLUDE_DIRS ${IPP_ROOT_DIR}/include PARENT_SCOPE) if (APPLE) - set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib PARENT_SCOPE) + set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib) elseif (IPP_X64) if(NOT EXISTS ${IPP_ROOT_DIR}/lib/intel64) message(SEND_ERROR "IPP EM64T libraries not found") endif() - set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/intel64 PARENT_SCOPE) + set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/intel64) else() if(NOT EXISTS ${IPP_ROOT_DIR}/lib/ia32) message(SEND_ERROR "IPP IA32 libraries not found") endif() - set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/ia32 PARENT_SCOPE) + set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/ia32) endif() + if (UNIX) + get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../lib REALPATH) + if (IPP_X64) + if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/intel64) + message(SEND_ERROR "Intel compiler EM64T libraries not found") + endif() + set(IPP_LIBRARY_DIRS + ${IPP_LIBRARY_DIRS} + ${INTEL_COMPILER_LIBRARY_DIR}/intel64) + else() + if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/ia32) + message(SEND_ERROR "Intel compiler IA32 libraries not found") + endif() + set(IPP_LIBRARY_DIRS + ${IPP_LIBRARY_DIRS} + ${INTEL_COMPILER_LIBRARY_DIR}/ia32) + endif() + endif() + set(IPP_LIBRARY_DIRS ${IPP_LIBRARY_DIRS} PARENT_SCOPE) + # set IPP_LIBRARIES variable (7.x or 8.x lib names) set_ipp_new_libraries(${_LATEST_VERSION}) set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE) From 8236181c627448bf5e662648ab78ffc60d7d835e Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Mon, 17 Feb 2014 17:01:23 +0400 Subject: [PATCH 07/26] Added more colorizing options to XLS generating script --- modules/ts/misc/xls-report.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/ts/misc/xls-report.py b/modules/ts/misc/xls-report.py index e71a7f66c7..6b90b59247 100755 --- a/modules/ts/misc/xls-report.py +++ b/modules/ts/misc/xls-report.py @@ -97,6 +97,9 @@ re_data_type = re.compile(r'^ (?: 8 | 16 | 32 | 64 ) [USF] C [1234] $', re.VERBO time_style = xlwt.easyxf(num_format_str='#0.00') no_time_style = xlwt.easyxf('pattern: pattern solid, fore_color gray25') +failed_style = xlwt.easyxf('pattern: pattern solid, fore_color red') +noimpl_style = xlwt.easyxf('pattern: pattern solid, fore_color orange') +style_dict = {"failed": failed_style, "noimpl":noimpl_style} speedup_style = time_style good_speedup_style = xlwt.easyxf('font: color green', num_format_str='#0.00') @@ -328,7 +331,7 @@ def main(): for c in config_names: if c in configs: - sheet.write(row, col, configs[c], time_style) + sheet.write(row, col, configs[c], style_dict.get(configs[c], time_style)) else: sheet.write(row, col, None, no_time_style) col += 1 From cc529d971b7fb6b459c9cc5acde44cf1afded5d9 Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Mon, 17 Feb 2014 17:37:02 +0400 Subject: [PATCH 08/26] removed tabs --- .../highgui/src/cap_ios_abstract_camera.mm | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/modules/highgui/src/cap_ios_abstract_camera.mm b/modules/highgui/src/cap_ios_abstract_camera.mm index 6675a9db63..e5c70724b1 100644 --- a/modules/highgui/src/cap_ios_abstract_camera.mm +++ b/modules/highgui/src/cap_ios_abstract_camera.mm @@ -279,20 +279,20 @@ self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession]; if ([self.captureVideoPreviewLayer respondsToSelector:@selector(connection)]) - { - if ([self.captureVideoPreviewLayer.connection isVideoOrientationSupported]) - { - [self.captureVideoPreviewLayer.connection setVideoOrientation:self.defaultAVCaptureVideoOrientation]; - } - } - else - { - // Deprecated in 6.0; here for backward compatibility - if ([self.captureVideoPreviewLayer isOrientationSupported]) - { - [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation]; - } - } + { + if ([self.captureVideoPreviewLayer.connection isVideoOrientationSupported]) + { + [self.captureVideoPreviewLayer.connection setVideoOrientation:self.defaultAVCaptureVideoOrientation]; + } + } + else + { + // Deprecated in 6.0; here for backward compatibility + if ([self.captureVideoPreviewLayer isOrientationSupported]) + { + [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation]; + } + } if (parentView != nil) { self.captureVideoPreviewLayer.frame = self.parentView.bounds; @@ -302,9 +302,6 @@ NSLog(@"[Camera] created AVCaptureVideoPreviewLayer"); } - - - - (void)setDesiredCameraPosition:(AVCaptureDevicePosition)desiredPosition; { for (AVCaptureDevice *device in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) { From 63235f51f06f15b0eddeb3a212808f91f574400b Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Mon, 17 Feb 2014 17:56:12 +0400 Subject: [PATCH 09/26] fixed year in copyright --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 312a1c2b9e..d815924727 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -44,7 +44,7 @@ master_doc = 'index' # General information about the project. project = u'OpenCV' -copyright = u'2011-2013, opencv dev team' +copyright = u'2011-2014, opencv dev team' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the From a8eab26bae0bc7f7f38e9e72235896311c65de72 Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Mon, 17 Feb 2014 18:10:08 +0400 Subject: [PATCH 10/26] fixed incorrect code in introduction tutorial --- .../linux_gcc_cmake/linux_gcc_cmake.rst | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst b/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst index f582d32086..9aa1f6289b 100644 --- a/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst +++ b/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst @@ -25,29 +25,34 @@ Let's use a simple program such as DisplayImage.cpp shown below. .. code-block:: cpp - #include - #include + #include + #include - using namespace cv; + using namespace cv; - int main( int argc, char** argv ) - { - Mat image; - image = imread( argv[1], 1 ); + int main(int argc, char** argv ) + { + if ( argc != 2 ) + { + printf("usage: DisplayImage.out \n"); + return -1; + } - if( argc != 2 || !image.data ) - { - printf( "No image data \n" ); - return -1; - } + Mat image; + image = imread( argv[1], 1 ); - namedWindow( "Display Image", CV_WINDOW_AUTOSIZE ); - imshow( "Display Image", image ); + if ( !image.data ) + { + printf("No image data \n"); + return -1; + } + namedWindow("Display Image", CV_WINDOW_AUTOSIZE ); + imshow("Display Image", image); - waitKey(0); + waitKey(0); - return 0; - } + return 0; + } Create a CMake file --------------------- From 01527c44fd23c6a5956557910710fae2a7880a95 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 17 Feb 2014 21:50:00 +0400 Subject: [PATCH 11/26] removed unused field --- modules/imgproc/src/clahe.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/imgproc/src/clahe.cpp b/modules/imgproc/src/clahe.cpp index 4ce479713e..9ecf792daf 100644 --- a/modules/imgproc/src/clahe.cpp +++ b/modules/imgproc/src/clahe.cpp @@ -49,8 +49,8 @@ namespace class CLAHE_CalcLut_Body : public cv::ParallelLoopBody { public: - CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int tilesY, int clipLimit, float lutScale) : - src_(src), lut_(lut), tileSize_(tileSize), tilesX_(tilesX), tilesY_(tilesY), clipLimit_(clipLimit), lutScale_(lutScale) + CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) : + src_(src), lut_(lut), tileSize_(tileSize), tilesX_(tilesX), clipLimit_(clipLimit), lutScale_(lutScale) { } @@ -62,7 +62,6 @@ namespace cv::Size tileSize_; int tilesX_; - int tilesY_; int clipLimit_; float lutScale_; }; @@ -293,7 +292,7 @@ namespace clipLimit = std::max(clipLimit, 1); } - CLAHE_CalcLut_Body calcLutBody(srcForLut, lut_, tileSize, tilesX_, tilesY_, clipLimit, lutScale); + CLAHE_CalcLut_Body calcLutBody(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale); cv::parallel_for_(cv::Range(0, tilesX_ * tilesY_), calcLutBody); CLAHE_Interpolation_Body interpolationBody(src, dst, lut_, tileSize, tilesX_, tilesY_); From 017a282c7ab2a83922107ba5c425fb35a7ef43dc Mon Sep 17 00:00:00 2001 From: yash Date: Tue, 18 Feb 2014 10:34:58 +0530 Subject: [PATCH 12/26] Minor error in the documentation Load and Save Image --- doc/tutorials/introduction/load_save_image/load_save_image.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tutorials/introduction/load_save_image/load_save_image.rst b/doc/tutorials/introduction/load_save_image/load_save_image.rst index 50fb9ea37f..675387efb1 100644 --- a/doc/tutorials/introduction/load_save_image/load_save_image.rst +++ b/doc/tutorials/introduction/load_save_image/load_save_image.rst @@ -100,7 +100,7 @@ Explanation imshow( imageName, image ); imshow( "Gray image", gray_image ); -#. Add add the *waitKey(0)* function call for the program to wait forever for an user key press. +#. Add the *waitKey(0)* function call for the program to wait forever for an user key press. Result From 38ef8894b7f5e85217faa6e44cf7d10fc4bc7020 Mon Sep 17 00:00:00 2001 From: yash Date: Tue, 18 Feb 2014 10:51:05 +0530 Subject: [PATCH 13/26] Made a sentence in the doc for Mat::copyTo more clearer --- modules/core/doc/basic_structures.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index 6f9c10e1db..d23da8de19 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -1355,7 +1355,7 @@ The method copies the matrix data to another matrix. Before copying the data, th so that the destination matrix is reallocated if needed. While ``m.copyTo(m);`` works flawlessly, the function does not handle the case of a partial overlap between the source and the destination matrices. -When the operation mask is specified, and the ``Mat::create`` call shown above reallocated the matrix, the newly allocated matrix is initialized with all zeros before copying the data. +When the operation mask is specified and the ``Mat::create`` call shown above is invoked to reallocate the matrix, the newly allocated matrix is initialized with all zeros before copying the data. .. _Mat::convertTo: From de6d13088fc435e1cdc4c6ae4221a3912b80b2ca Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 14 Feb 2014 17:43:33 +0400 Subject: [PATCH 14/26] gcov tool support added. --- CMakeLists.txt | 1 + cmake/OpenCVCompilerOptions.cmake | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14033b390f..b5fbb9f2b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,6 +206,7 @@ OCV_OPTION(ENABLE_DYNAMIC_CUDA "Enabled dynamic CUDA linkage" OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) ) OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) IF (CMAKE_VERSION VERSION_GREATER "2.8.0") ) OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX ) +OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CMAKE_COMPILER_IS_GNUCXX ) OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) ) OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) ) OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) ) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index a4b039280f..d525609d18 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -187,6 +187,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_extra_compiler_option(-ffunction-sections) endif() + if(ENABLE_COVERAGE) + set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} --coverage") + set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} --coverage") + endif() + set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG") set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0 -DDEBUG -D_DEBUG") endif() From 394c74b349d1d0e912324b9e2136700be0a39e8b Mon Sep 17 00:00:00 2001 From: yash Date: Tue, 18 Feb 2014 15:04:27 +0530 Subject: [PATCH 15/26] edited the doc for mat::copyto and clarified the part regarding reallocation by .create --- modules/core/doc/basic_structures.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index d23da8de19..54a1f4261d 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -1355,7 +1355,7 @@ The method copies the matrix data to another matrix. Before copying the data, th so that the destination matrix is reallocated if needed. While ``m.copyTo(m);`` works flawlessly, the function does not handle the case of a partial overlap between the source and the destination matrices. -When the operation mask is specified and the ``Mat::create`` call shown above is invoked to reallocate the matrix, the newly allocated matrix is initialized with all zeros before copying the data. +When the operation mask is specified, if the ``Mat::create`` call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data. .. _Mat::convertTo: From e35d98e566b628d52660854bf9a6e56c0251654e Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Mon, 17 Feb 2014 16:08:28 +0400 Subject: [PATCH 16/26] Worked around an apparent GCC bug in moments. --- modules/imgproc/src/moments.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/imgproc/src/moments.cpp b/modules/imgproc/src/moments.cpp index 784a61b8df..2fca862bca 100644 --- a/modules/imgproc/src/moments.cpp +++ b/modules/imgproc/src/moments.cpp @@ -197,6 +197,10 @@ static void icvContourMoments( CvSeq* contour, CvMoments* moments ) \****************************************************************************************/ template +#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 9 +// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60196 +__attribute__((optimize("no-tree-vectorize"))) +#endif static void momentsInTile( const cv::Mat& img, double* moments ) { cv::Size size = img.size(); From 77df5948e78cc630c8f6478f276b386c8affaa61 Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Tue, 18 Feb 2014 13:56:26 +0400 Subject: [PATCH 17/26] removed trailing spaces --- modules/highgui/src/cap_ios_abstract_camera.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_ios_abstract_camera.mm b/modules/highgui/src/cap_ios_abstract_camera.mm index e5c70724b1..b40b3648de 100644 --- a/modules/highgui/src/cap_ios_abstract_camera.mm +++ b/modules/highgui/src/cap_ios_abstract_camera.mm @@ -291,7 +291,7 @@ if ([self.captureVideoPreviewLayer isOrientationSupported]) { [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation]; - } + } } if (parentView != nil) { From da9bdf9c15e435364d52cc317d3e119ca4aaae44 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 18 Feb 2014 14:16:54 +0400 Subject: [PATCH 18/26] fixes typo and unused variables --- modules/gpu/src/cuda/nlm.cu | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/gpu/src/cuda/nlm.cu b/modules/gpu/src/cuda/nlm.cu index 922cba7e5a..8789a4cf6b 100644 --- a/modules/gpu/src/cuda/nlm.cu +++ b/modules/gpu/src/cuda/nlm.cu @@ -266,7 +266,7 @@ namespace cv { namespace gpu { namespace device __device__ __forceinline__ int calcDist(const uchar2& a, const uchar2& b) { return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y); } __device__ __forceinline__ int calcDist(const uchar3& a, const uchar3& b) { return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z); } - template struct FastNonLocalMenas + template struct FastNonLocalMeans { enum { @@ -290,7 +290,7 @@ namespace cv { namespace gpu { namespace device int block_window; float minus_h2_inv; - FastNonLocalMenas(int search_window_, int block_window_, float h) : search_radius(search_window_/2), block_radius(block_window_/2), + FastNonLocalMeans(int search_window_, int block_window_, float h) : search_radius(search_window_/2), block_radius(block_window_/2), search_window(search_window_), block_window(block_window_), minus_h2_inv(-1.f/(h * h * VecTraits::cn)) {} PtrStep src; @@ -394,7 +394,7 @@ namespace cv { namespace gpu { namespace device } } - __device__ __forceinline__ void convolve_window(int i, int j, const int* dist_sums, PtrStepi& col_sums, PtrStepi& up_col_sums, T& dst) const + __device__ __forceinline__ void convolve_window(int i, int j, const int* dist_sums, T& dst) const { typedef typename TypeVec::cn>::vec_type sum_type; @@ -471,18 +471,18 @@ namespace cv { namespace gpu { namespace device __syncthreads(); - convolve_window(i, j, dist_sums, col_sums, up_col_sums, dst(i, j)); + convolve_window(i, j, dist_sums, dst(i, j)); } } }; template - __global__ void fast_nlm_kernel(const FastNonLocalMenas fnlm, PtrStepSz dst) { fnlm(dst); } + __global__ void fast_nlm_kernel(const FastNonLocalMeans fnlm, PtrStepSz dst) { fnlm(dst); } void nln_fast_get_buffer_size(const PtrStepSzb& src, int search_window, int block_window, int& buffer_cols, int& buffer_rows) { - typedef FastNonLocalMenas FNLM; + typedef FastNonLocalMeans FNLM; dim3 grid(divUp(src.cols, FNLM::TILE_COLS), divUp(src.rows, FNLM::TILE_ROWS)); buffer_cols = search_window * search_window * grid.y; @@ -493,7 +493,7 @@ namespace cv { namespace gpu { namespace device void nlm_fast_gpu(const PtrStepSzb& src, PtrStepSzb dst, PtrStepi buffer, int search_window, int block_window, float h, cudaStream_t stream) { - typedef FastNonLocalMenas FNLM; + typedef FastNonLocalMeans FNLM; FNLM fnlm(search_window, block_window, h); fnlm.src = (PtrStepSz)src; From e460a29cab9d929de3d12632718f7c677a20d5c7 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 18 Feb 2014 14:24:17 +0400 Subject: [PATCH 19/26] typo --- .../android/service/engine/jni/Tests/HardwareDetectionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp b/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp index 83dd9c27e1..8e7dfab006 100644 --- a/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp +++ b/platforms/android/service/engine/jni/Tests/HardwareDetectionTest.cpp @@ -55,7 +55,7 @@ TEST(Parse, ParseEmptyString) EXPECT_FALSE(ParseString(a, key, value)); } -TEST(Parse, ParseStringWithoutSeporator) +TEST(Parse, ParseStringWithoutSeparator) { string a = "qqqwww"; string key; From 4c1ed138461400a8d74801a92c9cc048d8539723 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 18 Feb 2014 12:01:01 +0400 Subject: [PATCH 20/26] Warning fixes for GCC 4.8. --- modules/imgproc/src/color.cpp | 4 ++-- modules/imgproc/src/floodfill.cpp | 2 +- modules/imgproc/src/imgwarp.cpp | 12 +++++++++++- modules/imgproc/test/test_convhull.cpp | 8 ++++---- modules/legacy/src/bgfg_gaussmix.cpp | 4 ++-- modules/legacy/src/face.cpp | 1 + modules/legacy/src/lmeds.cpp | 4 ++-- modules/ts/src/ts_arrtest.cpp | 2 +- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 15c214ef91..08f27aef97 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -3214,7 +3214,7 @@ struct YUV420p2RGB888Invoker : ParallelLoopBody const int rangeBegin = range.start * 2; const int rangeEnd = range.end * 2; - size_t uvsteps[2] = {width/2, stride - width/2}; + int uvsteps[2] = {width/2, stride - width/2}; int usIdx = ustepIdx, vsIdx = vstepIdx; const uchar* y1 = my1 + rangeBegin * stride; @@ -3282,7 +3282,7 @@ struct YUV420p2RGBA8888Invoker : ParallelLoopBody int rangeBegin = range.start * 2; int rangeEnd = range.end * 2; - size_t uvsteps[2] = {width/2, stride - width/2}; + int uvsteps[2] = {width/2, stride - width/2}; int usIdx = ustepIdx, vsIdx = vstepIdx; const uchar* y1 = my1 + rangeBegin * stride; diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index 74047676e4..db2563ddea 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -41,7 +41,7 @@ #include "precomp.hpp" -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic ignored "-Warray-bounds" #endif diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 4748af2cee..6cbb416c9e 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -1217,8 +1217,13 @@ public: alpha(_alpha), _beta(__beta), ssize(_ssize), dsize(_dsize), ksize(_ksize), xmin(_xmin), xmax(_xmax) { + CV_Assert(ksize <= MAX_ESIZE); } +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif virtual void operator() (const Range& range) const { int dy, cn = src.channels(); @@ -1267,6 +1272,9 @@ public: vresize( (const WT**)rows, (T*)(dst.data + dst.step*dy), beta, dsize.width ); } } +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +# pragma GCC diagnostic pop +#endif private: Mat src; @@ -1274,7 +1282,9 @@ private: const int* xofs, *yofs; const AT* alpha, *_beta; Size ssize, dsize; - int ksize, xmin, xmax; + const int ksize, xmin, xmax; + + resizeGeneric_Invoker& operator = (const resizeGeneric_Invoker&); }; template diff --git a/modules/imgproc/test/test_convhull.cpp b/modules/imgproc/test/test_convhull.cpp index e20b1a2076..75fddfd04f 100644 --- a/modules/imgproc/test/test_convhull.cpp +++ b/modules/imgproc/test/test_convhull.cpp @@ -1225,7 +1225,7 @@ CV_FitLineTest::CV_FitLineTest() max_noise = 0.05; } -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Warray-bounds" #endif @@ -1301,7 +1301,7 @@ void CV_FitLineTest::generate_point_set( void* pointsSet ) } } -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic pop #endif @@ -1329,7 +1329,7 @@ void CV_FitLineTest::run_func() cv::fitLine(cv::cvarrToMat(points), (cv::Vec6f&)line[0], dist_type, 0, reps, aeps); } -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Warray-bounds" #endif @@ -1412,7 +1412,7 @@ _exit_: return code; } -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic pop #endif diff --git a/modules/legacy/src/bgfg_gaussmix.cpp b/modules/legacy/src/bgfg_gaussmix.cpp index 3cb7a5af9f..829e4fa14c 100644 --- a/modules/legacy/src/bgfg_gaussmix.cpp +++ b/modules/legacy/src/bgfg_gaussmix.cpp @@ -415,7 +415,7 @@ CV_INLINE int _icvRemoveShadowGMM(float* data, int nD, //IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.26, no.5, pages 651-656, 2004 //http://www.zoranz.net/Publications/zivkovic2004PAMI.pdf -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif @@ -608,7 +608,7 @@ CV_INLINE int _icvUpdateGMM(float* data, int nD, return bBackground; } -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic pop #endif diff --git a/modules/legacy/src/face.cpp b/modules/legacy/src/face.cpp index b188a10def..2132ea8f95 100644 --- a/modules/legacy/src/face.cpp +++ b/modules/legacy/src/face.cpp @@ -200,6 +200,7 @@ void RFace::CalculateError(FaceData * lpFaceData) void RFace::CreateFace(void * lpData) { FaceData Data; + memset(&Data, 0, sizeof(FaceData)); double Error = MAX_ERROR; double CurError = MAX_ERROR; diff --git a/modules/legacy/src/lmeds.cpp b/modules/legacy/src/lmeds.cpp index 33b57a7597..d1bb298ec1 100644 --- a/modules/legacy/src/lmeds.cpp +++ b/modules/legacy/src/lmeds.cpp @@ -163,7 +163,7 @@ icvLMedS( int *points1, int *points2, int numPoints, CvMatrix3 * fundamentalMatr /*===========================================================================*/ /*===========================================================================*/ -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Warray-bounds" #endif @@ -328,7 +328,7 @@ icvCubic( double a2, double a1, double a0, double *squares ) return CV_NO_ERR; } /* icvCubic */ -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) # pragma GCC diagnostic pop #endif diff --git a/modules/ts/src/ts_arrtest.cpp b/modules/ts/src/ts_arrtest.cpp index ec3f18330d..cdfbe23b37 100644 --- a/modules/ts/src/ts_arrtest.cpp +++ b/modules/ts/src/ts_arrtest.cpp @@ -122,7 +122,7 @@ void ArrayTest::get_test_array_types_and_sizes( int /*test_case_idx*/, vector Date: Thu, 20 Feb 2014 10:24:52 +0400 Subject: [PATCH 21/26] fix bug #3562: add missing __syncthreads to edgesHysteresisLocalKernel --- modules/gpu/src/cuda/canny.cu | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/gpu/src/cuda/canny.cu b/modules/gpu/src/cuda/canny.cu index 1dc179e340..468eec4172 100644 --- a/modules/gpu/src/cuda/canny.cu +++ b/modules/gpu/src/cuda/canny.cu @@ -293,8 +293,12 @@ namespace canny n += smem[threadIdx.y + 2][threadIdx.x + 2] == 2; } + __syncthreads(); + if (n > 0) smem[threadIdx.y + 1][threadIdx.x + 1] = 2; + + __syncthreads(); } const int e = smem[threadIdx.y + 1][threadIdx.x + 1]; From aa5311ea9fdc21f4b76df555aa0d1a9d529bb325 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 20 Feb 2014 18:55:08 +0400 Subject: [PATCH 22/26] backport of master-based perf tests for matchTemplate to 2.4 --- modules/ocl/perf/perf_match_template.cpp | 57 +++++++++++++++++++++++ modules/ts/include/opencv2/ts/ts_perf.hpp | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/modules/ocl/perf/perf_match_template.cpp b/modules/ocl/perf/perf_match_template.cpp index 3ee038a840..561a978ae3 100644 --- a/modules/ocl/perf/perf_match_template.cpp +++ b/modules/ocl/perf/perf_match_template.cpp @@ -119,3 +119,60 @@ PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, OCL_TYPICAL_MAT_SIZES) else OCL_PERF_ELSE } + +CV_ENUM(MethodType, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED) + +typedef std::tr1::tuple ImgSize_TmplSize_Method_t; +typedef TestBaseWithParam ImgSize_TmplSize_Method; + +PERF_TEST_P(ImgSize_TmplSize_Method, MatchTemplate, + ::testing::Combine( + testing::Values(szSmall128, cv::Size(320, 240), + cv::Size(640, 480), cv::Size(800, 600), + cv::Size(1024, 768), cv::Size(1280, 1024)), + testing::Values(cv::Size(12, 12), cv::Size(28, 9), + cv::Size(8, 30), cv::Size(16, 16)), + MethodType::all() + ) + ) +{ + Size imgSz = get<0>(GetParam()); + Size tmplSz = get<1>(GetParam()); + int method = get<2>(GetParam()); + + Mat img(imgSz, CV_8UC1); + Mat tmpl(tmplSz, CV_8UC1); + Mat result(imgSz - tmplSz + Size(1, 1), CV_32F); + + bool isNormed = + method == TM_CCORR_NORMED || + method == TM_SQDIFF_NORMED || + method == TM_CCOEFF_NORMED; + + declare.in(img, tmpl, WARMUP_RNG).out(result).time(30); + + if (RUN_OCL_IMPL) + { + ocl::oclMat oclImg(img), oclTmpl(tmpl), oclResult(result.size(), CV_32F); + + OCL_TEST_CYCLE() matchTemplate(oclImg, oclTmpl, oclResult, method); + + oclResult.download(result); + } + else if (RUN_PLAIN_IMPL) + { + OCL_TEST_CYCLE() matchTemplate(img, tmpl, result, method); + } + else + OCL_PERF_ELSE + + double eps = isNormed ? 3e-2 + : 255 * 255 * tmpl.total() * 1e-4; + + if (method == TM_SQDIFF_NORMED) + SANITY_CHECK_NOTHING(); + else if (isNormed) + SANITY_CHECK(result, eps, ERROR_RELATIVE); + else + SANITY_CHECK(result, eps); +} diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index e32057de23..088479aa8f 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -209,7 +209,7 @@ private: #define SANITY_CHECK(array, ...) ::perf::Regression::add(this, #array, array , ## __VA_ARGS__) #define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__) #define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__) -#define SANITY_CHECK_NOTHING() this->setVerified(); +#define SANITY_CHECK_NOTHING() this->setVerified() class CV_EXPORTS GpuPerf { From 46d128e073a0736f93301f98446f3e721a3e3fd1 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Thu, 20 Feb 2014 22:10:22 +0200 Subject: [PATCH 23/26] add test (needs updated opencv_extra repo) --- modules/highgui/test/test_grfmt.cpp | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index 86954e3e10..1fdf2c515a 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -419,4 +419,46 @@ TEST(Highgui_Tiff, decode_tile16384x16384) remove(file3.c_str()); remove(file4.c_str()); } + +class CV_GrfmtReadTifTiledWithNotFullTiles: public cvtest::BaseTest +{ +public: + void run(int) + { + try + { + /* see issue #3472 - dealing with tiled images where the tile size is + * not a multiple of image size. + * The tiled images were created with 'convert' from ImageMagick, + * using the command 'convert -define tiff:tile-geometry=128x128 -depth [8|16] + * Note that the conversion to 16 bits expands the range from 0-255 to 0-255*255, + * so the test converts back but rounding errors cause small differences. + */ + cv::Mat img = imread(string(ts->get_data_path()) + "readwrite/non_tiled.tif",-1); + if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + ASSERT_TRUE(img.channels() == 3); + cv::Mat tiled8 = imread(string(ts->get_data_path()) + "readwrite/tiled_8.tif", -1); + if (tiled8.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + ASSERT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, tiled8); + + cv::Mat tiled16 = imread(string(ts->get_data_path()) + "readwrite/tiled_16.tif", -1); + if (tiled16.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + ASSERT_TRUE(tiled16.elemSize() == 6); + tiled16.convertTo(tiled8, CV_8UC3, 1./256.); + ASSERT_PRED_FORMAT2(cvtest::MatComparator(2, 0), img, tiled8); + // What about 32, 64 bit? + } + catch(...) + { + ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION); + } + ts->set_failed_test_info(cvtest::TS::OK); + } +}; + +TEST(Highgui_Tiff, decode_tile_remainder) +{ + CV_GrfmtReadTifTiledWithNotFullTiles test; test.safe_run(); +} + #endif From 31c8f2ec57138aa2708aa2b59f930d4102c0d7e8 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Thu, 20 Feb 2014 22:12:22 +0200 Subject: [PATCH 24/26] fix code, it turns out only TIFFReadRGBATile needs buffer pointer mangling --- modules/highgui/src/grfmt_tiff.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/modules/highgui/src/grfmt_tiff.cpp b/modules/highgui/src/grfmt_tiff.cpp index 4b4d8011e8..614d001231 100644 --- a/modules/highgui/src/grfmt_tiff.cpp +++ b/modules/highgui/src/grfmt_tiff.cpp @@ -235,19 +235,21 @@ bool TiffDecoder::readData( Mat& img ) { case 8: { + uchar * bstart = buffer; if( !is_tiled ) ok = TIFFReadRGBAStrip( tif, y, (uint32*)buffer ); else + { ok = TIFFReadRGBATile( tif, x, y, (uint32*)buffer ); - + //Tiles fill the buffer from the bottom up + bstart += (tile_height0 - tile_height) * tile_width0 * 4; + } if( !ok ) { close(); return false; } - uchar * bstart = buffer + (tile_height0 - tile_height) * tile_width0 * 4; - for( i = 0; i < tile_height; i++ ) if( color ) icvCvt_BGRA2BGR_8u_C4C3R( bstart + i*tile_width0*4, 0, @@ -273,27 +275,25 @@ bool TiffDecoder::readData( Mat& img ) return false; } - uint16 * bstart = buffer16 + (tile_height0 - tile_height) * tile_width0 * ncn; - for( i = 0; i < tile_height; i++ ) { if( color ) { if( ncn == 1 ) { - icvCvt_Gray2BGR_16u_C1C3R(bstart + i*tile_width0*ncn, 0, + icvCvt_Gray2BGR_16u_C1C3R(buffer16 + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x*3, 0, cvSize(tile_width,1) ); } else if( ncn == 3 ) { - icvCvt_RGB2BGR_16u_C3R(bstart + i*tile_width0*ncn, 0, + icvCvt_RGB2BGR_16u_C3R(buffer16 + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x*3, 0, cvSize(tile_width,1) ); } else { - icvCvt_BGRA2BGR_16u_C4C3R(bstart + i*tile_width0*ncn, 0, + icvCvt_BGRA2BGR_16u_C4C3R(buffer16 + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x*3, 0, cvSize(tile_width,1), 2 ); } @@ -303,12 +303,12 @@ bool TiffDecoder::readData( Mat& img ) if( ncn == 1 ) { memcpy((ushort*)(data + img.step*i)+x, - bstart + i*tile_width0*ncn, + buffer16 + i*tile_width0*ncn, tile_width*sizeof(buffer16[0])); } else { - icvCvt_BGRA2Gray_16u_CnC1R(bstart + i*tile_width0*ncn, 0, + icvCvt_BGRA2Gray_16u_CnC1R(buffer16 + i*tile_width0*ncn, 0, (ushort*)(data + img.step*i) + x, 0, cvSize(tile_width,1), ncn, 2 ); } @@ -331,21 +331,18 @@ bool TiffDecoder::readData( Mat& img ) return false; } - float * fstart = buffer32 + (tile_height0 - tile_height) * tile_width0 * sizeof(buffer32[0]); - double * dstart = buffer64 + (tile_height0 - tile_height) * tile_width0 * sizeof(buffer64[0]); - for( i = 0; i < tile_height; i++ ) { if(dst_bpp == 32) { memcpy((float*)(data + img.step*i)+x, - fstart + i*tile_width0*ncn, + buffer32 + i*tile_width0*ncn, tile_width*sizeof(buffer32[0])); } else { memcpy((double*)(data + img.step*i)+x, - dstart + i*tile_width0*ncn, + buffer64 + i*tile_width0*ncn, tile_width*sizeof(buffer64[0])); } } From dc50dc72548a9b7c970610ee95a7797e644040be Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Fri, 21 Feb 2014 13:54:58 +0200 Subject: [PATCH 25/26] fix merge --- modules/highgui/test/test_grfmt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index bd9e79ad02..f451036ab9 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -420,7 +420,7 @@ TEST(Highgui_Tiff, decode_tile16384x16384) remove(file4.c_str()); } -class CV_GrfmtReadTifTiledWithNotFullTiles: public cvtest::BaseTest +TEST(Highgui_Tiff, write_read_16bit_big_little_endian) { // see issue #2601 "16-bit Grayscale TIFF Load Failures Due to Buffer Underflow and Endianness" From 1cf75c0cabff9699ab80d078629f9af0f71f1ec1 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 21 Feb 2014 16:08:49 +0400 Subject: [PATCH 26/26] Hardcode iOS's endianness, since the TestBigEndian module doesn't work there --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5fbb9f2b2..fb49497412 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -448,8 +448,15 @@ include(cmake/OpenCVModule.cmake) # ---------------------------------------------------------------------------- # Detect endianness of build platform # ---------------------------------------------------------------------------- -include(TestBigEndian) -test_big_endian(WORDS_BIGENDIAN) + +if(CMAKE_SYSTEM_NAME STREQUAL iOS) + # test_big_endian needs try_compile, which doesn't work for iOS + # http://public.kitware.com/Bug/view.php?id=12288 + set(WORDS_BIGENDIAN 0) +else() + include(TestBigEndian) + test_big_endian(WORDS_BIGENDIAN) +endif() # ---------------------------------------------------------------------------- # Detect 3rd-party libraries