Merge remote-tracking branch 'upstream/3.4' into merge-3.4
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sat, 23 Oct 2021 15:33:31 +0000 (15:33 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sat, 23 Oct 2021 15:33:31 +0000 (15:33 +0000)
1  2 
modules/calib3d/src/calibration.cpp
modules/core/src/system.cpp
modules/imgcodecs/src/grfmt_bmp.cpp
modules/imgcodecs/test/test_grfmt.cpp
modules/imgproc/src/hough.cpp
modules/imgproc/test/test_convhull.cpp
modules/videoio/src/cap_ffmpeg_impl.hpp

Simple merge
@@@ -128,10 -126,10 +128,10 @@@ void* allocSingletonNewBuffer(size_t si
  #include <cstdlib>        // std::abort
  #endif
  
 -#if defined __ANDROID__ || defined __unix__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__
 +#if defined __ANDROID__ || defined __unix__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__ || defined __Fuchsia__
  #  include <unistd.h>
  #  include <fcntl.h>
- #if defined __QNXNTO__
+ #if defined __QNX__
  #  include <sys/elf.h>
  #else
  #  include <elf.h>
@@@ -205,8 -180,8 +205,8 @@@ bool  BmpDecoder::readHeader(
          throw;
      }
      // in 32 bit case alpha channel is used - so require CV_8UC4 type
-     m_type = iscolor ? (m_bpp == 32 ? CV_8UC4 : CV_8UC3 ) : CV_8UC1;
+     m_type = iscolor ? ((m_bpp == 32 && m_rle_code != BMP_RGB) ? CV_8UC4 : CV_8UC3 ) : CV_8UC1;
 -    m_origin = m_height > 0 ? IPL_ORIGIN_BL : IPL_ORIGIN_TL;
 +    m_origin = m_height > 0 ? ORIGIN_BL : ORIGIN_TL;
      m_height = std::abs(m_height);
  
      if( !result )
@@@ -295,32 -280,16 +295,43 @@@ TEST(Imgcodecs_Bmp, read_rle8
      EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), rle, ord);
  }
  
+ TEST(Imgcodecs_Bmp, read_32bit_rgb)
+ {
+     const string root = cvtest::TS::ptr()->get_data_path();
+     const string filenameInput = root + "readwrite/test_32bit_rgb.bmp";
+     const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+     ASSERT_FALSE(img.empty());
+     ASSERT_EQ(CV_8UC3, img.type());
+ }
 +TEST(Imgcodecs_Bmp, rgba_bit_mask)
 +{
 +    const string root = cvtest::TS::ptr()->get_data_path();
 +    const string filenameInput = root + "readwrite/test_rgba_mask.bmp";
 +
 +    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
 +    ASSERT_FALSE(img.empty());
 +    ASSERT_EQ(CV_8UC4, img.type());
 +
 +    const uchar* data = img.ptr();
 +    ASSERT_EQ(data[3], 255);
 +}
 +
 +TEST(Imgcodecs_Bmp, read_32bit_xrgb)
 +{
 +    const string root = cvtest::TS::ptr()->get_data_path();
 +    const string filenameInput = root + "readwrite/test_32bit_xrgb.bmp";
 +
 +    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
 +    ASSERT_FALSE(img.empty());
 +    ASSERT_EQ(CV_8UC4, img.type());
 +
 +    const uchar* data = img.ptr();
 +    ASSERT_EQ(data[3], 255);
 +}
 +
++
  #ifdef HAVE_IMGCODEC_HDR
  TEST(Imgcodecs_Hdr, regression)
  {
@@@ -2253,31 -1728,27 +2253,30 @@@ static void HoughCircles( InputArray _i
      }
  
      CV_Assert(!_image.empty() && _image.type() == CV_8UC1 && (_image.isMat() || _image.isUMat()));
-     CV_Assert(_circles.isMat() || _circles.isVector());
  
 -    if( dp <= 0 || minDist <= 0 || param1 <= 0 || param2 <= 0)
 -        CV_Error( Error::StsOutOfRange, "dp, min_dist, canny_threshold and acc_threshold must be all positive numbers" );
 +    if( dp <= 0 || minDist <= 0 || param1 <= 0)
 +        CV_Error( Error::StsOutOfRange, "dp, min_dist and canny_threshold must be all positive numbers" );
  
 -    int cannyThresh = cvRound(param1), accThresh = cvRound(param2), kernelSize = cvRound(param3);
 +    switch( method )
 +    {
 +    case HOUGH_GRADIENT:
 +        {
 +        int cannyThresh = cvRound(param1), accThresh = cvRound(param2), kernelSize = cvRound(param3);
 +        minRadius = std::max(0, minRadius);
  
 -    minRadius = std::max(0, minRadius);
 +        if( param2 <= 0 )
 +            CV_Error( Error::StsOutOfRange, "acc_threshold must be a positive number" );
  
 -    if(maxCircles < 0)
 -        maxCircles = INT_MAX;
 +        if(maxCircles < 0)
 +            maxCircles = INT_MAX;
  
 -    bool centersOnly = (maxRadius < 0);
 +        bool centersOnly = (maxRadius < 0);
  
 -    if( maxRadius <= 0 )
 -        maxRadius = std::max( _image.rows(), _image.cols() );
 -    else if( maxRadius <= minRadius )
 -        maxRadius = minRadius + 2;
 +        if( maxRadius <= 0 )
 +            maxRadius = std::max( _image.rows(), _image.cols() );
 +        else if( maxRadius <= minRadius )
 +            maxRadius = minRadius + 2;
  
 -    switch( method )
 -    {
 -    case CV_HOUGH_GRADIENT:
          if (type == CV_32FC3)
              HoughCirclesGradient<Vec3f>(_image, _circles, (float)dp, (float)minDist,
                                          minRadius, maxRadius, cannyThresh,