opencv cvSaveImage保存图像问题!!急急急啊!!

wo252518553 2014-06-14 05:11:06
现在在做批处理图像的问题,因为每张图片都会产生很多中间结果图像,要保存下来,先读取文件名,这个我会,可是保存的时候如何在cvSaveImage()中写路径呢?我希望每个图像都产生一个文件夹用来存储中间结果。
比如:文件在\....\img\a.jpg
然后我想将结果保存为 \....\img\a\result1.jpg
如何做到呢???不是说cvSaveImage(“ \....\img\a\result1.jpg”,img),不是这样,这样就不能是批处理,每次都会覆盖。。
不知道我说清楚了没,求大神指教!
...全文
3891 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
alpha明 2016-08-11
  • 打赏
  • 举报
回复
你的问题在于不知道怎么使文件名可变是吧?可以这么做: int idx=0; char adr[128]={0}; sprintf(adr, "E:/Notemp/%d_imgNo_temp.jpg", ++idx); cvSaveImage(adr, imgNo ); 文件名为%d_imgNo_temp.jpg,%d部分会被后面idx的值填充。当然前提是要E:/Notemp/ 这个文件夹是存在的,不然会出错。
ZhtSunday 2016-07-09
  • 打赏
  • 举报
回复
请问楼主的问题是怎么解决的?我也有类似的问题,总是报错
gerton 2016-04-12
  • 打赏
  • 举报
回复
定义一个 char imgname[80][100]用来存储文件名,不过这应该是一个二维数组,每一行代表一个路径,然后一个指针指向这个路径,执行完之后指针自加1指向下一行,不过要把库里面的*filename类型改成非常量(就是把const去掉),希望能帮到你。
yujie1993 2015-07-21
  • 打赏
  • 举报
回复
用imwrite()函数
yrd241 2014-10-24
  • 打赏
  • 举报
回复
lz问题解决了没,我遇到和你一样的问题。
赵4老师 2014-06-16
  • 打赏
  • 举报
回复
目测你的.太多了。
赵4老师 2014-06-16
  • 打赏
  • 举报
回复
引用 5 楼 luotuo44 的回复:
[quote=引用 4 楼 wo252518553 的回复:] 我知道了,因为cvSaveImage不能创建不存在的文件夹。。。。。搞了一整天白忙活了。。。。
很少API会自动创建一个文件夹的。[/quote] 恰好今天看到了: MakeSureDirectoryPathExists The MakeSureDirectoryPathExists function creates all the directories in the specified DirPath, beginning with the root. BOOL MakeSureDirectoryPathExists( IN LPSTR DirPath ); Parameters DirPath Pointer to a null-terminated string that specifies a valid path name. If the final component of the path is a directory, not a filename, the string must end with a backslash (\) character. Return Values If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError. Remarks Each directory specified is created, if it does not already exist. If only some of the directories are created, the function will return FALSE. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Available as a redistributable for Windows 95. Windows CE: Unsupported. Header: Declared in imagehlp.h. Import Library: Use imagehlp.lib. See Also PE Image Helper (ImageHlp) Overview, ImageHlp General Functions
luotuo44 2014-06-15
  • 打赏
  • 举报
回复
引用 4 楼 wo252518553 的回复:
我知道了,因为cvSaveImage不能创建不存在的文件夹。。。。。搞了一整天白忙活了。。。。
很少API会自动创建一个文件夹的。
wo252518553 2014-06-14
  • 打赏
  • 举报
回复
我知道了,因为cvSaveImage不能创建不存在的文件夹。。。。。搞了一整天白忙活了。。。。
wo252518553 2014-06-14
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
cvSaveImage("d:\\img\\a\\result1.jpg”,img);
求大神指导啊……
wo252518553 2014-06-14
  • 打赏
  • 举报
回复
请问,如果我定义一个 char imgname[80]用来存储文件名,然后再用strcat(“路径A”,imgname) 最后cvSaveImage(“路径A”,Img)可以吗? 其实是这样的,这个imgname文件名是 file\img.jpg 所以strcat以后新的路径就是\.....\...\img.jpg ,然后我再把最后的.jpg删掉就变成\.....\...\img 接下来strcat(“\.....\...\img”,“\imgggggg.jpg”) 这样我想要的路径基本就是\.....\...\img\imgggggg.jpg 最后用cvSaveImage(“\.....\...\img\imgggggg.jpg”,img) 这么做对吗?可是总是存不上呢???而且我想生成的img文件夹也没有生成,什么变化都没有,这是怎么回事?求指导!!
赵4老师 2014-06-14
  • 打赏
  • 举报
回复
cvSaveImage("d:\\img\\a\\result1.jpg”,img);

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧