Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 63e95fa

Browse files
committed
Extract ImageResampler from X11Grabber
1 parent fc2faf3 commit 63e95fa

File tree

16 files changed

+541
-369
lines changed

16 files changed

+541
-369
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
5757
# Prefer static linking over dynamic
5858
#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so")
5959

60-
#set(CMAKE_BUILD_TYPE "Debug")
61-
set(CMAKE_BUILD_TYPE "Release")
60+
set(CMAKE_BUILD_TYPE "Debug")
61+
#set(CMAKE_BUILD_TYPE "Release")
6262

6363
# enable C++11
6464
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall")

include/grabber/V4L2Grabber.h

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -11,119 +11,119 @@
1111
// util includes
1212
#include <utils/Image.h>
1313
#include <utils/ColorRgb.h>
14+
#include <utils/PixelFormat.h>
1415
#include <utils/VideoMode.h>
1516

1617
// grabber includes
1718
#include <grabber/VideoStandard.h>
18-
#include <grabber/PixelFormat.h>
1919

2020
/// Capture class for V4L2 devices
2121
///
2222
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
2323
class V4L2Grabber : public QObject
2424
{
25-
Q_OBJECT
25+
Q_OBJECT
2626

2727
public:
28-
V4L2Grabber(const std::string & device,
29-
int input,
30-
VideoStandard videoStandard, PixelFormat pixelFormat,
31-
int width,
32-
int height,
33-
int frameDecimation,
34-
int horizontalPixelDecimation,
35-
int verticalPixelDecimation);
36-
virtual ~V4L2Grabber();
28+
V4L2Grabber(const std::string & device,
29+
int input,
30+
VideoStandard videoStandard, PixelFormat pixelFormat,
31+
int width,
32+
int height,
33+
int frameDecimation,
34+
int horizontalPixelDecimation,
35+
int verticalPixelDecimation);
36+
virtual ~V4L2Grabber();
3737

3838
public slots:
39-
void setCropping(int cropLeft,
40-
int cropRight,
41-
int cropTop,
42-
int cropBottom);
39+
void setCropping(int cropLeft,
40+
int cropRight,
41+
int cropTop,
42+
int cropBottom);
4343

44-
void set3D(VideoMode mode);
44+
void set3D(VideoMode mode);
4545

46-
void setSignalThreshold(double redSignalThreshold,
47-
double greenSignalThreshold,
48-
double blueSignalThreshold,
49-
int noSignalCounterThreshold);
46+
void setSignalThreshold(double redSignalThreshold,
47+
double greenSignalThreshold,
48+
double blueSignalThreshold,
49+
int noSignalCounterThreshold);
5050

51-
void start();
51+
void start();
5252

53-
void stop();
53+
void stop();
5454

5555
signals:
56-
void newFrame(const Image<ColorRgb> & image);
56+
void newFrame(const Image<ColorRgb> & image);
5757

5858
private slots:
59-
int read_frame();
59+
int read_frame();
6060

6161
private:
62-
void open_device();
62+
void open_device();
6363

64-
void close_device();
64+
void close_device();
6565

66-
void init_read(unsigned int buffer_size);
66+
void init_read(unsigned int buffer_size);
6767

68-
void init_mmap();
68+
void init_mmap();
6969

70-
void init_userp(unsigned int buffer_size);
70+
void init_userp(unsigned int buffer_size);
7171

72-
void init_device(VideoStandard videoStandard, int input);
72+
void init_device(VideoStandard videoStandard, int input);
7373

74-
void uninit_device();
74+
void uninit_device();
7575

76-
void start_capturing();
76+
void start_capturing();
7777

78-
void stop_capturing();
78+
void stop_capturing();
7979

80-
bool process_image(const void *p, int size);
80+
bool process_image(const void *p, int size);
8181

82-
void process_image(const uint8_t *p);
82+
void process_image(const uint8_t *p);
8383

84-
int xioctl(int request, void *arg);
84+
int xioctl(int request, void *arg);
8585

86-
void throw_exception(const std::string &error);
86+
void throw_exception(const std::string &error);
8787

88-
void throw_errno_exception(const std::string &error);
88+
void throw_errno_exception(const std::string &error);
8989

9090
private:
91-
enum io_method {
92-
IO_METHOD_READ,
93-
IO_METHOD_MMAP,
94-
IO_METHOD_USERPTR
95-
};
91+
enum io_method {
92+
IO_METHOD_READ,
93+
IO_METHOD_MMAP,
94+
IO_METHOD_USERPTR
95+
};
9696

97-
struct buffer {
98-
void *start;
99-
size_t length;
100-
};
97+
struct buffer {
98+
void *start;
99+
size_t length;
100+
};
101101

102102
private:
103-
const std::string _deviceName;
104-
const io_method _ioMethod;
105-
int _fileDescriptor;
106-
std::vector<buffer> _buffers;
107-
108-
PixelFormat _pixelFormat;
109-
int _width;
110-
int _height;
111-
int _frameByteSize;
112-
int _cropLeft;
113-
int _cropRight;
114-
int _cropTop;
115-
int _cropBottom;
116-
int _frameDecimation;
117-
int _horizontalPixelDecimation;
118-
int _verticalPixelDecimation;
119-
int _noSignalCounterThreshold;
120-
121-
ColorRgb _noSignalThresholdColor;
122-
123-
VideoMode _mode3D;
124-
125-
int _currentFrame;
126-
int _noSignalCounter;
127-
128-
QSocketNotifier * _streamNotifier;
103+
const std::string _deviceName;
104+
const io_method _ioMethod;
105+
int _fileDescriptor;
106+
std::vector<buffer> _buffers;
107+
108+
PixelFormat _pixelFormat;
109+
int _width;
110+
int _height;
111+
int _frameByteSize;
112+
int _cropLeft;
113+
int _cropRight;
114+
int _cropTop;
115+
int _cropBottom;
116+
int _frameDecimation;
117+
int _horizontalPixelDecimation;
118+
int _verticalPixelDecimation;
119+
int _noSignalCounterThreshold;
120+
121+
ColorRgb _noSignalThresholdColor;
122+
123+
VideoMode _mode3D;
124+
125+
int _currentFrame;
126+
int _noSignalCounter;
127+
128+
QSocketNotifier * _streamNotifier;
129129
};

include/grabber/X11Grabber.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Hyperion-utils includes
33
#include <utils/Image.h>
44
#include <utils/ColorRgb.h>
5+
#include <utils/ImageResampler.h>
56

67
// X11 includes
78
#include <X11/Xlib.h>
@@ -10,7 +11,7 @@ class X11Grabber
1011
{
1112
public:
1213

13-
X11Grabber(const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation);
14+
X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation);
1415

1516
virtual ~X11Grabber();
1617

@@ -19,11 +20,12 @@ class X11Grabber
1920
Image<ColorRgb> & grab();
2021

2122
private:
23+
ImageResampler _imageResampler;
2224

23-
const unsigned _pixelDecimation;
24-
25-
const unsigned _cropWidth;
26-
const unsigned _cropHeight;
25+
int _cropLeft;
26+
int _cropRight;
27+
int _cropTop;
28+
int _cropBottom;
2729

2830
/// Reference to the X11 display (nullptr if not opened)
2931
Display * _x11Display;

0 commit comments

Comments
 (0)