Fix the incompatibility of gif saving

When cv2.imwirte() saves ".gif", it will cause _error: (-2:Unspecified error) could not find a writer for the specified extension in function 'cv::imwrite_'_. We add an if statement to check whether the saving file format is ".gif" so as to avoid the error.
This commit is contained in:
Timo 2021-03-26 20:10:07 +01:00 committed by GitHub
parent cfdefbe1ba
commit 4bde18a1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -176,6 +176,8 @@ def main(args):
draw_img_save = "./inference_results/" draw_img_save = "./inference_results/"
if not os.path.exists(draw_img_save): if not os.path.exists(draw_img_save):
os.makedirs(draw_img_save) os.makedirs(draw_img_save)
if flag:
image_file = image_file[:-3] + "png"
cv2.imwrite( cv2.imwrite(
os.path.join(draw_img_save, os.path.basename(image_file)), os.path.join(draw_img_save, os.path.basename(image_file)),
draw_img[:, :, ::-1]) draw_img[:, :, ::-1])