-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathheadcapture.cpp
More file actions
41 lines (31 loc) · 969 Bytes
/
headcapture.cpp
File metadata and controls
41 lines (31 loc) · 969 Bytes
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
#include "headcapture.h"
#include <iostream>
// opencv
#include "highgui.h"
//------------------------------------------------------------------------------
HeadCapture::HeadCapture(const unsigned cameraID, const bool convert_to_gray)
: m_convert_to_gray(convert_to_gray)
{
m_head = new cv::VideoCapture(cameraID);
if (!(m_head->isOpened()))
{
std::cout << "[Error] cannot open video file";
}
// Get video information
m_head_width = (int)m_head->get(CV_CAP_PROP_FRAME_WIDTH);
m_head_height = (int)m_head->get(CV_CAP_PROP_FRAME_HEIGHT);
}
//------------------------------------------------------------------------------
HeadCapture::~HeadCapture()
{
delete m_head;
}
//------------------------------------------------------------------------------
cv::Mat HeadCapture::getFrame()
{
*(m_head) >> m_frame;
if(m_convert_to_gray)
cv::cvtColor(m_frame.clone(), m_frame, CV_BGR2GRAY);
cv::flip(m_frame,m_frame,1);
return m_frame;
}