v2 style updte

This commit is contained in:
13339479676 2022-01-02 15:43:11 +08:00
parent 741b3c40bd
commit 917df2152f
1 changed files with 20 additions and 10 deletions

View File

@ -67,7 +67,8 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False):
# webcam opencv
def webcam_opencv(device_index, quit_key, is_autoSaveFrame, frame_saveDir, frame_nSave, is_headSaveFrame,
frame_capKey, is_resizeFrame, resize_frame, resizeRatio_frame, frame_namePrefix, frame_saveStyle, jpg_quality, png_quality):
frame_capKey, is_resizeFrame, resize_frame, resizeRatio_frame, frame_namePrefix, frame_saveStyle,
jpg_quality, png_quality):
if (quit_key == frame_capKey): # 判断快捷键冲突
print(f'快捷键冲突! 程序结束!')
return
@ -109,20 +110,24 @@ def webcam_opencv(device_index, quit_key, is_autoSaveFrame, frame_saveDir, frame
if (frame_saveStyle == 'jpg'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new, [int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new,
[int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
if (frame_saveStyle == 'png'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new, [int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new,
[int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
else:
print(f'帧格式有问题!')
return
else:
if (frame_saveStyle == 'jpg'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame, [int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
if (frame_saveStyle == 'png'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame, [int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
else:
print(f'帧格式有问题!')
return
@ -137,20 +142,24 @@ def webcam_opencv(device_index, quit_key, is_autoSaveFrame, frame_saveDir, frame
frame, (w_resize, h_resize), interpolation=cv2.INTER_AREA)
if (frame_saveStyle == 'jpg'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new, [int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new,
[int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
if (frame_saveStyle == 'png'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new, [int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new,
[int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
else:
print(f'帧格式有问题!')
return
else:
if (frame_saveStyle == 'jpg'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame, [int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
if (frame_saveStyle == 'png'):
cv2.imwrite(
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame, [int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
f'./{frame_samePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
else:
print(f'帧格式有问题!')
return
@ -187,7 +196,8 @@ def main(args):
# 调用webcam opencv
webcam_opencv(device_index, quit_key, is_autoSaveFrame, frame_saveDir, frame_nSave,
is_headSaveFrame, frame_capKey, is_resizeFrame, resize_frame, resizeRatio_frame, frame_namePrefix, frame_saveStyle, jpg_quality, png_quality)
is_headSaveFrame, frame_capKey, is_resizeFrame, resize_frame, resizeRatio_frame,
frame_namePrefix, frame_saveStyle, jpg_quality, png_quality)
if __name__ == '__main__':