码迷,mamicode.com
首页 > 其他好文 > 详细

OpenCV - Create recursive pattern

时间:2020-03-16 17:40:55      阅读:59      评论:0      收藏:0      [点我收藏+]

标签:生成   窗口   imwrite   oca   release   back   named   lag   create   

很简单,生成一个窗口实时显示摄像头的内容,然后将摄像头对准这个窗口。代码如下:

import cv2

clicked = False
def onMouse(event, x, y, flags, param):
    global clicked
    if event == cv2.EVENT_LBUTTONUP:
        clicked = True

cameraCapture = cv2.VideoCapture(0)
cv2.namedWindow(‘Window‘)
cv2.setMouseCallback(‘Window‘, onMouse)

success, frame = cameraCapture.read()
while success and cv2.waitKey(1) == -1 and not clicked:
    cv2.imshow(‘Window‘, frame)
    success, frame = cameraCapture.read()
cv2.imwrite(‘recursive.png‘, frame)

cv2.destroyAllWindows()
cameraCapture.release()

 

效果图如下:

技术图片

OpenCV - Create recursive pattern

标签:生成   窗口   imwrite   oca   release   back   named   lag   create   

原文地址:https://www.cnblogs.com/zhangzhihui/p/12505200.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!