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

Commit b8f2bdb

Browse files
committed
add framerate parameter to X11 grabber application
1 parent 46176e5 commit b8f2bdb

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/hyperion-x11/X11Wrapper.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
// Hyperion-X11 includes
33
#include "X11Wrapper.h"
44

5-
X11Wrapper::X11Wrapper(const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation) :
5+
X11Wrapper::X11Wrapper(int grabInterval, const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation) :
66
_timer(this),
77
_grabber(cropHorizontal, cropVertical, pixelDecimation)
88
{
9+
_timer.setSingleShot(false);
10+
_timer.setInterval(grabInterval);
11+
912
// Connect capturing to the timeout signal of the timer
1013
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
1114
}
@@ -18,7 +21,7 @@ const Image<ColorRgb> & X11Wrapper::getScreenshot()
1821

1922
void X11Wrapper::start()
2023
{
21-
_timer.start(100);
24+
_timer.start();
2225
}
2326

2427
void X11Wrapper::stop()

src/hyperion-x11/X11Wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class X11Wrapper : public QObject
99
{
1010
Q_OBJECT
1111
public:
12-
X11Wrapper(const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation);
12+
X11Wrapper(int grabInterval, const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation);
1313

1414
const Image<ColorRgb> & getScreenshot();
1515

src/hyperion-x11/hyperion-x11.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ int main(int argc, char ** argv)
2929
OptionsParser optionParser("X11 capture application for Hyperion");
3030
ParameterSet & parameters = optionParser.getParameters();
3131

32+
IntParameter & argFps = parameters.add<IntParameter> ('f', "framerate", "Cpture frame rate [default=10]");
3233
IntParameter & argCropWidth = parameters.add<IntParameter> (0x0, "crop-width", "Number of pixels to crop from the left and right sides in the picture before decimation [default=0]");
3334
IntParameter & argCropHeight = parameters.add<IntParameter> (0x0, "crop-height", "Number of pixels to crop from the top and the bottom in the picture before decimation [default=0]");
3435
IntParameter & argSizeDecimation = parameters.add<IntParameter> ('s', "size-decimator", "Decimation factor for the output size [default=16]");
@@ -39,6 +40,7 @@ int main(int argc, char ** argv)
3940
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
4041

4142
// set defaults
43+
argFps.setDefault(10);
4244
argCropWidth.setDefault(0);
4345
argCropHeight.setDefault(0);
4446
argSizeDecimation.setDefault(16);
@@ -56,7 +58,8 @@ int main(int argc, char ** argv)
5658
}
5759

5860
// Create the X11 grabbing stuff
59-
X11Wrapper x11Wrapper(argCropWidth.getValue(), argCropHeight.getValue(), argSizeDecimation.getValue());
61+
int grabInterval = 1000 / argFps.getValue();
62+
X11Wrapper x11Wrapper(grabInterval, argCropWidth.getValue(), argCropHeight.getValue(), argSizeDecimation.getValue());
6063

6164
if (argScreenshot.isSet())
6265
{

0 commit comments

Comments
 (0)