python – Detect contour into the method cv2.Circle


I am developing a project and would like a little help. I am using opencv + python for image processing, I use the Canny method to extract the edges of a can and I use findContour to draw the contours found by the Canny method …

I draw the outline found in the image, then create a circle using the cv.Circle method as shown in the image:

Image

The red circle is the circle created by the cv.Circle method.

The green circle is the outline found by the Canny method.

What I need now is to know if it is possible to identify whether any part of the green outline is into the red circle, is it possible to make this identification?

Script used:

gray = cv2.cvtColor (image, cv2.COLOR_BGR2GRAY)
gray = cv2.blur (gray, (3, 3))
edged = cv2.Canny (gray, canny1, canny1 * 3, kernel)
outline, hierarchy = cv2.findContours (edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
areas = (cv2.contourArea (contour) for contour in contour)
if areas:
    (contour, areas) = ​​zip (* sorted (zip (contour, areas), key = lambda a: a (1)))
    cnt = outline (-1)
    #print (areas)
    (x, y), radius = cv2.minEnclosingCircle (cnt)
    center = (int (x), int (y))
    radius = int (radius)
    circle = cv2.circle (image, center, radius - 10, (0,0,255), 2)
    circle = cv2.circle (image, center, radius + 10, (0,0,255), 2)
    cv2.drawContours (image, (outline (-1)), -1, (0, 255, 0), 2)
    cv2.imshow ('Canny Edges After Contouring', edged)
    cv2.imshow ('Contours', image)