如何使用imwrite使用日期和时间命名图像
How to name a image using the date and time using the imwrite?
我真的很想保存多个图像,但我想使用日期和时间作为文件名来命名它。有人可以告诉我如何处理下面的代码:
//Saving Image
Mat save_img; cap >> save_img;
char buffer[20];
char dateStr[20];
char timeStr[20];
_strdate(dateStr);
_strtime(timeStr);
if(save_img.empty())
{
std::cerr << "Something is wrong with the webcam, could not get frame." << std::endl;
}
// Save the frame into a file
sprintf(buffer,"Cap %s%s.jpg",dateStr,timeStr);
imwrite(buffer, save_img); // A JPG FILE IS BEING SAVED
}
上面的代码不会保存任何文件图像,因此它不起作用,但不知何故它被正确编码。跑步时很慢,不知道为什么。这只是我正在处理的代码的一部分。如果您知道如何改进这一点,请发表评论。
我只是遇到了同样的问题,偶然发现了这个Reddit帖子:http://www.reddit.com/r/learnpython/comments/1e4s39/opencv_cant_use_imwrite_dont_understand_error/
因此,为了在文件名中保存带有日期和时间的文件,必须确保从字符串中删除所有":"符号!
std::string filename;
std::replace(filename.begin(), filename.end(), ':', '_');
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 从持续时间构造std::chrono::system_clock::time_point
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- while循环中while循环的时间复杂度是多少
- 使用简单类型列表实现的指数编译时间.为什么
- 是否可以在编译时初始化数组,以便在运行时不会花费时间?
- 从具有不同曝光时间的图像中获取HDR图像
- 图像缝合需要更多时间使用seamfinder和Exposureconsentator
- MF SinkWriter mp4文件的播放持续时间是添加音频样本时的一半,图像的播放速度也是添加音频样本的两倍
- C++ 模板复杂图像读取类执行时间慢,声明和实现分离
- 如何使用imwrite使用日期和时间命名图像
- 在Windows 8.1上使用OpenCV在C++中加载图像需要很长时间
- 根据从两个不同线程获取的时间戳匹配图像
- 用于图像数据采集和时间像素分析的C++库
- 使背景的QLabel png图像透明的设计时间
- 如何在C++中保存带有日期和时间的图像文件名?