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

[OpenCV] Samples 07: create_mask

OpenCV的,如何将参数传递到cv2.TrackerMedianFlow_create功能?

OpenCV && C++ 02 - Create a Blank Image & Display

OpenCV AttributeError 模块“cv2.cv2”没有属性“Tracker_create”

opencv4opencv教程 C++ 4Mat对象(深拷贝:clone()copyTo(),create()创建图片,zeros()eye()初始化空白图像,Scalar()创建向量)

opencv bwlabel