Skip to content

Commit 1939b42

Browse files
committed
update
1 parent 25119b3 commit 1939b42

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎opencv/read_frame.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import threading
66
import time
7+
from time import sleep
78

89

910
def process_frame(video_path, start_frame, end_frame, output_list, lock):
@@ -26,6 +27,9 @@ def process_frame(video_path, start_frame, end_frame, output_list, lock):
2627
thread_output.append(
2728
f"{time.ctime()} Thread {start_frame}: Timestamp - {timestamp}")
2829

30+
# 模拟处理帧的过程,越慢多线程优势越明显
31+
sleep(5)
32+
2933
# 设置视频流的位置,直接跳过一些帧
3034
cap.set(cv2.CAP_PROP_POS_FRAMES, cap.get(cv2.CAP_PROP_POS_FRAMES) + 20)
3135

@@ -71,8 +75,8 @@ def main(video_path, num_threads):
7175
logging.info("All threads completed.")
7276
# logging.info(f"Output list: {output_list.size()}")
7377
# 打印所有线程的输出
74-
for output in output_list:
75-
print(output)
78+
# for output in output_list:
79+
# print(output)
7680

7781
cap.release()
7882
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)