OpenCV imwrite()不保存图像 [英] OpenCV imwrite() not saving image

查看:1169
本文介绍了OpenCV imwrite()不保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

code> cv :: imwrite(/ Users / nickporter / Desktop / Gray_Image.jpg,cvImage);

任何人都能看到为什么这可能无法保存?

有时,OpenCV在保存到 JPG 图像时遇到问题,请尝试保存到 BMP 代替:

  cv :: imwrite(/ Users / nickporter / Desktop / Gray_Image.bmp, cvImage); 

此外,在此之前,请确保您将 cvImage 有效。您可以先显示图片进行检查:

  namedWindow(image,WINDOW_AUTOSIZE); 
imshow(image,cvImage);
waitKey(30);


I am trying to save an image from OpenCV on my mac and I am using the following code and so far it has not been working.

cv::imwrite("/Users/nickporter/Desktop/Gray_Image.jpg", cvImage);

Can anyone see why this might not be saving?

解决方案

OpenCV does have problems in saving to JPG images sometimes, try to save to BMP instead:

cv::imwrite("/Users/nickporter/Desktop/Gray_Image.bmp", cvImage);

Also, before this, make sure you image cvImage is valid. You can check it by showing the image first:

namedWindow("image", WINDOW_AUTOSIZE);
imshow("image", cvImage);
waitKey(30);

这篇关于OpenCV imwrite()不保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆