OpenCV获取摄像头数据并显示在窗口里 Python实现

来源:互联网 发布:幸运28网站源码2016 编辑:程序博客网 时间:2024/05/16 04:00
import cv2clicked = Falsedef onMouse(event, x, y, flags, param):    global clicked    if event == cv2.EVENT_LBUTTONUP:        clicked = TruecameraCapture = cv2.VideoCapture(0)cv2.namedWindow('MyWindow')cv2.setMouseCallback('MyWindow', onMouse)success, frame = cameraCapture.read()while success and cv2.waitKey(1) == 255:    keycode = cv2.waitKey(1)    cv2.imshow('MyWindow',frame)    success, frame = cameraCapture.read()cameraCapture.release()

这里的cv2.waitKey(1) == 255的255我是在Ubuntu是测试的结果。也有人说是bug。

阅读全文
0 0