|
|
|
@ -144,10 +144,10 @@ 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){ |
|
|
|
|
for(size_t i = 0; i <zxing_points.size(); i++){ |
|
|
|
|
vector<Point2f> points_qr = zxing_points[i]; |
|
|
|
|
for (auto&& pt: points_qr) { |
|
|
|
|
pt /= cur_scale; |
|
|
|
@ -159,7 +159,28 @@ 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); |
|
|
|
|
// try to find duplicate qr corners
|
|
|
|
|
bool isDuplicate = false; |
|
|
|
|
for (const auto &tmp_points: check_points) { |
|
|
|
|
const float eps = 10.f; |
|
|
|
|
for (size_t j = 0; j < tmp_points.size(); j++) { |
|
|
|
|
if (abs(tmp_points[j].x - points_qr[j].x) < eps && |
|
|
|
|
abs(tmp_points[j].y - points_qr[j].y) < eps) { |
|
|
|
|
isDuplicate = true; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
isDuplicate = false; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|