Skip to content

Commit 35f0b6e

Browse files
committed
Fix data corruption in WeChatQRCode::impl::decode
(it may lead to incorrect results if multiple QR found at image)
1 parent b42682b commit 35f0b6e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

modules/wechat_qrcode/src/wechat_qrcode.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
155155

156156
if (use_nn_detector_)
157157
points_qr = aligner.warpBack(points_qr);
158+
159+
auto point_to_save = Mat(4, 2, CV_32FC1);
158160
for (int j = 0; j < 4; ++j) {
159-
point.at<float>(j, 0) = points_qr[j].x;
160-
point.at<float>(j, 1) = points_qr[j].y;
161+
point_to_save.at<float>(j, 0) = points_qr[j].x;
162+
point_to_save.at<float>(j, 1) = points_qr[j].y;
161163
}
162164
// try to find duplicate qr corners
163165
bool isDuplicate = false;
@@ -175,7 +177,7 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
175177
}
176178
}
177179
if (isDuplicate == false) {
178-
points.push_back(point);
180+
points.push_back(point_to_save);
179181
check_points.push_back(points_qr);
180182
}
181183
else {
@@ -244,4 +246,4 @@ vector<float> WeChatQRCode::Impl::getScaleList(const int width, const int height
244246
return {0.5, 1.0};
245247
}
246248
} // namespace wechat_qrcode
247-
} // namespace cv
249+
} // namespace cv

0 commit comments

Comments
 (0)