import cv2
# import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
# cv2.imshow("The original figure", frame)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray2 = 255 - gray
cv2.imshow("The color chart", gray2)
cv2.resizeWindow("The color chart", 500, 500);
ret, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
cv2.imshow("Binary figure", binary)
cv2.resizeWindow("Binary figure", 500, 500);
img_median = cv2.medianBlur(binary, 3)
img_Guassian = cv2.GaussianBlur(img_median, (5, 5), 0)
img_mean = cv2.blur(img_Guassian, (5, 5))
img_bilater = cv2.bilateralFilter(img_mean, 9, 75, 75)
contours, hierarchy = cv2.findContours(img_bilater, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(frame, contours, -1, (0, 0, 255), 6)
cv2.imshow("Outline of the figure", frame)
cv2.resizeWindow("Outline of the figure", 500,500);
boardkey = cv2.waitKey(1) & 0xFF
if boardkey == 27:
break
cap.release()
cv2.destroyAllWindows()
选定区域 00-08-53_51Record
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/156937.html