- matplotlib - opencv-python - paths: - http://dreamplan7.cafe24.com/pyscript/Unity3DCam.mp4 - autoclose_loader: true - runtimes: - src: "https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.js" name: pyodide-0.20 lang: python
import matplotlib.pyplot as plt import cv2 from js import document, setInterval from pyodide.ffi import create_proxy import gc 캡쳐 = cv2.VideoCapture('Unity3DCam.mp4') 프레임번호 = 120 def ShowFrame(): global 캡쳐, 그래프, cv2, plt, 프레임번호, document 캡쳐.set(cv2.CAP_PROP_POS_FRAMES, 프레임번호) ret, frame = 캡쳐.read() # 두 개의 값을 반환하므로 두 변수 지정 그래프 = plt.figure(figsize=(8, 6)) plt.axis('off') ax = plt.gca() ax.margins(x=0, y=0) 그래프.tight_layout() plt.imshow(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) pyscript.write('graph', 그래프) plt.close(그래프) document.getElementById('frameNo').innerHTML=프레임번호 프레임번호=프레임번호+15 gc.collect() setInterval(create_proxy(ShowFrame), 500)