Reputation: 11
i'm beginner in programming. I do a face detection project (detect a face, record its result, then save it into output file). I rather naming its result with date&time than with "MyVideo". But I dunno how, anyone can help me? Thanks b4.
Here is my code.
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;
}
Upvotes: 1
Views: 101
Reputation: 3307
What you need is to get date and time as a string and then use this string as your file name. One example you can find here: 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;
}
Upvotes: 1