From fa1c915ccb7f1f79c73efdebfbecf60e82822fe4 Mon Sep 17 00:00:00 2001 From: 13339479676 Date: Mon, 17 Jan 2022 20:49:15 +0800 Subject: [PATCH] v04 update 03 --- opencv_webcam.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opencv_webcam.py b/opencv_webcam.py index ffec60e..f50812d 100644 --- a/opencv_webcam.py +++ b/opencv_webcam.py @@ -120,7 +120,8 @@ def webcam_opencv(device_index="0", Path(f"{frame_saveDir}") / frame_dirName, exist_ok=False) # 增量运行 frame_savePath.mkdir(parents=True, exist_ok=True) # 创建目录 - frame_num = 0 # 帧数 + frame_num = 0 # 总帧数 + frame_hand_num = 0 # 手动保存帧数 ows_version = 'OpenCV Webcam Script v0.4' # 版本号 while(cap.isOpened()): wait_key = cv2.waitKey(20) & 0xFF # 键盘监听 @@ -138,6 +139,7 @@ def webcam_opencv(device_index="0", frame_namePrefix, frame_saveStyle, jpg_quality, png_quality) if (is_handSaveFrame): # 手动保存 if wait_key == ord(frame_capKey): # 保存键 + frame_hand_num += 1 # 手动帧计数 frame_opt(frame, frame_savePath, frame_num, is_resizeFrame, resize_frame, resizeRatio_frame, frame_namePrefix, frame_saveStyle, jpg_quality, png_quality) @@ -147,10 +149,14 @@ def webcam_opencv(device_index="0", print(f'已暂停!按任意键继续。。。') cv2.waitKey(0) # 暂停,按任意键继续 - if (frame_savePath != ""): + if (is_autoSaveFrame): frameSaveMsg = f'共计{frame_num}帧,已保存在:{frame_savePath}' print(frameSaveMsg) log_management(f'{frameSaveMsg}\n', logName, logMode) # 记录帧保存信息 + elif (is_handSaveFrame): + frameSaveMsg = f'共计{frame_hand_num}帧,已保存在:{frame_savePath}' + print(frameSaveMsg) + log_management(f'{frameSaveMsg}\n', logName, logMode) # 记录帧保存信息 cap.release() # 释放缓存资源 cv2.destroyAllWindows() # 删除所有窗口