保存 Opencv 图像 [英] Saving Opencv Images

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

问题描述

我有一个在 OpenCV (C API) 中运行的窗口,我想从该窗口中保存一系列图像,而无需保存前一个图像.所以一段时间后,窗口应该保存刷新,然后保存并刷新等,我的计算机上应该有多个图像.我还没有完全到达那里,但我正在尝试做类似的事情:

Hi I have a window running in OpenCV (C API) and I would like to save a series of images from the window without saving over the previous image. So after a certain time the window should save refresh, then save and refresh etc. and I should have multiple images on my computer. I haven't quite gotten there but I am trying to do something like:

if (counter>=300)  {
int counterimg=1;
//reset background to black
cvSet(imgScribble,cvScalar(0,0,0);
//save image to file 
cvSaveImage("/Documents/testframe.jpg" [counterimg], frame); 
counter=0;
//increase counter for saving
counterimg+=1;  
}

推荐答案

你只需要创建一个带有图片索引的路径名:

You just need to create a path name with the index of the image:

char path[512];
snprintf(path, 512, "/Documents/testframe%03d.jpg", counterimg);
cvSaveImage(path, frame);

%03d"将被000"、001"、002"等替换

The "%03d" will be replaced by "000", "001", "002", etc.

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

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