0

I am using opencv to detect shapes, I have to detect a shape like this enter image description here

this will be a hand drawn picture, and i am using kinect to detect the picture by checking on frames. Now I get 6 points for these kind of pictures, by removing noise, edge detection, finding contours and than approxDP, now I am not able to detect the shape is right faced, left face, down or up. As the points location change for each picture.

So I want to know given two points, how can I check if there is a line segment between the points or not. After getting there two points, I can calculate from remaining points position that where is the shape pointing.

If anyone has better solution, please share.

Fahad Rauf
  • 705
  • 2
  • 8
  • 17

1 Answers1

0

Assume you have two endpoints, and your line segment have pixel value greater than zero(in the above image you may need to use threshold binary inverted).

  1. Create a mask image by drawing the line with thickness=1 pixel.

  2. Copy the source image to new Mat using above Mask.

  3. Now count non-zero pixel in the resultant Mat,

    • if it is zero there is no line between the points,
    • and if the count non-zero gives a value you can cross-check it by comparing with the length of line you drawn in mask.
Haris
  • 13,645
  • 12
  • 90
  • 121