Skip to content

Commit

Permalink
fixed duplicate corners
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrPanov committed Sep 19, 2022
1 parent 5d90679 commit 59e513f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions modules/wechat_qrcode/src/wechat_qrcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
super_resolution_model_->processImageScale(cropped_img, cur_scale, use_nn_sr_);
string result;
DecoderMgr decodemgr;
vector<vector<Point2f>> zxing_points;
vector<vector<Point2f>> zxing_points, check_points;
auto ret = decodemgr.decodeImage(scaled_img, use_nn_detector_, decode_results, zxing_points);
if (ret == 0) {
for(unsigned int i=0; i<zxing_points.size(); ++i){
Expand All @@ -159,7 +159,23 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate
point.at<float>(j, 0) = points_qr[j].x;
point.at<float>(j, 1) = points_qr[j].y;
}
points.push_back(point);
bool isDuplicate = false;
for (const auto &points: check_points) {
const float eps = 10.f;
for (size_t i = 0; i < points.size(); i++) {
if (abs(points[i].x - points_qr[i].x) < eps && abs(points[i].y - points_qr[i].y) < eps){
isDuplicate = true;
}
else
isDuplicate = false;
}
}
if (isDuplicate == false) {
points.push_back(point);
check_points.push_back(points_qr);
}
else
decode_results.erase(decode_results.begin() + i, decode_results.begin() + i + 1);
}
break;
}
Expand Down

0 comments on commit 59e513f

Please sign in to comment.