使用日期和时间命名输出文件
Naming output file with date&time
我是编程初学者。我做了一个人脸检测项目(检测人脸,记录结果,然后将其保存到输出文件中)。我宁愿用日期来命名它的结果;时间比使用"MyVideo"要长。但我不知道怎么做,有人能帮我吗?谢谢b4。
这是我的密码。
void rekamwajah(){
double nBaris = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
double nKolom = cap.get(CV_CAP_PROP_FRAME_WIDTH);
cv::Size frameSize(static_cast<int>(nKolom), static_cast<int>(nBaris));
if (!rekam.isOpened()) //if not intialize the VideoWriter successfully
{
rekam.open ("K:\MyVideo.avi", CV_FOURCC('M','J','P','G'), 20, frameSize, true);
}
bool bSuccess = cap.read(framewarna);
if (!bSuccess) //if not success, break loop
{
MessageBox::Show("ERROR: Cannot read a frame from video file");
return;
}
rekam.write(framewarna); //writer the frame into the file
timer1->Enabled = true;
}
您需要的是将日期和时间作为字符串,然后将此字符串用作文件名。你可以在这里找到一个例子:https://stackoverflow.com/a/16358111/137261
#include <iostream>
#include <iomanip>
#include <ctime>
int main()
{
auto t = std::time(nullptr);
auto tm = *std::localtime(&t);
std::cout << std::put_time(&tm, "%d-%m-%Y %H-%M-%S") << std::endl;
}
相关文章:
- 有没有办法简单地从 GPU 调用多个 cpp 输出文件?
- VI工作室代码错误无法打开输出文件主.exe
- 在代码块中查找输出文件
- 将未签名的字符写入输出文件
- 为什么我的代码不写入输出文件?
- 完成搜索任务时为空输出文件
- 如何将地图<列表<string>、矢量<string>>输出到输出文件?
- 无法在代码块 IDE 中打开输出文件.exe
- C++:更改 IF 语句中的输出文件
- 编译 gsoap 输出文件 (onvif) 时出现问题
- C++击球平均值程序使用输入/输出文件打印名称,平均值,最高/最低平均值时遇到麻烦
- while 循环中的流输出文件() 通常生成空文件
- 如何使用 Docker 访问输出文件
- 提升进程间共享内存删除、权限和输出文件
- 查找素数,然后将质数放入输出文件中
- GDB / C++ - 根据循环条件将多个变量记录到输出文件中
- 带有文件结束函数的 while 循环重复输出文件中的最后一个数字两次
- 我的输出文件未显示解决方案
- 输入文件中的第一个字符是输出文件中的最后一个字符,反之亦然
- C++,我正在尝试创建一个有效的.bmp输出文件