@@ -35,7 +35,8 @@ class WeChatQRCode::Impl {
35
35
* @param points succussfully decoded qrcode with bounding box points.
36
36
* @return vector<string>
37
37
*/
38
- std::vector<std::string> decode (const Mat& img, std::vector<Mat>& candidate_points,
38
+ std::vector<std::string> decode (const Mat& img,
39
+ const std::vector<Mat>& candidate_points,
39
40
std::vector<Mat>& points);
40
41
int applyDetector (const Mat& img, std::vector<Mat>& points);
41
42
Mat cropObj (const Mat& img, const Mat& point, Align& aligner);
@@ -123,13 +124,14 @@ float WeChatQRCode::getScaleFactor() {
123
124
return p->scaleFactor ;
124
125
};
125
126
126
- vector<string> WeChatQRCode::Impl::decode (const Mat& img, vector<Mat>& candidate_points,
127
+ vector<string> WeChatQRCode::Impl::decode (const Mat& img,
128
+ const vector<Mat>& candidate_points,
127
129
vector<Mat>& points) {
128
130
if (candidate_points.size () == 0 ) {
129
131
return vector<string>();
130
132
}
131
133
vector<string> decode_results;
132
- for (auto & point : candidate_points) {
134
+ for (const auto & point : candidate_points) {
133
135
Mat cropped_img;
134
136
Align aligner;
135
137
if (use_nn_detector_) {
@@ -155,9 +157,11 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
155
157
156
158
if (use_nn_detector_)
157
159
points_qr = aligner.warpBack (points_qr);
160
+
161
+ auto point_to_save = Mat (4 , 2 , CV_32FC1);
158
162
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 ;
163
+ point_to_save .at <float >(j, 0 ) = points_qr[j].x ;
164
+ point_to_save .at <float >(j, 1 ) = points_qr[j].y ;
161
165
}
162
166
// try to find duplicate qr corners
163
167
bool isDuplicate = false ;
@@ -175,7 +179,7 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
175
179
}
176
180
}
177
181
if (isDuplicate == false ) {
178
- points.push_back (point );
182
+ points.push_back (point_to_save );
179
183
check_points.push_back (points_qr);
180
184
}
181
185
else {
@@ -244,4 +248,4 @@ vector<float> WeChatQRCode::Impl::getScaleList(const int width, const int height
244
248
return {0.5 , 1.0 };
245
249
}
246
250
} // namespace wechat_qrcode
247
- } // namespace cv
251
+ } // namespace cv
0 commit comments