v05 frames opt update

This commit is contained in:
13339479676 2022-01-29 07:40:36 +08:00
parent d144cf6caa
commit e697b92850
1 changed files with 11 additions and 24 deletions

View File

@ -33,30 +33,17 @@ def frame_opt(frame,
resize_frame[0] * resizeRatio_frame) # 重塑宽度
h_resize = int(
resize_frame[1] * resizeRatio_frame) # 重塑高度
frame_new = cv2.resize(
frame = cv2.resize(
frame, (w_resize, h_resize), interpolation=cv2.INTER_AREA) # 重塑
if (frame_saveStyle == 'jpg'):
cv2.imwrite(
f'./{frame_savePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new,
[int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
elif (frame_saveStyle == 'png'):
cv2.imwrite(
f'./{frame_savePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame_new,
[int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
else:
print(f'帧格式有问题!无法保存!')
sys.exit() # 结束程序
if (frame_saveStyle == 'jpg'):
cv2.imwrite(
f'./{frame_savePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
elif (frame_saveStyle == 'png'):
cv2.imwrite(
f'./{frame_savePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
else:
if (frame_saveStyle == 'jpg'):
cv2.imwrite(
f'./{frame_savePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_JPEG_QUALITY), jpg_quality])
elif (frame_saveStyle == 'png'):
cv2.imwrite(
f'./{frame_savePath}/{frame_namePrefix}-{frame_num}.{frame_saveStyle}', frame,
[int(cv2.IMWRITE_PNG_COMPRESSION), png_quality])
else:
print(f'帧格式有问题!无法保存!')
sys.exit() # 结束程序
print(f'帧格式有问题!无法保存!')
sys.exit() # 结束程序