Skip to content

Commit

Permalink
Fix data corruption in WeChatQRCode::impl::decode
Browse files Browse the repository at this point in the history
(it may lead to incorrect results if multiple QR found at image)
  • Loading branch information
ylatkin committed Mar 20, 2024
1 parent b42682b commit 35f0b6e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/wechat_qrcode/src/wechat_qrcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate

if (use_nn_detector_)
points_qr = aligner.warpBack(points_qr);

auto point_to_save = Mat(4, 2, CV_32FC1);
for (int j = 0; j < 4; ++j) {
point.at<float>(j, 0) = points_qr[j].x;
point.at<float>(j, 1) = points_qr[j].y;
point_to_save.at<float>(j, 0) = points_qr[j].x;
point_to_save.at<float>(j, 1) = points_qr[j].y;
}
// try to find duplicate qr corners
bool isDuplicate = false;
Expand All @@ -175,7 +177,7 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
}
}
if (isDuplicate == false) {
points.push_back(point);
points.push_back(point_to_save);
check_points.push_back(points_qr);
}
else {
Expand Down Expand Up @@ -244,4 +246,4 @@ vector<float> WeChatQRCode::Impl::getScaleList(const int width, const int height
return {0.5, 1.0};
}
} // namespace wechat_qrcode
} // namespace cv
} // namespace cv

0 comments on commit 35f0b6e

Please sign in to comment.