Read a tape measure

Hello all, I stumbled across this old post
OpenCV tape measure

This is almost exactly what I’m trying to do with an esp32 cam. Did anyone manage it ? Or would anyone have suggestions on further reading/ research I could do ?
Thanks for reading

start by finding the tape in your picture.

That’s the easy bit as the camera only has a section of the tape in view ie all of the picture is the tape. It is in a jig so will always be perfectly aligned , in focus , same back lighting and size of fonts etc constant. I hope to be able to see the numbers in view then do a pixel count between the centre of the picture and the next mm marker and thus quickly resolve to mm level then calculate sub mm…

that’s a pleasant surprise.

taking that synthetic picture from the old site as an example, you’d wanna prepare the picture so the red markings are ignored. you only care about the black marks.

take scanlines along the length, at various positions into the width of the tape. 1D signals are easier to analyze. run one over the mm ticks, one that only intersects cm ticks.

the black ticks are local minima in the signal. there are many ways to find local extrema. you’ll need to fiddle with smoothing and thresholds and such, but only once.

going from the cm ticks, you could blindly grab a ROI that must contain a number. send it to whatever OCR you want. this could be very cheap to OCR, if you’re willing to specialize the OCR. it’s just digits of a single appearance (font, size, …)

Thanks for the tips. Sorry I was a bit slow responding. I can get stick on scales from the intaweb so I potentially could optimise the input colours. My first thoughts were to swap the image to B&W before trying any processing. Unfortunately it doesn’t appear to be possible to tell my esp32 to only use B&W it takes full colour and converts it which is costly. I like the idea of having the image split in to longitudinal lines so a line for the text , a line for the mm and a line for cm. This would mean I’d only have to scan a one pixel wide image looking for the cm or mm lines. Would you have any suggestions on the ocr bit ? I haven’t got any experience on this part. My thoughts are set the camera distance and focus to only show say 15mm of scale. This would hopefully mean I’d have at least one text marker in view. Look for text marker, ocr it to get value and detect if it is to the left or right of the centre. Now do the same for cm marker distance from this to centre ( when rounded down) gives me the mm measure. Last bit would be to start at the centre line and go one pixel at a time left of centre until I hit a mm marker. This distance in pixel count can then be used to calc the sub mm part. Does this sound feasible and do able in less than a second ?