diff --git a/utils/frame_opt.py b/utils/frame_opt.py index 945d08b..5e1f9ea 100644 --- a/utils/frame_opt.py +++ b/utils/frame_opt.py @@ -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() # 结束程序