@@ -35,7 +35,8 @@ class WeChatQRCode::Impl {
3535 * @param points succussfully decoded qrcode with bounding box points.
3636 * @return vector<string>
3737 */
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,
3940 std::vector<Mat>& points);
4041 int applyDetector (const Mat& img, std::vector<Mat>& points);
4142 Mat cropObj (const Mat& img, const Mat& point, Align& aligner);
@@ -123,13 +124,14 @@ float WeChatQRCode::getScaleFactor() {
123124 return p->scaleFactor ;
124125};
125126
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,
127129 vector<Mat>& points) {
128130 if (candidate_points.size () == 0 ) {
129131 return vector<string>();
130132 }
131133 vector<string> decode_results;
132- for (auto & point : candidate_points) {
134+ for (const auto & point : candidate_points) {
133135 Mat cropped_img;
134136 Align aligner;
135137 if (use_nn_detector_) {
@@ -155,9 +157,11 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
155157
156158 if (use_nn_detector_)
157159 points_qr = aligner.warpBack (points_qr);
160+
161+ auto point_to_save = Mat (4 , 2 , CV_32FC1);
158162 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 ;
161165 }
162166 // try to find duplicate qr corners
163167 bool isDuplicate = false ;
@@ -175,7 +179,7 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
175179 }
176180 }
177181 if (isDuplicate == false ) {
178- points.push_back (point );
182+ points.push_back (point_to_save );
179183 check_points.push_back (points_qr);
180184 }
181185 else {
@@ -244,4 +248,4 @@ vector<float> WeChatQRCode::Impl::getScaleList(const int width, const int height
244248 return {0.5 , 1.0 };
245249}
246250} // namespace wechat_qrcode
247- } // namespace cv
251+ } // namespace cv
0 commit comments