I'm trying to detect data matrices from a camera image looking up. I'm using an external DM decoder library, but it's slow enough I need to find likely codes in opencv before passing them off. I'm using python openv4.1 on a raspberry pi. I have some direct fore-lighting, but the backlighting is highly variable:
I can put whatever I want around the data matrices to make this easier. I initially tried putting a red square around them and using chroma keying (HSV->filter_to_red), but it's tough to define "red" consistently enough for the lighting:
Here's the same settings on the brighter image:
I've had some luck with chroma->canny->blur->edges->approxPolyDP to come up with the squares, but it's still pretty finicky as lighting changes or the clipart gets too close to the image:
Any suggestions for a better fiducial than a red square? What would be the easiest thing to detect?
It's a cropped image from a fisheye lens and I haven't corrected the distortion because it's too slow.