From 1ad3ad5f856aac752403bf7725e75b491aa4d975 Mon Sep 17 00:00:00 2001 From: Dhanwanth1803 <147172285+Dhanwanth1803@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:17:19 +0530 Subject: [PATCH] Merge pull request #3646 from Dhanwanth1803:latch Fixes #25081:Latch input corruption fix #3646 Fixes https://github.com/opencv/opencv/issues/25081 As mentioned by WennPaper making it `grayImage = image.clone();` will make a deep copy. It prevents the `InputArray` from being modified. - [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 - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- Co-authored-by: Dhanwanth1803 Co-authored-by: Dmitry Kurtaev --- modules/xfeatures2d/src/latch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/xfeatures2d/src/latch.cpp b/modules/xfeatures2d/src/latch.cpp index da5041fa0..49cd8f589 100644 --- a/modules/xfeatures2d/src/latch.cpp +++ b/modules/xfeatures2d/src/latch.cpp @@ -519,7 +519,7 @@ namespace cv switch (image.type()) { case CV_8UC1: - grayImage = image; + grayImage = sigma_ ? image.clone() : image; break; case CV_8UC3: cvtColor(image, grayImage, COLOR_BGR2GRAY);