OpenCV Error: Unspecified error (could not find a writer for the specified extension) in imwrite

OpenCV(3.4.1) Error: Unspecified error (could not find a writer for the specified extension) in imwrite_, file /home/caros/Downloads/opencv-3.4.1/modules/imgcodecs/src/loadsave.cpp, line 678
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.1) /home/caros/Downloads/opencv-3.4.1/modules/imgcodecs/src/loadsave.cpp:678: error: (-2) could not find a writer for the specified extension in function imwrite_

出现这种错误的原因大部分是因为要保存的图片没有加后缀

因为我设置的保存地址中没有加上图片名称...

os.path.basename()可以获取单独的文件名称

posted @ 2021-10-26 13:26  Tomorrow1126  阅读(987)  评论(0编辑  收藏  举报