Algorithm 2 Contour Area Filter |
1: Input: image = cv2.imread(“./welding01.jpg”) 2: hsvVals = {‘hmin’:0, ‘smin’:0, ‘vmin’:250, ‘hmax’:179, ‘smax’:135, ‘vmax’:255} 3: Initialize: imgColor, mask = myColorFinder.update(image, hsvVals) 4: contours, hierarchy = cv2.findContours(mask, cv2.RETR_EXTER NAL, cv2.CHAIN_APPROX_NONE) 5: Repeat: for cnt loop every contours do: 6: area = cv2.contourArea(cnt) 7: (x, y, w, h) = cv2.boundingRect(cnt) 8: if area_threshold_1 < area < area_threshold_2: 9: print(x, y, w, h) Output: (x, y, w, h) contour area |