python边缘检测显示原图边缘
【摘要】
def bianyuan(): import cv2 import numpy as np vc=cv2.VideoCapture(0) while True: ret,img=vc.read() start=time.time() source = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # sobel_x:发现垂...
-
def bianyuan():
-
import cv2
-
import numpy as np
-
-
vc=cv2.VideoCapture(0)
-
-
while True:
-
ret,img=vc.read()
-
-
start=time.time()
-
source = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
-
-
# sobel_x:发现垂直边缘
-
sobel_x = cv2.Sobel(source, cv2.CV_64F, 1, 0)
-
# sobel_y:发现水平边缘
-
sobel_y = cv2.Sobel(source, cv2.CV_64F, 0, 1)
-
-
sobel_x = np.uint8(np.absolute(sobel_x))
-
sobel_y = np.uint8(np.absolute(sobel_y))
-
np.set_printoptions(threshold=np.inf)
-
sobelCombined = cv2.bitwise_or(sobel_x, sobel_y) # 按位或
-
-
-
# sum = sobel_x + sobel_y
-
-
# cv2.imshow('sobel_combined', sobelCombined)
-
sobelCombined = cv2.cvtColor(sobelCombined, cv2.COLOR_GRAY2BGR)
-
sobelCombined = cv2.bitwise_and(sobelCombined, img) # 按位或
-
print(time.time() - start, '2')
-
cv2.imshow('aaa', sobelCombined)
-
cv2.waitKey(1)
-
-
if __name__ == '__main__':
-
bianyuan()
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/103067966
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)