pythonopencvcomputer-visioncontourobject-recognition

Draw Contours in opencv around recognized polygon


I am working on OpenCV-Python. I have a image like this(bellow image,but without light green lines) from live feed by webcam.I have found corners coordinates,

(array([[[280, 109]],

   [[162, 206]],

   [[189, 341]],

   [[329, 389]],

   [[444, 283]],

   [[412, 160]]])

of polygon. How to draw a line around recognized polygon like light green lines shown on image?

Recognized shape


Solution

  • You can use drawContours() function:

    cv2.drawContours(img, contours, -1, (0,255,0), 3)
    

    The documentation explains it well:

    http://docs.opencv.org/master/d4/d73/tutorial_py_contours_begin.html#gsc.tab=0