I have a problem while looking for biggest contour. I'm using image after canny edge detection:
Then I'm using
contours, hierarchy = cv2.findContours(edges,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
to find contours:
Next step is to find the biggest contour... I've tried:
contour = max(contours, key = cv2.contourArea)
but this give me something like:
Any ideas how to fix this? Thanks!
Code:
import cv2
image = cv2.imread('TEST_1.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gaussian = cv2.GaussianBlur(gray,(3,3),cv2.BORDER_DEFAULT)
edges = cv2.Canny(gaussian,100,200)
contours, hierarchy = cv2.findContours(edges,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
contour = max(contours, key = cv2.contourArea)
contourImg = cv2.drawContours(image, contour, -1, (0,255,0), 3)
cv2.imshow("Contours", contourImg)
cv2.waitKey(0)
cv2.destroyAllWindows()
Also, contour area for this dot is 109 and for my biggest contour is 3.5