i was following a tutorial about shapes detection using opencv ,numpy and python ,and it was this function i know the reason from it but i do not know how to modify it so i can use it as i want the total bubble's number are 320 but the function detect 303 only i tried to modify this line but the max i get is 303 (len(approx) > 8 and w / h <= 1.1 and w / h >= 0.8) i want someone to explain to me this function please
this is the code
def getOvalContours(self, adaptiveFrame):contours, hierarchy = cv2.findContours(adaptiveFrame, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)ovalContours = []for contour in contours:approx = cv2.approxPolyDP(contour, 0, True)ret = 0x, y, w, h = cv2.boundingRect(contour)# eliminating not ovals by approx lenghtif (len(approx) > 8 and w / h <= 1.1 and w / h >= 0.8):mask = np.zeros(adaptiveFrame.shape, dtype="uint8")cv2.drawContours(mask, [contour], -1, 255, -1)ret = cv2.matchShapes(mask, contour, 1, 0.0)if (ret < 1):ovalContours.append(contour)self.bubbleWidthAvr += wself.bubbleHeightAvr += hself.bubbleWidthAvr = self.bubbleWidthAvr / len(ovalContours)self.bubbleHeightAvr = self.bubbleHeightAvr / len(ovalContours)return ovalContours
this is the image