python 搞定opencv

 
更多

安装

pip install opencv-python==3.4.0.12

参考文档

https://www.cnblogs.com/xiaotongtt/p/6601951.html

# coding:utf-8
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('MyWindow')
cv2.setMouseCallback('MyWindow', onMouse)
out = cv2.VideoWriter('E:\\Python\\output.avi', cv2.VideoWriter_fourcc('m', 'p', '4', 'v'), 10, (640, 480))
print('showing camera feed. Click window or press any key to stop.')
success, frame = cameraCapture.read()
while success and cv2.waitKey(1) == -1 and not clicked:
    cv2.imshow('MyWindow', frame)
    success, frame = cameraCapture.read()
    frame = cv2.flip(frame, 1)
    a = out.write(frame)
cv2.destroyWindow('MyWindow')
out.release()
cameraCapture.release()

打赏

本文固定链接: https://www.cxy163.net/archives/1611 | 绝缘体

该日志由 绝缘体.. 于 2018年02月14日 发表在 首页 分类下,
原创文章转载请注明: python 搞定opencv | 绝缘体

报歉!评论已关闭.