-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[API Behavior Change] return four vertices of qrcode instead of axis aligned bounding box #3238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,9 +119,10 @@ vector<string> WeChatQRCode::Impl::decode(const Mat& img, vector<Mat>& candidate | |
| vector<string> decode_results; | ||
| for (auto& point : candidate_points) { | ||
| Mat cropped_img; | ||
| Align *aligner = NULL; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be simple |
||
| if (use_nn_detector_) { | ||
| Align aligner; | ||
| cropped_img = cropObj(img, point, aligner); | ||
| aligner = new Align(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid using operator new(). You should use |
||
| cropped_img = cropObj(img, point, *aligner); | ||
| } else { | ||
| cropped_img = img; | ||
| } | ||
|
|
@@ -132,9 +133,22 @@ 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; | ||
| auto ret = decodemgr.decodeImage(scaled_img, use_nn_detector_, result); | ||
|
|
||
| vector<Point2f> points_qr; | ||
| auto ret = decodemgr.decodeImage(scaled_img, use_nn_detector_, result, points_qr); | ||
| if (ret == 0) { | ||
| for (int i = 0; i < 4; i++) { | ||
| points_qr[i].x = points_qr[i].x / cur_scale; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for (auto&& pt: points_qr) {
pt /= cur_scale;
} |
||
| points_qr[i].y = points_qr[i].y / cur_scale; | ||
| } | ||
| if (use_nn_detector_) { | ||
| points_qr = aligner->warpBack(points_qr); | ||
| delete aligner; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid using operator delete(). You should use cv::Ptr or std::shared_ptr |
||
| } | ||
|
|
||
| for(int i = 0; i < 4; i++) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for (int i = 0; i < 4; ++i) {
point.at<Point2f>(i) = points_qr[static_cast<size_t>(i)];
} |
||
| point.at<float>(i, 0) = points_qr[i].x; | ||
| point.at<float>(i, 1) = points_qr[i].y; | ||
| } | ||
| decode_results.push_back(result); | ||
| points.push_back(point); | ||
| break; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corners should be order as Top Left -> Top Right -> Bottom Right -> Bottom Left
result_pointsare returned in Bottom Left -> Top Left -> Top Right -> Bottom Right