set auto save max frames
This commit is contained in:
parent
3259e7601b
commit
cf05facede
|
@ -43,7 +43,8 @@ def parse_args(known=False):
|
|||
default=3, type=int, help='frame save jpg quality (0-9) default 3')
|
||||
parser.add_argument('--pause', '-p',
|
||||
default="p", type=str, help='webcam pause')
|
||||
|
||||
parser.add_argument('--auto_frameNum', '-afn',
|
||||
default=0, type=int, help='auto save number of frames')
|
||||
args = parser.parse_known_args()[0] if known else parser.parse_args()
|
||||
return args
|
||||
|
||||
|
@ -93,7 +94,7 @@ def frame_opt(frame, frame_savePath, frame_num, is_resizeFrame, resize_frame, re
|
|||
|
||||
|
||||
# Webcam OpenCV
|
||||
def webcam_opencv(device_index, quit_key, pause_key, is_autoSaveFrame, frame_saveDir, frame_nSave, is_handSaveFrame,
|
||||
def webcam_opencv(device_index, quit_key, pause_key, is_autoSaveFrame, frame_saveDir, frame_nSave, auto_frameNum, is_handSaveFrame,
|
||||
frame_capKey, is_resizeFrame, resize_frame, resizeRatio_frame, frame_namePrefix, frame_saveStyle,
|
||||
jpg_quality, png_quality):
|
||||
if (quit_key == frame_capKey): # 判断快捷键冲突
|
||||
|
@ -127,6 +128,9 @@ def webcam_opencv(device_index, quit_key, pause_key, is_autoSaveFrame, frame_sav
|
|||
cv2.imshow(ows_version, frame) # 显示画面
|
||||
|
||||
if (is_autoSaveFrame): # 自动保存
|
||||
if (auto_frameNum > 0 and frame_num > auto_frameNum):
|
||||
# 设置自动最大保存帧数
|
||||
break
|
||||
if (frame_num % frame_nSave == 0): # 每隔n帧保存一次
|
||||
frame_opt(frame, frame_savePath, frame_num, is_resizeFrame, resize_frame, resizeRatio_frame,
|
||||
frame_namePrefix, frame_saveStyle, jpg_quality, png_quality)
|
||||
|
@ -169,9 +173,10 @@ def main(args):
|
|||
jpg_quality = args.jpg_quality
|
||||
png_quality = args.png_quality
|
||||
pause_key = args.pause
|
||||
auto_frameNum = args.auto_frameNum
|
||||
|
||||
# 调用webcam opencv
|
||||
webcam_opencv(device_index, quit_key, pause_key, is_autoSaveFrame, frame_saveDir, frame_nSave,
|
||||
webcam_opencv(device_index, quit_key, pause_key, is_autoSaveFrame, frame_saveDir, frame_nSave, auto_frameNum,
|
||||
is_handSaveFrame, frame_capKey, is_resizeFrame, resize_frame, resizeRatio_frame,
|
||||
frame_namePrefix, frame_saveStyle, jpg_quality, png_quality)
|
||||
|
||||
|
|
Loading…
Reference in New Issue