From: Alexander Smorkalov Date: Thu, 22 Dec 2022 14:29:22 +0000 (+0300) Subject: Valgrind issues fix in QRCode detector. X-Git-Tag: accepted/tizen/unified/20230127.161057~1^2~20^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a32100d9ba57b05c28d91aa0e39f045633937704;p=platform%2Fupstream%2Fopencv.git Valgrind issues fix in QRCode detector. --- diff --git a/modules/objdetect/src/qrcode.cpp b/modules/objdetect/src/qrcode.cpp index a62b90b..41c604a 100644 --- a/modules/objdetect/src/qrcode.cpp +++ b/modules/objdetect/src/qrcode.cpp @@ -2340,9 +2340,8 @@ static inline std::pair matchPatternPoints(const vector &finder double QRDecode::getNumModules() { vector> finderPatterns; double numModulesX = 0., numModulesY = 0.; - bool flag = findPatternsVerticesPoints(finderPatterns); - if (flag) { - double pattern_distance[4]; + if (findPatternsVerticesPoints(finderPatterns)) { + double pattern_distance[4] = {0.,0.,0.,0.}; for (auto& pattern : finderPatterns) { auto indexes = matchPatternPoints(pattern, original_points); if (indexes == std::make_pair(-1, -1)) @@ -2558,8 +2557,9 @@ bool QRDecode::versionDefinition() bool useFinderPattern = false; const double thresholdFinderPattern = 0.2; const double roundingError = abs(numModulesByFinderPattern - cvRound(numModulesByFinderPattern)); - if (cvRound(versionByFinderPattern) >= 1 && versionByFinderPattern <= 6 && transition_x != transition_y) { - if (roundingError < thresholdFinderPattern) + + if (cvRound(versionByFinderPattern) >= 1 && versionByFinderPattern <= 6. && + transition_x != transition_y && roundingError < thresholdFinderPattern) { useFinderPattern = true; } @@ -2775,7 +2775,12 @@ bool QRDecode::curvedDecodingProcess() #endif } -QRDecode::QRDecode(bool _useAlignmentMarkers): useAlignmentMarkers(_useAlignmentMarkers) {} +QRDecode::QRDecode(bool _useAlignmentMarkers): + useAlignmentMarkers(_useAlignmentMarkers), + version(0), + version_size(0), + test_perspective_size(0.f) + {} std::string QRCodeDetector::decode(InputArray in, InputArray points, OutputArray straight_qrcode)