I'm trying to extract this mold from this picture. I've got some code to extract it, the only thing I need are the four corners.
def detect_object(image):
orig = image.copy()
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurry = cv2.adaptiveThreshold(image.astype(np.uint8), 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 11, 3)
contours, _ = cv2.findContours(blurry, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours = sorted(contours, key = cv2.contourArea, reverse = True)
cnt = contours[1] #We don't want the outer contour.
cv2.drawContours(orig, cnt, -1, (0,255,255))
return orig
When I try this with for example a sudoku, it draws the contours of the outer lines perfect . As a result, this sudoku can be extracted from the picture with some extra code. However, when I try this with my aluminium mold, no useful contours can be found.
I've already tried to use a lot of filters, but unfortunately it still doesn't work.
Does someone knows some helpful tips? Thanks in advance.