-
Notifications
You must be signed in to change notification settings - Fork 539
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
fix refine_edges() and the coordinates recovery when quad_decimate > … #346
fix refine_edges() and the coordinates recovery when quad_decimate > … #346
Conversation
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 only left style comments so far as I need a while to better understand the changes. Can you add more details about the issue and how it is fixed in the commit message?
Can you add a qualitative and quantitative comparison of the estimation results before and after your PR? |
Of course, let me make it clear. I tested with this image from #334 . With the current master branch, the estimated coordinates of that corner under different settings are: As we can see,
With the modified code (this PR), the estimated coordinates under different settings are all close to the groundtruth (10,10): |
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.
Can you squash your commits together again?
Thanks to this, I found that I broke the tests with #327 when I tried to make them less flaky. The test compares the pixel coordinates and should trigger an error if the absolute error is larger than 0.1 pixels: apriltag/test/test_detection.c Lines 47 to 54 in 3806edf
Setting: td->quad_decimate = 2;
td->refine_edges = false; in the tests should therefore have triggered this when running I fixed the test on Ubuntu in #348. But on other OSes, the results are slightly different and therefore have a small discrepancy to the reference values:
and I am wondering if this may be caused by rounding effects and fixed by this PR. |
I changed the tests to not decimate quads or refine edges: td->quad_decimate = 1;
td->refine_edges = false; and now get identical (accurate up to 0.001 pixels) results across OSes, which suggests that decimation and refinement are causing unreliable detections. While td->quad_decimate = 2;
td->refine_edges = true; after applying your first commit. Can you show with debug results from the test images, that this PR should produce the same quads, just better refined? |
I'm not entirely sure what you mean by "debug results from the test images". I have simply enabled Update: (test image: apriltag/test/data/34139872896_defdb2f8d9_c.jpg) More results: It can be observed that master and this pr produce slightly different coordinates for the tag corners. However it's hard to tell which version is better than the other according to these results only, because the ground truths for real world images are unknown. Anyway, theoretically speaking, using continuous coordinates (with interpolation) to retrieve pixel values, as done in this pr, can generate more accurate edge points, and the test with the ideal input image (from #334 ) , where ground truth is available, does show that this pr can produce nearly perfect estimation for the corners' coordinates. |
I'll squash the two commits into one after you confirm whether we should merge the if/else blocks mentioned above. |
Thanks for the comparison. The results are indeed very close.
I selected real images since some processing steps, such as the edge refinement, will have more noticeable effects on noisy real images than clean synthetic images.
I originally added the test images to see if a PR would change the estimated quads. For a performance evaluation of which method is better, we would need to manually label these images and extract ground truth corner coordinates. Alternatively, we could render synthetic images for the ground truth coordinates and add blur, noise and other effects to see how a change affects the performance. |
7f64834
to
4bf66cd
Compare
@christian-rauch Hi, I have squashed the previous commits. Please let me know if any further modifications are needed. |
I recently fixed the tests to work across OSes with no decimation. Can you rebase your PR to make sure that it does not break the tests without decimation? Then, we probably need a test for the results with decimation to make sure that results with decimation are close to the ones without decimation and that the output does not change in future. |
Hi christian-rauch,
Yes, it's better to split the commit into two. I think we should update the doc file
Or maybe you have better suggestions? |
4bf66cd
to
a62f434
Compare
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.
Thank you for splitting this. I think the purpose of the diffs are much easier to understand.
Regarding the commits message: I think the title is far too long and the message body also should have line breaks. If you look at an individual commit, e.g. 5666602, then ideally the title fits into the first line without line breaks.
Have a look at https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/ for suggestions on how to format a good commit message regarding style and content.
A fix in refine_edges(): Use continuous coordinates and bilinear interpolation (instead of discrete coordinates) to fetch grayscale values from the input image. Using discrete coordinates and pixel values, as done in the previous versions before this commit, might incur errors caused by rounding effects, resulting in instability. While in this commit, the bilinear interpolation is employed, which doesn't change the *average output* of refine_edges(), but just makes the output more smooth and stable.
The convention that (0,0) be the left top corner of the first pixel is adopted in this commit. In the previous versions, the coordinate convention used for `quad_decimate = 1, refine_edges = false` is already `left-top-corner = (0,0)`; while for `quad_decimate > 1` or `refine_edges = true`, the convention is vague since it seems mixed conventions are used and some code even be wrong (see AprilRobotics#345). This fix ensures the same convention be used no matter what values for `quad_decimate` and `refine_edges`.
a62f434
to
cb522ae
Compare
Modified as you suggested, please see the new commits. |
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.
Thanks. I am fine with these changes now. But I still would like @mkrogius to have a look at this and give the green light.
Hi, I noticed that this PR is still not merged. I might need to introduce some unrelated features to this branch in the coming weeks. If possible, could you please review the changes and consider merging them if you find them beneficial? |
As said, I am fine with these changes now. I would still like @mkrogius to have a look at this. @NewThinker-Jeffrey What is your deadline on this? You can create a new branch from this and start working there. You do not have to (and you shouldn't) push new changes to this PR. |
I understand that and won't push my new changes to this branch before the PR finished. |
I am going to merge this now to not delay this further and potentially causing merge conflicts later. |
fix refine_edges() and the coordinates recovery when quad_decimate > 1 (fixes #334, fixes #345)