From 8facf61bed81570ed0c93302a06dba5adc9c36fd Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 28 Jan 2020 15:20:37 +0300 Subject: [PATCH] objdetect(QR): don't introduce deprecated API, compatibility code --- .../objdetect/include/opencv2/objdetect.hpp | 60 ++++++++++++------- modules/objdetect/src/qrcode.cpp | 20 ------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp index 5bd6a11002..ea7b1ac801 100644 --- a/modules/objdetect/include/opencv2/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect.hpp @@ -743,6 +743,43 @@ public: OutputArrayOfArrays straight_qrcode = noArray() ) const; + +#ifndef CV_DOXYGEN // COMPATIBILITY + inline bool decodeMulti( + InputArray img, InputArray points, + CV_OUT std::vector& decoded_info, + OutputArrayOfArrays straight_qrcode = noArray() + ) const + { + std::vector decoded_info_; + bool res = decodeMulti(img, points, decoded_info_, straight_qrcode); + decoded_info.resize(decoded_info_.size()); + for (size_t i = 0; i < decoded_info.size(); ++i) + { + cv::String s; std::swap(s, decoded_info_[i]); + decoded_info[i] = s; + } + return res; + } + + inline bool detectAndDecodeMulti( + InputArray img, CV_OUT std::vector& decoded_info, + OutputArray points = noArray(), + OutputArrayOfArrays straight_qrcode = noArray() + ) const + { + std::vector decoded_info_; + bool res = detectAndDecodeMulti(img, decoded_info_, points, straight_qrcode); + decoded_info.resize(decoded_info_.size()); + for (size_t i = 0; i < decoded_info.size(); ++i) + { + cv::String s; std::swap(s, decoded_info_[i]); + decoded_info[i] = s; + } + return res; + } +#endif + protected: struct Impl; Ptr p; @@ -764,29 +801,6 @@ CV_EXPORTS bool detectQRCode(InputArray in, std::vector &points, double e */ CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &decoded_info, OutputArray straight_qrcode = noArray()); -/** @brief Detect QR codes in image and return vector of minimum area of quadrangle that describes QR codes. - @param in Matrix of the type CV_8UC1 containing an image where QR codes are detected. - @param points Output vector of vertices of quadrangles of minimal area that describes QR codes. - @param eps_x Epsilon neighborhood, which allows you to determine the horizontal pattern of the scheme 1:1:3:1:1 according to QR code standard. - @param eps_y Epsilon neighborhood, which allows you to determine the vertical pattern of the scheme 1:1:3:1:1 according to QR code standard. - */ -CV_EXPORTS -bool detectQRCodeMulti( - InputArray in, std::vector &points, - double eps_x = 0.2, double eps_y = 0.1); - -/** @brief Decode QR codes in image and return text that is encrypted in QR code. - @param in Matrix of the type CV_8UC1 containing an image where QR code are detected. - @param points Input vector of vertices of quadrangles of minimal area that describes QR codes. - @param decoded_info vector of String information that is encrypted in QR codes. - @param straight_qrcode vector of Matrixes of the type CV_8UC1 containing an binary straight QR codes. - */ -CV_EXPORTS -bool decodeQRCodeMulti( - InputArray in, InputArray points, - CV_OUT std::vector &decoded_info, - OutputArrayOfArrays straight_qrcode = noArray()); - //! @} objdetect } diff --git a/modules/objdetect/src/qrcode.cpp b/modules/objdetect/src/qrcode.cpp index 3467803a25..6ceb6d4ee4 100644 --- a/modules/objdetect/src/qrcode.cpp +++ b/modules/objdetect/src/qrcode.cpp @@ -2234,14 +2234,6 @@ bool QRCodeDetector::detectMulti(InputArray in, OutputArray points) const return true; } -bool detectQRCodeMulti(InputArray in, vector< Point > &points, double eps_x, double eps_y) -{ - QRCodeDetector qrdetector; - qrdetector.setEpsX(eps_x); - qrdetector.setEpsY(eps_y); - return qrdetector.detectMulti(in, points); -} - class ParallelDecodeProcess : public ParallelLoopBody { public: @@ -2385,16 +2377,4 @@ bool QRCodeDetector::detectAndDecodeMulti( return ok; } -bool decodeQRCodeMulti( - InputArray in, InputArray points, - vector &decoded_info, OutputArrayOfArrays straight_qrcode) -{ - QRCodeDetector qrcode; - vector info; - bool ok = qrcode.decodeMulti(in, points, info, straight_qrcode); - for (size_t i = 0; i < info.size(); i++) - decoded_info.push_back(info[i]); - return ok; -} - } // namespace -- GitLab