From 5c544bcd519767ae60c69585d8f09663eac8682d Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Thu, 9 Jan 2025 07:55:52 +0200 Subject: [PATCH 1/8] cudacodec: Enable use of features added in PR 25874 in windows now the FFmpeg dll has been updated. --- modules/cudacodec/src/video_writer.cpp | 8 -------- modules/cudacodec/test/test_video.cpp | 10 ---------- 2 files changed, 18 deletions(-) diff --git a/modules/cudacodec/src/video_writer.cpp b/modules/cudacodec/src/video_writer.cpp index 5bb1a533faf..af6c3f04e23 100644 --- a/modules/cudacodec/src/video_writer.cpp +++ b/modules/cudacodec/src/video_writer.cpp @@ -53,10 +53,6 @@ Ptr createVideoWriter(const String&, const Size, const C #else // !defined HAVE_NVCUVENC -#if defined(WIN32) // remove when FFmpeg wrapper includes PR25874 -#define WIN32_WAIT_FOR_FFMPEG_WRAPPER_UPDATE -#endif - NV_ENC_BUFFER_FORMAT EncBufferFormat(const ColorFormat colorFormat); int NChannels(const ColorFormat colorFormat); GUID CodecGuid(const Codec codec); @@ -107,9 +103,7 @@ void FFmpegVideoWriter::onEncoded(const std::vector>& vPack Mat wrappedPacket(1, packet.size(), CV_8UC1, (void*)packet.data()); const double ptsDouble = static_cast(pts.at(i)); CV_Assert(static_cast(ptsDouble) == pts.at(i)); -#if !defined(WIN32_WAIT_FOR_FFMPEG_WRAPPER_UPDATE) CV_Assert(writer.set(VIDEOWRITER_PROP_PTS, ptsDouble)); -#endif writer.write(wrappedPacket); } } @@ -337,11 +331,9 @@ void VideoWriterImpl::InitializeEncoder(const GUID codec, const double fps) initializeParams.encodeConfig->rcParams.maxBitRate = encoderParams.maxBitRate; initializeParams.encodeConfig->rcParams.targetQuality = encoderParams.targetQuality; initializeParams.encodeConfig->gopLength = encoderParams.gopLength; -#if !defined(WIN32_WAIT_FOR_FFMPEG_WRAPPER_UPDATE) if (initializeParams.encodeConfig->frameIntervalP > 1) { CV_Assert(encoderCallback->setFrameIntervalP(initializeParams.encodeConfig->frameIntervalP)); } -#endif if (codec == NV_ENC_CODEC_H264_GUID) initializeParams.encodeConfig->encodeCodecConfig.h264Config.idrPeriod = encoderParams.idrPeriod; else if (codec == NV_ENC_CODEC_HEVC_GUID) diff --git a/modules/cudacodec/test/test_video.cpp b/modules/cudacodec/test/test_video.cpp index 29f25b2ca1e..f431933b157 100644 --- a/modules/cudacodec/test/test_video.cpp +++ b/modules/cudacodec/test/test_video.cpp @@ -1011,10 +1011,6 @@ struct H264ToH265 : SetDevice { }; -#if defined(WIN32) // remove when FFmpeg wrapper includes PR25874 -#define WIN32_WAIT_FOR_FFMPEG_WRAPPER_UPDATE -#endif - CUDA_TEST_P(H264ToH265, Transcode) { const std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "../highgui/video/big_buck_bunny.h264"; @@ -1054,10 +1050,8 @@ CUDA_TEST_P(H264ToH265, Transcode) for (int i = 0; i < nFrames; ++i) { cap >> frame; ASSERT_FALSE(frame.empty()); -#if !defined(WIN32_WAIT_FOR_FFMPEG_WRAPPER_UPDATE) const int pts = static_cast(cap.get(CAP_PROP_PTS)); ASSERT_EQ(i, pts > 0 ? pts : 0); // FFmpeg back end returns dts if pts is zero. -#endif } } ASSERT_EQ(0, remove(outputFile.c_str())); @@ -1201,10 +1195,8 @@ CUDA_TEST_P(Write, Writer) for (int i = 0; i < nFrames; ++i) { cap >> frame; ASSERT_FALSE(frame.empty()); -#if !defined(WIN32_WAIT_FOR_FFMPEG_WRAPPER_UPDATE) const int pts = static_cast(cap.get(CAP_PROP_PTS)); ASSERT_EQ(i, pts > 0 ? pts : 0); // FFmpeg back end returns dts if pts is zero. -#endif } } ASSERT_EQ(0, remove(outputFile.c_str())); @@ -1299,10 +1291,8 @@ CUDA_TEST_P(EncoderParams, Writer) const bool keyFrameActual = capRaw.get(CAP_PROP_LRF_HAS_KEY_FRAME) == 1.0; const bool keyFrameReference = i % idrPeriod == 0; ASSERT_EQ(keyFrameActual, keyFrameReference); -#if !defined(WIN32_WAIT_FOR_FFMPEG_WRAPPER_UPDATE) const int pts = static_cast(cap.get(CAP_PROP_PTS)); ASSERT_EQ(i, pts > 0 ? pts : 0); // FFmpeg back end returns dts if pts is zero. -#endif } } } From 45c86643ef8cb8c58952177b6acb5a0d394236a1 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Mon, 13 Jan 2025 15:05:40 +0100 Subject: [PATCH 2/8] Remove useless C headers The cvInvSqrt code replacement is taken from 5.x --- modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp | 1 - modules/cvv/src/qtutil/filter/sobelfilterwidget.cpp | 1 - modules/dpm/src/dpm_cascade.cpp | 2 +- modules/dpm/src/dpm_feature.cpp | 2 +- modules/dpm/src/dpm_feature.hpp | 1 - modules/img_hash/src/precomp.hpp | 1 - modules/xfeatures2d/src/affine_feature2d.cpp | 1 - modules/xphoto/samples/dct_image_denoising.cpp | 1 - modules/xphoto/src/dct_image_denoising.cpp | 10 ++++------ 9 files changed, 6 insertions(+), 14 deletions(-) diff --git a/modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp b/modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp index 36d799f8f3c..43dc6e0cc58 100644 --- a/modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp +++ b/modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp @@ -66,7 +66,6 @@ the use of this software, even if advised of the possibility of such damage. #include "opencv2/viz/vizcore.hpp" #include "opencv2/highgui.hpp" -#include "opencv2/highgui/highgui_c.h" #include "opencv2/imgproc.hpp" /** @defgroup cnn_3dobj 3D object recognition and pose estimation API diff --git a/modules/cvv/src/qtutil/filter/sobelfilterwidget.cpp b/modules/cvv/src/qtutil/filter/sobelfilterwidget.cpp index c9f0a8aec0c..d4f67369c74 100644 --- a/modules/cvv/src/qtutil/filter/sobelfilterwidget.cpp +++ b/modules/cvv/src/qtutil/filter/sobelfilterwidget.cpp @@ -1,7 +1,6 @@ #include "sobelfilterwidget.hpp" #include "opencv2/imgproc.hpp" -#include "opencv2/imgproc/types_c.h" #include #include diff --git a/modules/dpm/src/dpm_cascade.cpp b/modules/dpm/src/dpm_cascade.cpp index e64f7a50557..542cef7d94a 100644 --- a/modules/dpm/src/dpm_cascade.cpp +++ b/modules/dpm/src/dpm_cascade.cpp @@ -62,7 +62,7 @@ void DPMCascade::loadCascadeModel(const string &modelPath) if (!is_success) { string errorMessage = format("Unable to parse the model: %s", modelPath.c_str()); - CV_Error(CV_StsBadArg, errorMessage); + CV_Error(Error::StsBadArg, errorMessage); } model.initModel(); diff --git a/modules/dpm/src/dpm_feature.cpp b/modules/dpm/src/dpm_feature.cpp index c4fb7c75b59..4670f686d1e 100644 --- a/modules/dpm/src/dpm_feature.cpp +++ b/modules/dpm/src/dpm_feature.cpp @@ -81,7 +81,7 @@ void ParalComputePyramid::initialize() if (params.maxScale < params.interval) { - CV_Error(CV_StsBadArg, "The image is too small to create a pyramid"); + CV_Error(Error::StsBadArg, "The image is too small to create a pyramid"); return; } diff --git a/modules/dpm/src/dpm_feature.hpp b/modules/dpm/src/dpm_feature.hpp index 1c06d95af99..0a83507ea8c 100644 --- a/modules/dpm/src/dpm_feature.hpp +++ b/modules/dpm/src/dpm_feature.hpp @@ -43,7 +43,6 @@ #define __DPM_FEATURE__ #include "opencv2/core.hpp" -#include "opencv2/core/core_c.h" #include "opencv2/imgproc.hpp" #include diff --git a/modules/img_hash/src/precomp.hpp b/modules/img_hash/src/precomp.hpp index 24bb8168a8f..1fa7c0cb8fa 100644 --- a/modules/img_hash/src/precomp.hpp +++ b/modules/img_hash/src/precomp.hpp @@ -8,7 +8,6 @@ #include "opencv2/core.hpp" #include "opencv2/core/base.hpp" #include "opencv2/imgproc.hpp" -#include "opencv2/imgproc/types_c.h" #include "opencv2/img_hash.hpp" #include diff --git a/modules/xfeatures2d/src/affine_feature2d.cpp b/modules/xfeatures2d/src/affine_feature2d.cpp index 7c7e1873210..d6dd00b7c92 100644 --- a/modules/xfeatures2d/src/affine_feature2d.cpp +++ b/modules/xfeatures2d/src/affine_feature2d.cpp @@ -8,7 +8,6 @@ #include "precomp.hpp" #include "opencv2/imgproc.hpp" -#include "opencv2/imgproc/types_c.h" namespace { diff --git a/modules/xphoto/samples/dct_image_denoising.cpp b/modules/xphoto/samples/dct_image_denoising.cpp index e305a23efbf..387ded0f486 100644 --- a/modules/xphoto/samples/dct_image_denoising.cpp +++ b/modules/xphoto/samples/dct_image_denoising.cpp @@ -4,7 +4,6 @@ #include "opencv2/highgui.hpp" #include "opencv2/core/utility.hpp" -#include "opencv2/imgproc/types_c.h" const char* keys = { diff --git a/modules/xphoto/src/dct_image_denoising.cpp b/modules/xphoto/src/dct_image_denoising.cpp index c43bbb43c1c..31159068b7a 100644 --- a/modules/xphoto/src/dct_image_denoising.cpp +++ b/modules/xphoto/src/dct_image_denoising.cpp @@ -47,10 +47,8 @@ #include "opencv2/imgproc.hpp" #include "opencv2/core.hpp" -#include "opencv2/core/core_c.h" #include "opencv2/core/types.hpp" -#include "opencv2/core/types_c.h" namespace cv { @@ -137,9 +135,9 @@ namespace xphoto { CV_Assert( src.type() == CV_MAKE_TYPE(CV_32F, 3) ); - cv::Matx33f mt(cvInvSqrt(3.0f), cvInvSqrt(3.0f), cvInvSqrt(3.0f), - cvInvSqrt(2.0f), 0.0f, -cvInvSqrt(2.0f), - cvInvSqrt(6.0f), -2.0f*cvInvSqrt(6.0f), cvInvSqrt(6.0f)); + cv::Matx33f mt(pow(3.0f, -0.5f), pow(3.0f, -0.5f), pow(3.0f, -0.5f), + pow(2.0f, -0.5f), 0.0f, -pow(2.0f, -0.5f), + pow(6.0f, -0.5f), -2.0f*pow(6.0f, -0.5f), pow(6.0f, -0.5f)); cv::transform(src, dst, mt); @@ -175,7 +173,7 @@ namespace xphoto else if ( img.type() == CV_32FC1 ) grayDctDenoising( img, img, sigma, psize ); else - CV_Error_( CV_StsNotImplemented, + CV_Error_( Error::StsNotImplemented, ("Unsupported source image format (=%d)", img.type()) ); img.convertTo( dst, src.type() ); From b4a91cd4e6aeaffc52938590545a6a6974babe28 Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Wed, 8 Jan 2025 20:52:26 +0200 Subject: [PATCH 3/8] =?UTF-8?q?=EF=BB=BFcudacodec:=20Add=20flag=20to=20sig?= =?UTF-8?q?nal=20whether=20the=20luma=20and=20chroma=20samples=20in=20the?= =?UTF-8?q?=20yuv=20frames=20passed=20to=20VideoWriter=20occupy=20the=20fu?= =?UTF-8?q?ll=20or=20limited=20range=20as=20defined=20by=20the=20Annex=20E?= =?UTF-8?q?=20of=20the=20ITU-T=20Specification.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cudacodec/include/opencv2/cudacodec.hpp | 3 ++- modules/cudacodec/src/video_writer.cpp | 25 +++++++++++++++++-- modules/cudacodec/test/test_video.cpp | 8 +++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/modules/cudacodec/include/opencv2/cudacodec.hpp b/modules/cudacodec/include/opencv2/cudacodec.hpp index 307fa79edae..35f5b28cc83 100644 --- a/modules/cudacodec/include/opencv2/cudacodec.hpp +++ b/modules/cudacodec/include/opencv2/cudacodec.hpp @@ -186,7 +186,7 @@ struct CV_EXPORTS_W_SIMPLE EncoderParams public: CV_WRAP EncoderParams() : nvPreset(ENC_PRESET_P3), tuningInfo(ENC_TUNING_INFO_HIGH_QUALITY), encodingProfile(ENC_CODEC_PROFILE_AUTOSELECT), rateControlMode(ENC_PARAMS_RC_VBR), multiPassEncoding(ENC_MULTI_PASS_DISABLED), constQp({ 0,0,0 }), averageBitRate(0), maxBitRate(0), - targetQuality(30), gopLength(250), idrPeriod(250) {}; + targetQuality(30), gopLength(250), idrPeriod(250), videoFullRangeFlag(false){}; CV_PROP_RW EncodePreset nvPreset; CV_PROP_RW EncodeTuningInfo tuningInfo; CV_PROP_RW EncodeProfile encodingProfile; @@ -198,6 +198,7 @@ struct CV_EXPORTS_W_SIMPLE EncoderParams CV_PROP_RW uint8_t targetQuality; //!< value 0 - 51 where video quality decreases as targetQuality increases, used with \ref ENC_PARAMS_RC_VBR. CV_PROP_RW int gopLength; //!< the number of pictures in one GOP, ensuring \ref idrPeriod >= \ref gopLength. CV_PROP_RW int idrPeriod; //!< IDR interval, ensuring \ref idrPeriod >= \ref gopLength. + CV_PROP_RW bool videoFullRangeFlag;//!< Indicates if the black level, luma and chroma of the source are represented using the full or limited range (AKA TV or "analogue" range) of values as defined in Annex E of the ITU-T Specification. }; CV_EXPORTS bool operator==(const EncoderParams& lhs, const EncoderParams& rhs); diff --git a/modules/cudacodec/src/video_writer.cpp b/modules/cudacodec/src/video_writer.cpp index af6c3f04e23..74581e21a85 100644 --- a/modules/cudacodec/src/video_writer.cpp +++ b/modules/cudacodec/src/video_writer.cpp @@ -315,6 +315,13 @@ GUID EncodingPresetGuid(const EncodePreset nvPreset) { CV_Error(Error::StsUnsupportedFormat, msg); } +std::string GetVideoCodecString(const GUID codec) { + if (codec == NV_ENC_CODEC_H264_GUID) return "AVC/H.264"; + else if (codec == NV_ENC_CODEC_HEVC_GUID) return "H.265/HEVC"; + else if (codec == NV_ENC_CODEC_AV1_GUID) return "AV1"; + else return "Unknown"; +} + void VideoWriterImpl::InitializeEncoder(const GUID codec, const double fps) { NV_ENC_INITIALIZE_PARAMS initializeParams = {}; @@ -334,10 +341,24 @@ void VideoWriterImpl::InitializeEncoder(const GUID codec, const double fps) if (initializeParams.encodeConfig->frameIntervalP > 1) { CV_Assert(encoderCallback->setFrameIntervalP(initializeParams.encodeConfig->frameIntervalP)); } - if (codec == NV_ENC_CODEC_H264_GUID) + if (codec == NV_ENC_CODEC_H264_GUID) { initializeParams.encodeConfig->encodeCodecConfig.h264Config.idrPeriod = encoderParams.idrPeriod; - else if (codec == NV_ENC_CODEC_HEVC_GUID) + if (encoderParams.videoFullRangeFlag) { + initializeParams.encodeConfig->encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = 1; + initializeParams.encodeConfig->encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 1; + } + } + else if (codec == NV_ENC_CODEC_HEVC_GUID) { initializeParams.encodeConfig->encodeCodecConfig.hevcConfig.idrPeriod = encoderParams.idrPeriod; + if (encoderParams.videoFullRangeFlag) { + initializeParams.encodeConfig->encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFullRangeFlag = 1; + initializeParams.encodeConfig->encodeCodecConfig.hevcConfig.hevcVUIParameters.videoSignalTypePresentFlag = 1; + } + } + else { + std::string msg = "videoFullRangeFlag is not supported by codec: " + GetVideoCodecString(codec); + CV_LOG_WARNING(NULL, msg); + } pEnc->CreateEncoder(&initializeParams); } diff --git a/modules/cudacodec/test/test_video.cpp b/modules/cudacodec/test/test_video.cpp index f431933b157..deb75aafb5b 100644 --- a/modules/cudacodec/test/test_video.cpp +++ b/modules/cudacodec/test/test_video.cpp @@ -1060,7 +1060,7 @@ CUDA_TEST_P(H264ToH265, Transcode) INSTANTIATE_TEST_CASE_P(CUDA_Codec, H264ToH265, ALL_DEVICES); CV_ENUM(YuvColorFormats, cudacodec::ColorFormat::NV_YUV444, cudacodec::ColorFormat::NV_YUV420_10BIT, cudacodec::ColorFormat::NV_YUV444_10BIT) -PARAM_TEST_CASE(YUVFormats, cv::cuda::DeviceInfo, YuvColorFormats) +PARAM_TEST_CASE(YUVFormats, cv::cuda::DeviceInfo, YuvColorFormats, bool) { }; @@ -1069,6 +1069,7 @@ CUDA_TEST_P(YUVFormats, Transcode) cv::cuda::setDevice(GET_PARAM(0).deviceID()); const std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "../highgui/video/big_buck_bunny.h265"; const cv::cudacodec::ColorFormat writerColorFormat = static_cast(static_cast(GET_PARAM(1))); + const bool fullRange = GET_PARAM(2); constexpr double fps = 25; const cudacodec::Codec codec = cudacodec::Codec::HEVC; const std::string ext = ".mp4"; @@ -1082,6 +1083,7 @@ CUDA_TEST_P(YUVFormats, Transcode) cv::cudacodec::EncoderParams params; params.tuningInfo = cv::cudacodec::EncodeTuningInfo::ENC_TUNING_INFO_LOSSLESS; params.rateControlMode = cv::cudacodec::EncodeParamsRcMode::ENC_PARAMS_RC_CONSTQP; + params.videoFullRangeFlag = fullRange; for (int i = 0; i < nFrames; ++i) { ASSERT_TRUE(cap.read(frame)); ASSERT_FALSE(frame.empty()); @@ -1095,7 +1097,7 @@ CUDA_TEST_P(YUVFormats, Transcode) yuvFormat = cudacodec::SurfaceFormat::SF_P016; bitDepth = cudacodec::BitDepth::SIXTEEN; } - generateTestImages(frame, yuv, bgr, yuvFormat, cudacodec::ColorFormat::BGR, bitDepth, false); + generateTestImages(frame, yuv, bgr, yuvFormat, cudacodec::ColorFormat::BGR, bitDepth, false, fullRange); bgrGs.push_back(bgr.clone()); if (writer.empty()) writer = cv::cudacodec::createVideoWriter(outputFile, frame.size(), codec, fps, writerColorFormat, params); @@ -1119,7 +1121,7 @@ CUDA_TEST_P(YUVFormats, Transcode) ASSERT_EQ(0, remove(outputFile.c_str())); } -INSTANTIATE_TEST_CASE_P(CUDA_Codec, YUVFormats, testing::Combine(ALL_DEVICES, YuvColorFormats::all())); +INSTANTIATE_TEST_CASE_P(CUDA_Codec, YUVFormats, testing::Combine(ALL_DEVICES, YuvColorFormats::all(), testing::Bool())); #endif #if defined(HAVE_NVCUVENC) From 430db9244d63fead2cf06a272c099786d7067f90 Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Mon, 27 Jan 2025 13:43:02 +0900 Subject: [PATCH 4/8] suppress warning --- modules/cudalegacy/include/opencv2/cudalegacy/private.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cudalegacy/include/opencv2/cudalegacy/private.hpp b/modules/cudalegacy/include/opencv2/cudalegacy/private.hpp index fd3286c17eb..945a6bc4f53 100644 --- a/modules/cudalegacy/include/opencv2/cudalegacy/private.hpp +++ b/modules/cudalegacy/include/opencv2/cudalegacy/private.hpp @@ -91,6 +91,6 @@ namespace cv { namespace cuda //! @endcond -#endif HAVE_CUDA +#endif // HAVE_CUDA #endif // OPENCV_CORE_CUDALEGACY_PRIVATE_HPP From 127ce19a620bf5ee1944208b1fe9cdcb0bb818d6 Mon Sep 17 00:00:00 2001 From: Gursimar Singh Date: Mon, 3 Feb 2025 12:16:32 +0530 Subject: [PATCH 5/8] Merge pull request #3877 from gursimarsingh:mcc_pr3599_bugfix Fix bugs in checker_detector.cpp after resolving conflicts from PR #3599 #3877 ### This is the pull request for fixing some bugs in "Color Checker detection" + The link to pretrained tensorflow model for detecting Macbeth Color-checker: https://drive.google.com/drive/folders/1JNWlmyfZKxiYQoYk6f0RzcGtHuiZq1Pz #### 1, Detecting color-checker using Neural network When loading the pretrained Macbeth color-checker detector model, and set it successfully to CCheckerDetector, ``` Ptr detector = CCheckerDetector::create(); if (!detector->setNet(net)) { cout << "Loading Model failed: Aborting" << endl; return 0; } ``` then ``` if(!detector->process(image, cv::mcc::MCC24, color_checker_roi, 1, true, params)) { std::cout<<"Color-checker not found\n"; } Ptr checker = detector->getBestColorChecker(); Ptr cdraw = CCheckerDraw::create(checker); cdraw->draw(image); ``` + problem 1: cdraw function failed to draw the correct result due to the following code block failed to update box in checker: ``` for (Ptr checker : checkers){ for (cv::Point2f &corner : checker->getBox()) corner += static_cast(region.tl() + innerRegion.tl()); ... } ``` the corrected and test pass version is: ``` for (Ptr& checker : checkers){ std::vector restore_box; for (cv::Point2f& corner : checker->getBox()) { corner += static_cast(region.tl() + innerRegion.tl()); restore_box.emplace_back(corner); } checker->setBox(restore_box); } ... ``` See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake --- modules/mcc/src/checker_detector.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/mcc/src/checker_detector.cpp b/modules/mcc/src/checker_detector.cpp index 2de276d87fc..a7d624e15a6 100644 --- a/modules/mcc/src/checker_detector.cpp +++ b/modules/mcc/src/checker_detector.cpp @@ -232,9 +232,12 @@ bool CCheckerDetectorImpl:: #endif for (Ptr checker : checkers) { - for (cv::Point2f &corner : checker->getBox()) - corner += static_cast(region.tl()); - + const std::vector& checkerBox = checker->getBox(); + std::vector restore_box(checkerBox.size()); + for (size_t a = 0; a < checkerBox.size(); ++a) { + restore_box[a] = checkerBox[a] + static_cast(region.tl()); + } + checker->setBox(restore_box); { cv::AutoLock lock(mtx); m_checkers.push_back(checker); @@ -453,9 +456,12 @@ bool CCheckerDetectorImpl:: #endif for (Ptr checker : checkers) { - for (cv::Point2f &corner : checker->getBox()) - corner += static_cast(region.tl() + innerRegion.tl()); - + const std::vector& checkerBox = checker->getBox(); + std::vector restore_box(checkerBox.size()); + for (size_t a = 0; a < checkerBox.size(); ++a) { + restore_box[a] = checkerBox[a] + static_cast(region.tl() + innerRegion.tl()); + } + checker->setBox(restore_box); { cv::AutoLock lock(mtx); m_checkers.push_back(checker); From b8505ffc67a8ed94a965f54eab38bf26a10487b3 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Mon, 3 Feb 2025 10:11:35 +0300 Subject: [PATCH 6/8] CI: unified Linux pipeline (#3855) --- .github/workflows/PR-4.x.yaml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/PR-4.x.yaml b/.github/workflows/PR-4.x.yaml index 586d406b209..e9654e34f10 100644 --- a/.github/workflows/PR-4.x.yaml +++ b/.github/workflows/PR-4.x.yaml @@ -6,18 +6,14 @@ on: - 4.x jobs: + Linux: + uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-Linux.yaml@main + with: + workflow_branch: main + Ubuntu2004-ARM64: uses: opencv/ci-gha-workflow/.github/workflows/OCV-Contrib-PR-4.x-ARM64.yaml@main - Ubuntu2004-x64: - uses: opencv/ci-gha-workflow/.github/workflows/OCV-Contrib-PR-4.x-U20.yaml@main - - Ubuntu2204-x64: - uses: opencv/ci-gha-workflow/.github/workflows/OCV-Contrib-PR-4.x-U22.yaml@main - - Ubuntu2404-x64: - uses: opencv/ci-gha-workflow/.github/workflows/OCV-Contrib-PR-4.x-U24.yaml@main - Ubuntu2004-x64-CUDA: uses: opencv/ci-gha-workflow/.github/workflows/OCV-Contrib-PR-4.x-U20-Cuda.yaml@main From 4dcd845c1794132ce407a49d7ced97f2145879b3 Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Wed, 5 Feb 2025 02:47:40 +0300 Subject: [PATCH 7/8] cudacodec: fix VideoWriter version check bug introduced in #3711 --- modules/cudacodec/src/NvEncoder.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/cudacodec/src/NvEncoder.cpp b/modules/cudacodec/src/NvEncoder.cpp index b94bea200f5..3beb09514b8 100644 --- a/modules/cudacodec/src/NvEncoder.cpp +++ b/modules/cudacodec/src/NvEncoder.cpp @@ -101,7 +101,7 @@ void NvEncoder::CreateDefaultEncoderParams(NV_ENC_INITIALIZE_PARAMS* pIntializeP #endif pIntializeParams->tuningInfo = tuningInfo; pIntializeParams->encodeConfig->rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; -#if (NVENCAPI_MAJOR_VERSION >= 12 && NVENCAPI_MINOR_VERSION >= 2) +#if ((NVENCAPI_MAJOR_VERSION == 12 && NVENCAPI_MINOR_VERSION >= 2) || NVENCAPI_MAJOR_VERSION > 12) NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, 0, { NV_ENC_CONFIG_VER } }; #else NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, { NV_ENC_CONFIG_VER } }; @@ -119,7 +119,7 @@ void NvEncoder::CreateDefaultEncoderParams(NV_ENC_INITIALIZE_PARAMS* pIntializeP } else if (pIntializeParams->encodeGUID == NV_ENC_CODEC_HEVC_GUID) { -#if (NVENCAPI_MAJOR_VERSION >= 12 && NVENCAPI_MINOR_VERSION >= 2) +#if ((NVENCAPI_MAJOR_VERSION == 12 && NVENCAPI_MINOR_VERSION >= 2) || NVENCAPI_MAJOR_VERSION > 12) pIntializeParams->encodeConfig->encodeCodecConfig.hevcConfig.inputBitDepth = pIntializeParams->encodeConfig->encodeCodecConfig.hevcConfig.outputBitDepth = (m_eBufferFormat == NV_ENC_BUFFER_FORMAT_YUV420_10BIT || m_eBufferFormat == NV_ENC_BUFFER_FORMAT_YUV444_10BIT) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8; #else @@ -179,7 +179,7 @@ void NvEncoder::CreateEncoder(const NV_ENC_INITIALIZE_PARAMS* pEncoderParams) if (pEncoderParams->encodeGUID == NV_ENC_CODEC_HEVC_GUID) { bool yuv10BitFormat = (m_eBufferFormat == NV_ENC_BUFFER_FORMAT_YUV420_10BIT || m_eBufferFormat == NV_ENC_BUFFER_FORMAT_YUV444_10BIT) ? true : false; -#if (NVENCAPI_MAJOR_VERSION >= 12 && NVENCAPI_MINOR_VERSION >= 2) +#if ((NVENCAPI_MAJOR_VERSION == 12 && NVENCAPI_MINOR_VERSION >= 2) || NVENCAPI_MAJOR_VERSION > 12) if (yuv10BitFormat && pEncoderParams->encodeConfig->encodeCodecConfig.hevcConfig.inputBitDepth != NV_ENC_BIT_DEPTH_10) #else if (yuv10BitFormat && pEncoderParams->encodeConfig->encodeCodecConfig.hevcConfig.pixelBitDepthMinus8 != 2) @@ -205,7 +205,7 @@ void NvEncoder::CreateEncoder(const NV_ENC_INITIALIZE_PARAMS* pEncoderParams) } else { -#if (NVENCAPI_MAJOR_VERSION >= 12 && NVENCAPI_MINOR_VERSION >= 2) +#if ((NVENCAPI_MAJOR_VERSION == 12 && NVENCAPI_MINOR_VERSION >= 2) || NVENCAPI_MAJOR_VERSION > 12) NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, 0, { NV_ENC_CONFIG_VER } }; #else NV_ENC_PRESET_CONFIG presetConfig = { NV_ENC_PRESET_CONFIG_VER, { NV_ENC_CONFIG_VER } }; From 633c1a4d9eadb4d09c837af3219e983ae3135c4a Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Sun, 9 Feb 2025 20:08:56 +0200 Subject: [PATCH 8/8] cudacodec - VideoWriter make h265 containers compatible with quicktime which requires fourcc hvc1 --- modules/cudacodec/src/video_writer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cudacodec/src/video_writer.cpp b/modules/cudacodec/src/video_writer.cpp index 74581e21a85..9b36febda45 100644 --- a/modules/cudacodec/src/video_writer.cpp +++ b/modules/cudacodec/src/video_writer.cpp @@ -82,7 +82,7 @@ class FFmpegVideoWriter : public EncoderCallback FFmpegVideoWriter::FFmpegVideoWriter(const String& fileName, const Codec codec, const int fps, const Size sz, const int idrPeriod) { if (!videoio_registry::hasBackend(CAP_FFMPEG)) CV_Error(Error::StsNotImplemented, "FFmpeg backend not found"); - const int fourcc = codec == Codec::H264 ? cv::VideoWriter::fourcc('a', 'v', 'c', '1') : cv::VideoWriter::fourcc('h', 'e', 'v', '1'); + const int fourcc = codec == Codec::H264 ? cv::VideoWriter::fourcc('a', 'v', 'c', '1') : cv::VideoWriter::fourcc('h', 'v', 'c', '1'); writer.open(fileName, fourcc, fps, sz, { VideoWriterProperties::VIDEOWRITER_PROP_RAW_VIDEO, 1, VideoWriterProperties::VIDEOWRITER_PROP_KEY_INTERVAL, idrPeriod }); if (!writer.isOpened()) CV_Error(Error::StsUnsupportedFormat, "Unsupported video sink");