Hi,
I'm currently fiddling with DataMatrix codes and the assumption (centered bar code) made inside WhiteRectangleDetector is simply invalid for my use case: the bar code isn't near the center of my LuminanceSource at all (see
datamatrix-3/scan1).
WhiteRectangleDetector searches for "one white line" from the center in all directions (center to right, center to left, ...). After it has located a "white working area" it scans diagonally for black pixels, extracting a "bar code area". The algorithm can be tricked very easily: put the bar code in a corner of a large white image and/or draw an intersecting ellipse around the barcode - voila nothing is detected. The Aztec detector suffers from the same problem. I've got several ideas how to fix this:
- Replace WhiteRectangleDetector with something more sophisticated as in Data Matrix Code Location Based on Finder Pattern Detection and Bar Code Border Fitting. Basically they locate all lines using region growing along with some tricky validation/matching. This obviously eliminates the "someone aiming with a camera" assumption, but its tricky to implement, slower and sort of expands the scope of ZXing.
- Close() = Erode(Dilate()) the hole image, find connected components and
search the resulting rectangles for bar codes. This would be sort of a new
MultipleBarcodeReader, that searches every plausible rectangle, that still could miss DataMatrix bar codes due to page layout/text/people connecting page layout to barcodes with pens (yep...!).
Any thoughts on this? Feedback is always welcome :)
Regards,
Christoph