OpenCV - Create recursive pattern

Posted zhangzhihui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenCV - Create recursive pattern相关的知识,希望对你有一定的参考价值。

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

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的主要内容,如果未能解决你的问题,请参考以下文章