Sean,
I guess I wasn't clear, I'm referring to cases where the camera is not
parallel to the surface, so perspective distortion occurs. This cannot
be fixed just by rotating the image.
The current test data doesn't contain many cases like these, so it
doesn't really affect the unit tests. With the 40% tolerance it solves
112 instead of 113 with global thresholding, and 117 instead of 115
with local thresholding (a modified version).
However, I have a lot of test data where it makes a big difference. I
attached two examples.
The increased tolerance is enough for any QR code with an alignment
pattern. However, it alone doesn't help for QR version 1 codes. For my
application we mostly use version 1 codes, and it is important to be
able to scan it from an angle. I do realize that for other
applications this might be a small and unimportant case. The first
patch I sent is not strictly required, but it avoids code duplication
when using my detector, as it allows me to extend the class. I don't
currently have the code with me, but this is basically what the code
does:
- Uses the current detector to locate the finder and alignment patterns.
- If an alignment pattern is found, it acts just like the current
detector, and does nothing else.
- If the 3 finder patterns are found, but no alignment pattern:
- The sides of the finder patterns are used to find approximate
bottom and right edges.
- Using these approximations, a more accurate search is performed
for the real edges.
- The intersection of these edges are used as the bottom-right corner.
More details are in the code comments.
The performance of the code is reasonable. In the C++ port, it roughly
doubles the total time of the detection algorithm, which is still
small compared to the time the binarizer takes. The Java code probably
needs more optimization.
Currently the QR code contains some hardcoded values, which are
specifically optimized for 240x180 images (I don't have any other test
data). It will need some work before it will be usable for larger
images as well.
This adds a lot of code, for general barcode scanning applications it
might not be worth it. The edge detection functions might be useful
for datamatrix codes.
I'll send you the code soon. Use or don't use it, it's up to you. It
should be useful to keep it for possible future development anyway.
As for the C++ port, the changes to the current code are minor. I'll
be using the edge detection in my Symbian application, but I'll leave
it disabled by default.
Ralf