computer vision - OpenCV: How to detect rhombus on image? -


i hame image plane have perspective transform.

i need detect center of each white rhombus or rhombus itself.

here examples:

enter image description here enter image description here

as unserstand problem can solved simple template matching if rectify image, need automatically.

is there functions in opencv suitable task? other ideas?

here 2 quick tests did without correcting perspective issue.

pure mathematical morphology:

  1. extract red channel
  2. big white top-hat in order detect bright areas, without big bright reflexion.
  3. small white top-hat in order detect thin lines between rhombus
  4. result of 2 minus result of 3. lines between rhombus thinner or disappeared.
  5. opening clean final result.

here 2 results: image1 , image2. main issue rhombus not have same sizes (different magnification , perspective), can problematic mathematical morphology.

so here an other solution using hough transform:

  1. you start resulting image of step 3 previous algorithm.
  2. you apply hough transform.

here results: hough1 , hough2. have filter between lines touching rhombus or not, can use first algorithm that. if rhombus not detected first algorithm, , enough detect lines touching rhombus. line intersections centroids looking for.


Comments