-
Notifications
You must be signed in to change notification settings - Fork 2
/
MediaRecorder.cxx
50 lines (42 loc) · 1.1 KB
/
MediaRecorder.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "MediaRecorder.hxx"
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include "ImageRecorder.hxx"
using namespace std;
using namespace cv;
ISentry::MediaRecorder::MediaRecorder()
:enabled(false),last_time(0),seq(0),files_recorded(0)
{
}
void ISentry::MediaRecorder::rescale(const cv::Mat &m,cv::Mat &m_s)
{
if(max_width==-1 || m.cols<=max_width)
{
m_s=m;
return;
}
float scaler = m.cols/max_width;
Size newSize(m.cols/scaler, m.rows/scaler);
cv::resize(m, m_s, newSize, 0, 0, INTER_LINEAR);
}
std::string ISentry::MediaRecorder::getFilename(time_t rawtime)
{
struct tm * timeinfo = localtime (&rawtime);
char buf[80];
if(rawtime==last_time)
{
size_t p = strftime(buf,sizeof(buf),"%Y-%m-%d-%H-%M-%S",timeinfo);
sprintf(buf+p,"-%d.", seq+1);
seq++;
} else
{
strftime(buf,sizeof(buf),"%Y-%m-%d-%H-%M-%S.", timeinfo);
last_time = rawtime;
seq=0;
}
if(dir.empty())
return buf+getExt();
else
return dir+"/"+buf+getExt();
}