diff --git a/modules/features2d/test/test_descriptors_regression.cpp b/modules/features2d/test/test_descriptors_regression.cpp index 717cae58d6..7f44bc2bdd 100644 --- a/modules/features2d/test/test_descriptors_regression.cpp +++ b/modules/features2d/test/test_descriptors_regression.cpp @@ -162,7 +162,8 @@ protected: ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); } - image.create( 50, 50, CV_8UC3 ); + RNG rng; + image = cvtest::randomMat(rng, Size(50, 50), CV_8UC3, 0, 255, false); try { dextractor->compute( image, keypoints, descriptors ); diff --git a/modules/imgcodecs/src/grfmt_exr.cpp b/modules/imgcodecs/src/grfmt_exr.cpp index 5957549f33..71d89126ab 100644 --- a/modules/imgcodecs/src/grfmt_exr.cpp +++ b/modules/imgcodecs/src/grfmt_exr.cpp @@ -381,6 +381,11 @@ bool ExrDecoder::readData( Mat& img ) close(); + if( !m_native_depth || (!color && m_iscolor )) + { + delete[] buffer; + } + return result; } diff --git a/modules/imgcodecs/src/grfmt_jpeg.cpp b/modules/imgcodecs/src/grfmt_jpeg.cpp index 6862a06ebb..8a2900a194 100644 --- a/modules/imgcodecs/src/grfmt_jpeg.cpp +++ b/modules/imgcodecs/src/grfmt_jpeg.cpp @@ -270,7 +270,11 @@ int JpegDecoder::getOrientation() ExifReader reader( m_filename ); if( reader.parse() ) { - orientation = reader.getTag( ORIENTATION ).field_u16;//orientation is unsigned short, so check field_u16 + ExifEntry_t entry = reader.getTag( ORIENTATION ); + if (entry.tag != INVALID_TAG) + { + orientation = entry.field_u16; //orientation is unsigned short, so check field_u16 + } } return orientation; diff --git a/modules/imgcodecs/src/jpeg_exif.cpp b/modules/imgcodecs/src/jpeg_exif.cpp index c7b5b76a26..103e72ddec 100644 --- a/modules/imgcodecs/src/jpeg_exif.cpp +++ b/modules/imgcodecs/src/jpeg_exif.cpp @@ -52,10 +52,16 @@ namespace { namespace cv { +ExifEntry_t::ExifEntry_t() : + field_float(0), field_double(0), field_u32(0), field_s32(0), + tag(INVALID_TAG), field_u16(0), field_s16(0), field_u8(0), field_s8(0) +{ +} + /** * @brief ExifReader constructor */ -ExifReader::ExifReader(std::string filename) : m_filename(filename) +ExifReader::ExifReader(std::string filename) : m_filename(filename), m_format(NONE) { } diff --git a/modules/imgcodecs/src/jpeg_exif.hpp b/modules/imgcodecs/src/jpeg_exif.hpp index 9ca1381679..c8502c5c87 100644 --- a/modules/imgcodecs/src/jpeg_exif.hpp +++ b/modules/imgcodecs/src/jpeg_exif.hpp @@ -111,6 +111,8 @@ typedef std::pair u_rational_t; */ struct ExifEntry_t { + ExifEntry_t(); + std::vector field_u_rational; ///< vector of rational fields std::string field_str; ///< any kind of textual information diff --git a/modules/imgproc/src/drawing.cpp b/modules/imgproc/src/drawing.cpp index 2d975f1c30..8c052d1643 100644 --- a/modules/imgproc/src/drawing.cpp +++ b/modules/imgproc/src/drawing.cpp @@ -2331,10 +2331,10 @@ static void addChildContour(InputArrayOfArrays contours, int h_next = hierarchy[i][0], h_prev = hierarchy[i][1], v_next = hierarchy[i][2], v_prev = hierarchy[i][3]; - seq[i].h_next = (size_t)h_next < ncontours ? &seq[h_next] : 0; - seq[i].h_prev = (size_t)h_prev < ncontours ? &seq[h_prev] : 0; - seq[i].v_next = (size_t)v_next < ncontours ? &seq[v_next] : 0; - seq[i].v_prev = (size_t)v_prev < ncontours ? &seq[v_prev] : 0; + seq[i].h_next = (0 <= h_next && h_next < (int)ncontours) ? &seq[h_next] : 0; + seq[i].h_prev = (0 <= h_prev && h_prev < (int)ncontours) ? &seq[h_prev] : 0; + seq[i].v_next = (0 <= v_next && v_next < (int)ncontours) ? &seq[v_next] : 0; + seq[i].v_prev = (0 <= v_prev && v_prev < (int)ncontours) ? &seq[v_prev] : 0; if( v_next >= 0 ) addChildContour(contours, ncontours, hierarchy, v_next, seq, block); diff --git a/modules/imgproc/test/test_goodfeaturetotrack.cpp b/modules/imgproc/test/test_goodfeaturetotrack.cpp index 3e4ea8cde3..53aa08a865 100644 --- a/modules/imgproc/test/test_goodfeaturetotrack.cpp +++ b/modules/imgproc/test/test_goodfeaturetotrack.cpp @@ -320,7 +320,6 @@ protected: void run_func(); int validate_test_results( int test_case_idx ); - int aperture_size; Mat src, src_gray; Mat src_gray32f, src_gray8U; Mat mask; @@ -348,7 +347,7 @@ CV_GoodFeatureToTTest::CV_GoodFeatureToTTest() k = 0.04; mask = Mat(); test_case_count = 4; - + SrcType = 0; } int CV_GoodFeatureToTTest::prepare_test_case( int test_case_idx ) diff --git a/modules/photo/src/tonemap.cpp b/modules/photo/src/tonemap.cpp index e475482d66..1ccc84ea09 100644 --- a/modules/photo/src/tonemap.cpp +++ b/modules/photo/src/tonemap.cpp @@ -510,8 +510,11 @@ protected: void calculateSum(std::vector& x_contrast, std::vector& y_contrast, Mat& sum) { - sum = Mat::zeros(x_contrast[x_contrast.size() - 1].size(), CV_32F); - for(int i = (int)x_contrast.size() - 1; i >= 0; i--) + if (x_contrast.empty()) + return; + const int last = (int)x_contrast.size() - 1; + sum = Mat::zeros(x_contrast[last].size(), CV_32F); + for(int i = last; i >= 0; i--) { Mat grad_x, grad_y; getGradient(x_contrast[i], grad_x, 1); diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index c515c192fb..41fe81f5fc 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -82,6 +82,11 @@ Stitcher Stitcher::createDefault(bool try_use_gpu) stitcher.setExposureCompensator(makePtr()); stitcher.setBlender(makePtr(try_use_gpu)); + stitcher.work_scale_ = 1; + stitcher.seam_scale_ = 1; + stitcher.seam_work_aspect_ = 1; + stitcher.warped_image_scale_ = 1; + return stitcher; } diff --git a/modules/video/src/tvl1flow.cpp b/modules/video/src/tvl1flow.cpp index 429f9141cd..b10dc3f344 100644 --- a/modules/video/src/tvl1flow.cpp +++ b/modules/video/src/tvl1flow.cpp @@ -1133,18 +1133,22 @@ void EstimateDualVariablesBody::operator() (const Range& range) const { const float g1 = static_cast(hypot(u1xRow[x], u1yRow[x])); const float g2 = static_cast(hypot(u2xRow[x], u2yRow[x])); - const float g3 = static_cast(hypot(u3xRow[x], u3yRow[x])); const float ng1 = 1.0f + taut * g1; const float ng2 = 1.0f + taut * g2; - const float ng3 = 1.0f + taut * g3; p11Row[x] = (p11Row[x] + taut * u1xRow[x]) / ng1; p12Row[x] = (p12Row[x] + taut * u1yRow[x]) / ng1; p21Row[x] = (p21Row[x] + taut * u2xRow[x]) / ng2; p22Row[x] = (p22Row[x] + taut * u2yRow[x]) / ng2; - if (use_gamma) p31Row[x] = (p31Row[x] + taut * u3xRow[x]) / ng3; - if (use_gamma) p32Row[x] = (p32Row[x] + taut * u3yRow[x]) / ng3; + + if (use_gamma) + { + const float g3 = static_cast(hypot(u3xRow[x], u3yRow[x])); + const float ng3 = 1.0f + taut * g3; + p31Row[x] = (p31Row[x] + taut * u3xRow[x]) / ng3; + p32Row[x] = (p32Row[x] + taut * u3yRow[x]) / ng3; + } } } }