Feb
14
2018
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()
微信扫一扫,打赏作者吧~
最活跃的读者