我想根据灰度图像中轮廓区域的颜色强度从集合中过滤轮廓。因此,对于每帧中所有检测到的轮廓,我想检查轮廓的平均颜色强度是否大于阈值。
def check_countour(cnt, gray_frame, threshold):
cimg = np.zeros_like(gray_frame)
cv2.drawContours(cimg, cnt, -1, color=255, thickness=-3)
pts = np.where(cimg == 255)
color_intensity = np.mean(gray_frame[pts[0], pts[1]])
return True if color_intensity > threshold else False
这能正确地给我答案吗?