-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
WeChat QRCode module open source. #2821
Conversation
Hi @alalek, sorry for bothering you again. Now, the code successfully supports different platforms. However, there are two issues that we meet:
logs:
|
This repository should store source code only. Models and other data blobs should be stored externally. There are several options:
Take a look There is
In general binding generator should handle nested namespaces (target name may look like Just renaming to |
Hi, @alalek . I have added BTW, there are still some issues:
|
Thank you for update!
Please prepare 2 commits in this PR:
(no need to re-create PR, use
Need to squash commits into one (all binaries are still in git history)
This is the right path.
Agreed, we need to take a look on this.
Submodules are not supported yet in Python bindings. However it makes sense (but we need to preserve existed Python API too to avoid breaking of Users code). @vpisarev Any suggestions about bindings? |
@dddzg, @alalek, in my opinion, the patch looks great. I suggest to merge it in and adjust Python bindings/fix ObjC bindings etc. later if needed. It's usable, it works really well and that's enough for now. @dddzg, may I ask you to do 2 more things:
after it the pull request will contain just 1 commit and the doc builder warning will gone, since the patch will not include model files anymore. |
Sorry for the delay. |
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.
I have updated the opencv_3rdparty with 2 commits
Update looks good. Thank you!
@alalek, all the tests pass now; in my opinion, PR is ready to be merged 👍 |
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.
Great contribution!
* maxepoches max iteration epochs | ||
* minchanged min central change times | ||
*/ | ||
vector<Cluster> k_means(vector<vector<double> > trainX, uint k, uint maxepoches, uint minchanged) { |
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.
Future TODO: try to reuse cv::kmeans()
* Ends up being a bit faster than {@link Math#round(float)}. This merely | ||
* rounds its argument to the nearest int, where x.5 rounds up to x+1. | ||
*/ | ||
static inline int round(double value) { |
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.
Future TODO: cvRound()
auto res_points = vector<Mat>(); | ||
auto ret = p->decode(input_img, candidate_points, res_points); |
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.
Are points fixed size? 4 points per instance?
if so, then it make sense to return 2D Mat instead of vector:
- rows are instances
- cols(=4) are corners points of
CV_32FC2
elements (C2 means 2 channels for x/y components)
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.
Yes, 4 points per instance, but the row size of points is not fixed. Because our detector supports detecting multiple QRcode in an image. Moreover, not all detected QRCode can be decoded. So, there are candidate_points
detected by the detector. Then we try to decode them one by one. For the successfully decoded qrcode, we will append their points to the res_points
.
So, I prefer to use the vector
, which is more convenient to append. Could we keep it?
I am not very familiar with OpenCV 2D Mat, is it convenient to append new rows?
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.
multiple QRcode in an image
So, what is represented by each vector element? 4 points corners?
This question is about external API representation (points
output argument). Internal implementation can be any (we don't worry about that).
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.
@alalek, I suggest to merge the current PR as-is.
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.
@vpisarev Please make careful reviews. For example, .fixedType()
check below doesn't make any sense. Are you going to fix that?
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.
@alalek Yes, each Mat in vector
represents 4 points corners, it can also be represented as Mat(4, 2, CV_32FC1)
. And the format is the same with OpenCV QRcodeDetector
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.
Hi @alalek , the code fixedType()
comes from https://github.com/opencv/opencv/blob/7a790d0d353bcbe48f1d62fb917c787ab4185846/modules/objdetect/src/qrcode.cpp#L49 (the opencv qrcode module) Because I try to convert vector<Mat>
to OutputArrayOfArrays
. Do you have any good ideas?
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.
@dddzg
Hello, are there any steps for use and deployment? I want to try to use it in Golang, but I can't run the project of wechat_qrcode. Cmake is always running unsuccessfully, and I meet all kinds of errors, which makes me very upset!
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.
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.
Could you list the errors with more details?
@vpisarev Do you want to merge opencv_3rdparty? Why do you violate existed rules? ("fixup" commits should not go to upstream repository) |
// opencv type convert | ||
vector<Mat> tmp_points; | ||
if (points.needed()) { | ||
for (size_t i = 0; i < res_points.size(); i++) { | ||
Mat tmp_point; | ||
tmp_points.push_back(tmp_point); | ||
res_points[i].convertTo(((OutputArray)tmp_points[i]), | ||
((OutputArray)tmp_points[i]).fixedType() | ||
? ((OutputArray)tmp_points[i]).type() | ||
: CV_32FC2); |
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.
.fixedType()
is used with external arguments only (mentioned file from objdetect
follows this rule).
No sense to use it with "local" variables.
good ideas
Reuse conventions from external API of objdetect/QRCodeDetector
This code is expected here.
Update: file from objdetect is valid partially
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.
OK. I will remove it.
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.
@alalek Could we reopen this PR or open a new PR?
Merge with 3rdparty: opencv/opencv_3rdparty#59
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
There is an open-source version of the WeChat QR code detector.
Check #2809 for more information.