What is the meaning of the output of sensor_rate in this code?

  image-processing, python

_, img = cap.read()
zeros_image = np.zeros((img.shape[0], img.shape[1], 1), np.uint8)

img_ycrcb = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
blur = cv2.GaussianBlur(img_ycrcb, (11, 11), 0)

skin_ycrcb_min = np.array((0, 0, 140))
skin_ycrcb_max = np.array((65, 253, 255))
skin_ycrcb_min = np.array((0, 0, 180))
skin_ycrcb_max = np.array((140, 255, 255))
mask = cv2.inRange(blur, skin_ycrcb_min, skin_ycrcb_max)

contours, hierarchy = cv2.findContours(
    mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:]
valid_cntrs = []
for i, cnt in enumerate(contours):
    x, y, w, h = cv2.boundingRect(cnt)
    area = cv2.contourArea(cnt)
    cX = int(x + (w/2))
    cY = int(y + (h/2))

    if (x <= 600) & (y >= 300) & (y <= 455) & (area > 900):
        valid_cntrs.append(cnt)
        cv2.putText(img, str(f'{cX},{cY}'), (cX, cY), cv2.FONT_HERSHEY_SIMPLEX,
                    1, (255, 0, 0), 2, cv2.LINE_AA)
        cv2.rectangle(zeros_image, (x, y), (x+w, y+h), (255),
                      thickness=cv2.FILLED)

mask1 = np.zeros((zeros_image.shape[0], zeros_image.shape[1], 1), np.uint8)
mask_result = cv2.bitwise_or(zeros_image, zeros_image, mask=Sensor1.mask)
white_cell_number = np.sum(mask_result == 255)
sensor_rate = white_cell_number/Sensor1.full_mask_area

sensor_rate prints out values between 0.85 to 31 or less than 0.85

Source: Python Questions

LEAVE A COMMENT