我正在尝试使用openCV组合来自网络摄像头的提要,然后使用matplotlib更新图表.
获取和显示框架的基本示例如下:
import cv2
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame',frame)
# When to exit loop - terminate program
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
使用matplotlib连续更新图形(随机绘图)的示例:
import numpy as np
import matplotlib.pyplot as plt
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
y = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# x …Run Code Online (Sandbox Code Playgroud) 我有一个具有以下格式的文件:
SET, 0, 0, 0, 6938987, 0, 4
SET, 1, 1, 6938997, 128, 0, 0
SET, 2, 4, 6938998, 145, 0, 2
SET, 0, 9, 6938998, 147, 0, 0
SET, 1, 11, 6938998, 149, 0, 0
....
SET, 1, 30, 6946103, 6, 0, 0
SET, 2, 30, 6946104, 6, 0, 2
GET, 0, 30, 6946104, 8, 0, 0
SET, 1, 30, 6946105, 8, 0, 0
GET, 2, 30, 6946106, 7, 0, 0
Run Code Online (Sandbox Code Playgroud)
第 5 列代表我从系统测量的毫秒(从 Java 的 System.nanoTime() 转换而来)。因此,这些不代表任何日期/时间格式。我想以 5s …