Detecting (not decoding!) datamatrix (rectangle) regions in an image
I know that OpenCV doesn't provide any datamatrix decoding. That's ok. I'm currently using zxing to decode datamatrixes and it seems to work well.
However, Sometimes my image may contain two or more datamatrixes. In this case zxing fails because it needs an image with a single datamatrix in it.
Does anyone know how I can detect the datamatrix region? It doesn't have to be perfect as I don't mind false-positives, as long as I also get the rectangle for the actual datamatrix if there is one. I figure that this should be pretty easy with OpenCV since it is essentially trying to find a high-contrast rectangle, but I haven't been able to figure out how to do it...
Any help would be appreciated!
"find a high-contrast rectangle" - MSER, and some estimation, if the outline is square, maybe.
Find two thresholds, mean+xstdDev and mean-xstdDev (pick an appropriate x), then use inRange to set everything between them to zero. Then set everything else to white and look for squares?
Thanks for the suggestions! Regarding "finding squares", would you suggest MSER for that?
Well, MSER would be instead of the thresholding thing. But to figure out if something is square, take a look at the sample squares.cpp (or squares.py if you're using python).
Appreciate the suggestions here. After some experimentation, I've had good luck with MSER after blurring, resizing and inRanging the image to give me black blobs where the codes are likely to be. It seems to work quite well, except that my results vary dramatically depending on lighting conditions. Any ideas on how I might normalize for these given the steps I mention? I tried the approach mentioned in http://answers.opencv.org/question/75... , but it doesn't seem to solve the issue...
Thanks again.