@@ -144,10 +144,10 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
144
144
super_resolution_model_->processImageScale (cropped_img, cur_scale, use_nn_sr_);
145
145
string result;
146
146
DecoderMgr decodemgr;
147
- vector<vector<Point2f>> zxing_points;
147
+ vector<vector<Point2f>> zxing_points, check_points ;
148
148
auto ret = decodemgr.decodeImage (scaled_img, use_nn_detector_, decode_results, zxing_points);
149
149
if (ret == 0 ) {
150
- for (unsigned int i= 0 ; i<zxing_points.size (); ++i ){
150
+ for (size_t i = 0 ; i <zxing_points.size (); i++ ){
151
151
vector<Point2f> points_qr = zxing_points[i];
152
152
for (auto && pt: points_qr) {
153
153
pt /= cur_scale;
@@ -159,7 +159,28 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
159
159
point.at <float >(j, 0 ) = points_qr[j].x ;
160
160
point.at <float >(j, 1 ) = points_qr[j].y ;
161
161
}
162
- points.push_back (point);
162
+ // try to find duplicate qr corners
163
+ bool isDuplicate = false ;
164
+ for (const auto &tmp_points: check_points) {
165
+ const float eps = 10 .f ;
166
+ for (size_t j = 0 ; j < tmp_points.size (); j++) {
167
+ if (abs (tmp_points[j].x - points_qr[j].x ) < eps &&
168
+ abs (tmp_points[j].y - points_qr[j].y ) < eps) {
169
+ isDuplicate = true ;
170
+ }
171
+ else {
172
+ isDuplicate = false ;
173
+ break ;
174
+ }
175
+ }
176
+ }
177
+ if (isDuplicate == false ) {
178
+ points.push_back (point);
179
+ check_points.push_back (points_qr);
180
+ }
181
+ else {
182
+ decode_results.erase (decode_results.begin () + i, decode_results.begin () + i + 1 );
183
+ }
163
184
}
164
185
break ;
165
186
}
0 commit comments