Ask Your Question

Revision history [back]

How to detect labels with numbers in a black rectangle?

I am an absolute newbie to OpenCV and Computer Vision with only a few weeks of trying to understand this fascinating subject. Please excuse me if my question is "stupid" or otherwise, but we all have to start somewhere. What might be trivial to an expert or Guru is a mountain to a beginner until they are enlightened with the knowledge.

With that aside, I am involved in a project to locate labels with a series of numbers in a black rectangle (see attached photo).

image description

Using the images from a camera, I need to detect and retrieve the numbered rectangles to apply OCR on it and shine a laser pointer on the number that is being searched for. I am able to manually get the rectangle, adjust for its perspective, binarize it and use Tesseract to read it. But I am having difficulty in detecting the label and getting the bounding rectangle of the numbers. I have tried using Cascade Classifiers without much luck and applying adaptive thresholding to get a clearer image of the bounding black rectangle. What would be the best approach to getting the ROI? Is it possible to detect the label using Cascade Classifiers? If it is then please enlighten me as to how train the Cascade Classifier properly because I have followed the instructions, found on the Net, to train them. Do I need to get clearer/cleaner images of the labels and what size is best for the images? I found out there is a limit to how big the positive images can be.

Your suggestions, ideas, constructive comments, and help is greatly appreciated. And I hope to pass on what I learn to others also.