-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbullet3_adapter.cpp
65 lines (56 loc) · 1.3 KB
/
bullet3_adapter.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "vbropencv_adapter.h"
VBR::VideoAdapter::VideoAdapter()
{
}
VBR::VideoAdapter::~VideoAdapter()
{
close();
}
bool VBR::VideoAdapter::open(const std::string &filename)
{
// ensure that no other video capture object is opened
close();
// create a new video capture object
m_video_capture = std::unique_ptr<cv::VideoCapture>(new cv::VideoCapture(filename));
return is_opened();
}
void VBR::VideoAdapter::close()
{
if (is_opened()) {
// release the video capture object and reset the pointer
m_video_capture->release();
m_video_capture.reset();
}
}
int VBR::VideoAdapter::get_width() const
{
if (is_opened()) {
return m_video_capture->get(cv::CAP_PROP_FRAME_WIDTH);
}
return 0;
}
int VBR::VideoAdapter::get_height() const
{
if (is_opened()) {
return m_video_capture->get(cv::CAP_PROP_FRAME_HEIGHT);
}
return 0;
}
int VBR::VideoAdapter::get_fps() const
{
if (is_opened()) {
return m_video_capture->get(cv::CAP_PROP_FPS);
}
return 0;
}
bool VBR::VideoAdapter::read()
{
if (is_opened()) {
if (m_video_capture->read(m_frame)) {
// Convert from BGR to RGB
cv::cvtColor(m_frame, m_frame, cv::COLOR_BGR2RGB);
return true;
}
}
return false;
}