Detecting a fiducial/data matrix under variable lighting

asked 2019-11-10 21:12:39 -0600

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:

image description image description

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:

image description

Here's the same settings on the brighter image: image description

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.

image description

edit retag flag offensive close merge delete