np使用创建图像 霍夫圆检测 video操作,显示canny边缘

np使用创建图像
def creat_image():
image = np.zeros([400, 400, 3], np.uint8) //三通道
image[:, :, 2] = np.ones([400, 400])*255
cv.imshow('creat image', image )


霍夫圆检测
def detect_circle_Demo(image):
dst = cv.pyrMeanShiftFiltering(image, 10, 100)
cv.imshow('sdasda',dst)
cimage = cv.cvtColor(dst, cv.COLOR_BGR2GRAY)
circles = cv.HoughCircles(cimage, cv.HOUGH_GRADIENT, 1, 200, param1=50, param2=30, minRadius=0, maxRadius=0)
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
cv.circle(image, (i[0], i[1]), i[2], (0, 0, 255), 2)
cv.circle(image, (i[0], i[1]), 2, (0, 0, 255), 2)
cv.imshow('circles', image)
  
video操作,显示canny边缘
def video_Demo():
capture = cv.VideoCapture(0)
while True:
ret, frame = capture.read()
frame = cv.flip(frame, 1)
frame_gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
canny = cv.Canny(frame_gray, 50, 150)
cv.imshow('video', canny)
c = cv.waitKey(50)
if c == 27:
break

 

posted @ 2020-07-09 22:53  千寻slimg  阅读(299)  评论(0编辑  收藏  举报