From 1bced43e96de94077ac51017f8628c6af1a0ce72 Mon Sep 17 00:00:00 2001 From: berak Date: Wed, 5 May 2021 10:34:42 +0200 Subject: [PATCH 1/7] samples/dnn: better errormsg in openpose.py --- samples/dnn/openpose.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/dnn/openpose.py b/samples/dnn/openpose.py index b79ccd54b8..191d23edd4 100644 --- a/samples/dnn/openpose.py +++ b/samples/dnn/openpose.py @@ -41,8 +41,7 @@ elif args.dataset == 'MPI': ["RElbow", "RWrist"], ["Neck", "LShoulder"], ["LShoulder", "LElbow"], ["LElbow", "LWrist"], ["Neck", "Chest"], ["Chest", "RHip"], ["RHip", "RKnee"], ["RKnee", "RAnkle"], ["Chest", "LHip"], ["LHip", "LKnee"], ["LKnee", "LAnkle"] ] -else: - assert(args.dataset == 'HAND') +elif args.dataset == 'HAND': BODY_PARTS = { "Wrist": 0, "ThumbMetacarpal": 1, "ThumbProximal": 2, "ThumbMiddle": 3, "ThumbDistal": 4, "IndexFingerMetacarpal": 5, "IndexFingerProximal": 6, "IndexFingerMiddle": 7, "IndexFingerDistal": 8, @@ -61,7 +60,8 @@ else: ["RingFingerProximal", "RingFingerMiddle"], ["RingFingerMiddle", "RingFingerDistal"], ["Wrist", "LittleFingerMetacarpal"], ["LittleFingerMetacarpal", "LittleFingerProximal"], ["LittleFingerProximal", "LittleFingerMiddle"], ["LittleFingerMiddle", "LittleFingerDistal"] ] - +else: + raise(Exception("you need to specify either 'COCO', 'MPI', or 'Hand' in args.dataset")) inWidth = args.width inHeight = args.height From 158b13e0ba5c3e152129021b16fb797b5742a79b Mon Sep 17 00:00:00 2001 From: Jake Staahl Date: Fri, 7 May 2021 12:48:01 -0700 Subject: [PATCH 2/7] Remove static initializers caused by templated static member. --- modules/flann/include/opencv2/flann/any.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/flann/include/opencv2/flann/any.h b/modules/flann/include/opencv2/flann/any.h index f5684e9962..4906fec081 100644 --- a/modules/flann/include/opencv2/flann/any.h +++ b/modules/flann/include/opencv2/flann/any.h @@ -167,17 +167,15 @@ class SinglePolicy public: static base_any_policy* get_policy(); - -private: - static typename choose_policy::type policy; }; -template -typename choose_policy::type SinglePolicy::policy; - /// This function will return a different policy for each type. template -inline base_any_policy* SinglePolicy::get_policy() { return &policy; } +inline base_any_policy* SinglePolicy::get_policy() +{ + static typename choose_policy::type policy; + return &policy; +} } // namespace anyimpl From 302c2354a3b570444c2b3dfe10005c9d6086baa4 Mon Sep 17 00:00:00 2001 From: berak Date: Sun, 9 May 2021 14:01:54 +0200 Subject: [PATCH 3/7] core: add missing implementation for Mat::ptr(Vec) --- modules/core/include/opencv2/core/mat.inl.hpp | 27 +++++++++++++++++++ modules/core/test/test_mat.cpp | 16 +++++++++++ 2 files changed, 43 insertions(+) diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 49357555de..fffb860f18 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -898,6 +898,33 @@ const _Tp* Mat::ptr(const int* idx) const return (const _Tp*)p; } +template inline +uchar* Mat::ptr(const Vec& idx) +{ + return Mat::ptr(idx.val); +} + +template inline +const uchar* Mat::ptr(const Vec& idx) const +{ + return Mat::ptr(idx.val); +} + +template inline +_Tp* Mat::ptr(const Vec& idx) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return Mat::ptr<_Tp>(idx.val); +} + +template inline +const _Tp* Mat::ptr(const Vec& idx) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return Mat::ptr<_Tp>(idx.val); +} + + template inline _Tp& Mat::at(int i0, int i1) { diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 2afd926bd1..4f7cbb6725 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -2365,4 +2365,20 @@ TEST(Mat, regression_18473) } +TEST(Mat, ptrVecni_20044) +{ + Mat_ m(3,4); m << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12; + Vec2i idx(1,1); + + uchar *u = m.ptr(idx); + EXPECT_EQ(int(6), *(int*)(u)); + const uchar *cu = m.ptr(idx); + EXPECT_EQ(int(6), *(int*)(cu)); + + int *i = m.ptr(idx); + EXPECT_EQ(int(6), *(i)); + const int *ci = m.ptr(idx); + EXPECT_EQ(int(6), *(ci)); +} + }} // namespace From 1d7d18afba3de93482513c22fd271d63c01bfaff Mon Sep 17 00:00:00 2001 From: Smirnov Egor Date: Wed, 12 May 2021 13:18:58 +0300 Subject: [PATCH 4/7] Document imwrite depth fallback --- modules/imgcodecs/include/opencv2/imgcodecs.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/imgcodecs/include/opencv2/imgcodecs.hpp b/modules/imgcodecs/include/opencv2/imgcodecs.hpp index 7f6b24f0ff..41fcc79674 100644 --- a/modules/imgcodecs/include/opencv2/imgcodecs.hpp +++ b/modules/imgcodecs/include/opencv2/imgcodecs.hpp @@ -212,6 +212,8 @@ can be saved using this function, with these exceptions: should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below). - Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below). +If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way. + If the format, depth or channel order is different, use Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O functions to save the image to XML or YAML format. From 901ed5545fae022811e9c5e443876248292e0852 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 14 May 2021 17:39:40 +0000 Subject: [PATCH 5/7] cmake: fix handling of CMAKE_MODULE_LINKER_FLAGS --- cmake/OpenCVCompilerOptions.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 3cb10a1878..0a10bfffcf 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -225,9 +225,11 @@ if(CV_GCC OR CV_CLANG) if(APPLE) set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} -Wl,-dead_strip") set(OPENCV_EXTRA_SHARED_LINKER_FLAGS "${OPENCV_EXTRA_SHARED_LINKER_FLAGS} -Wl,-dead_strip") + set(OPENCV_EXTRA_MODULE_LINKER_FLAGS "${OPENCV_EXTRA_MODULE_LINKER_FLAGS} -Wl,-dead_strip") else() set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} -Wl,--gc-sections") set(OPENCV_EXTRA_SHARED_LINKER_FLAGS "${OPENCV_EXTRA_SHARED_LINKER_FLAGS} -Wl,--gc-sections") + set(OPENCV_EXTRA_MODULE_LINKER_FLAGS "${OPENCV_EXTRA_MODULE_LINKER_FLAGS} -Wl,--gc-sections") endif() endif() endif() @@ -279,6 +281,7 @@ if(MSVC) set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi") set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE} /debug") set(OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE} /debug") + set(OPENCV_EXTRA_MODULE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_MODULE_LINKER_FLAGS_RELEASE} /debug") endif() # Remove unreferenced functions: function level linking @@ -346,6 +349,7 @@ if(NOT OPENCV_SKIP_LINK_AS_NEEDED) if(HAVE_LINK_AS_NEEDED) set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} ${_option}") set(OPENCV_EXTRA_SHARED_LINKER_FLAGS "${OPENCV_EXTRA_SHARED_LINKER_FLAGS} ${_option}") + set(OPENCV_EXTRA_MODULE_LINKER_FLAGS "${OPENCV_EXTRA_MODULE_LINKER_FLAGS} ${_option}") endif() endif() endif() @@ -364,6 +368,9 @@ if(NOT OPENCV_SKIP_EXTRA_COMPILER_FLAGS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OPENCV_EXTRA_SHARED_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_SHARED_LINKER_FLAGS_DEBUG}") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OPENCV_EXTRA_MODULE_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_MODULE_LINKER_FLAGS_RELEASE}") + set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_MODULE_LINKER_FLAGS_DEBUG}") endif() if(MSVC) From 101d50703cf75f41349366c1302d6d81d42c6ba5 Mon Sep 17 00:00:00 2001 From: changh95 Date: Sat, 15 May 2021 00:22:50 +0900 Subject: [PATCH 6/7] fix typo 'undistorsed'->'undistorted' --- .../camera_calibration/camera_calibration.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp index 38961ec63e..5870e456fb 100644 --- a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp +++ b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp @@ -45,7 +45,7 @@ public: << "Write_extrinsicParameters" << writeExtrinsics << "Write_outputFileName" << outputFileName - << "Show_UndistortedImage" << showUndistorsed + << "Show_UndistortedImage" << showUndistorted << "Input_FlipAroundHorizontalAxis" << flipVertical << "Input_Delay" << delay @@ -67,7 +67,7 @@ public: node["Calibrate_FixPrincipalPointAtTheCenter"] >> calibFixPrincipalPoint; node["Calibrate_UseFisheyeModel"] >> useFisheye; node["Input_FlipAroundHorizontalAxis"] >> flipVertical; - node["Show_UndistortedImage"] >> showUndistorsed; + node["Show_UndistortedImage"] >> showUndistorted; node["Input"] >> input; node["Input_Delay"] >> delay; node["Fix_K1"] >> fixK1; @@ -214,7 +214,7 @@ public: bool calibFixPrincipalPoint; // Fix the principal point at the center bool flipVertical; // Flip the captured images around the horizontal axis string outputFileName; // The name of the file where to write - bool showUndistorsed; // Show undistorted images after calibration + bool showUndistorted; // Show undistorted images after calibration string input; // The input -> bool useFisheye; // use fisheye camera model for calibration bool fixK1; // fix K1 distortion coefficient @@ -374,8 +374,8 @@ int main(int argc, char* argv[]) if( mode == CAPTURING ) { - if(s.showUndistorsed) - msg = format( "%d/%d Undist", (int)imagePoints.size(), s.nrFrames ); + if(s.showUndistorted) + msg = cv::format( "%d/%d Undist", (int)imagePoints.size(), s.nrFrames ); else msg = format( "%d/%d", (int)imagePoints.size(), s.nrFrames ); } @@ -387,7 +387,7 @@ int main(int argc, char* argv[]) //! [output_text] //------------------------- Video capture output undistorted ------------------------------ //! [output_undistorted] - if( mode == CALIBRATED && s.showUndistorsed ) + if( mode == CALIBRATED && s.showUndistorted ) { Mat temp = view.clone(); if (s.useFisheye) @@ -410,7 +410,7 @@ int main(int argc, char* argv[]) break; if( key == 'u' && mode == CALIBRATED ) - s.showUndistorsed = !s.showUndistorsed; + s.showUndistorted = !s.showUndistorted; if( s.inputCapture.isOpened() && key == 'g' ) { @@ -422,7 +422,7 @@ int main(int argc, char* argv[]) // -----------------------Show the undistorted image for the image list ------------------------ //! [show_results] - if( s.inputType == Settings::IMAGE_LIST && s.showUndistorsed && !cameraMatrix.empty()) + if( s.inputType == Settings::IMAGE_LIST && s.showUndistorted && !cameraMatrix.empty()) { Mat view, rview, map1, map2; From e53a4ce64d4aca2ca1073d5a2e54a9ddab574d46 Mon Sep 17 00:00:00 2001 From: Giles Payne Date: Sun, 16 May 2021 20:52:36 +0900 Subject: [PATCH 7/7] Fix for failing QRCodeDetectorTest.testDetectAndDecodeMulti test --- .../objdetect/misc/java/test/QRCodeDetectorTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/objdetect/misc/java/test/QRCodeDetectorTest.java b/modules/objdetect/misc/java/test/QRCodeDetectorTest.java index cd8be409aa..369e7b8cc3 100644 --- a/modules/objdetect/misc/java/test/QRCodeDetectorTest.java +++ b/modules/objdetect/misc/java/test/QRCodeDetectorTest.java @@ -5,7 +5,10 @@ import org.opencv.core.Mat; import org.opencv.objdetect.QRCodeDetector; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.test.OpenCVTestCase; +import java.util.Arrays; import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; public class QRCodeDetectorTest extends OpenCVTestCase { @@ -39,11 +42,7 @@ public class QRCodeDetectorTest extends OpenCVTestCase { boolean result = detector.detectAndDecodeMulti(img, output); assertTrue(result); assertEquals(output.size(), 6); - assertEquals(output.get(0), "SKIP"); - assertEquals(output.get(1), "EXTRA"); - assertEquals(output.get(2), "TWO STEPS FORWARD"); - assertEquals(output.get(3), "STEP BACK"); - assertEquals(output.get(4), "QUESTION"); - assertEquals(output.get(5), "STEP FORWARD"); + List < String > expectedResults = Arrays.asList("SKIP", "EXTRA", "TWO STEPS FORWARD", "STEP BACK", "QUESTION", "STEP FORWARD"); + assertEquals(new HashSet(output), new HashSet(expectedResults)); } }