python opencv 逐帧看视频 一帧一帧看
import cv2
import json
from collections import defaultdict
from collections import deque
from pynput import keyboard
frame_objects = defaultdict(list)
frame_buffer = deque(maxlen=300)
queue_index = -1
load_new_frame = True
frame_index = -1
def read_log_file(log_file_path):
global frame_objects
with open(log_file_path, 'r') as f:
for line in f:
data = json.loads(line)
frame_index = int(data["imagePath"])
shapes = data["shapes"]
frame_objects[frame_index] = shapes
def on_press(key):
global queue_index, load_new_frame
if key == keyboard.Key.right or key == keyboard.Key.dow