0

I have a document (graphical plan of a building) which has some objects I need to detect with text in it. Basically it's just a oblate hexagon with text inside. My task is to find all such hexagons on a given plan. I decided to cut one hexagon and set it as a template and use cv2.templateMatch. It was able to correctly detect some hexagons, but not all of them. I suppose, the problem is the text inside, since it's different for each hexagon, I'm not able to detect all the hexagons that are present.

Is it possible to somehow make the template dynamic or to detect only the surrounding borders, ignoring the text inside.

UPD: Objects I need to locate look kind of this:

  __________
 <|ABC12345|>
  ----------
wasd
  • 1,532
  • 3
  • 28
  • 40
  • Can you provide a sample input image, please? – Dan Mašek Jul 29 '18 at 16:57
  • @DanMašek sorry, but it's under NDA. Can you imagine plan of a floor of a building (e.x. fire emergency plan) and on it I have objects, which kind of similar to: This box I call hexagon, I think you got the idea – wasd Jul 29 '18 at 19:04
  • 1
    opencvs template matching does not allow the usage of masks, but the process is quite aimple and you might be able to write it (maybe slower / less optimized) yourself. Another similar alprach is chamfer matching. – Micka Jul 29 '18 at 20:50
  • If color of the font is different to the hexagon, you might try to filter text out before pattern matching. – Mika72 Jul 31 '18 at 09:00

1 Answers1

0

I think template matching won't give you good results since this is a object detection problem.

To me, it is very similar to plate detection/recognition.

The most robust way is using deep learning to solve this problem.

A rough summary of a possible solution could be: 1. Generate training and testing data based on the font style and its format (e.g., 3 letters and 5 digits) 2. Add noise and different background to the generated images 3. Find a proper netowrk and start training ...

Good luck.

Howard GENG
  • 1,075
  • 7
  • 16