add framerate parameter to X11 grabber application

Former-commit-id: b8f2bdb5c3e376a4505eec46204efe46dce1a6d9
This commit is contained in:
poljvd 2014-12-01 20:24:53 +01:00
parent d89f504d83
commit 0fd25285a6
3 changed files with 10 additions and 4 deletions

View File

@ -2,10 +2,13 @@
// Hyperion-X11 includes
#include "X11Wrapper.h"
X11Wrapper::X11Wrapper(const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation) :
X11Wrapper::X11Wrapper(int grabInterval, const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation) :
_timer(this),
_grabber(cropHorizontal, cropVertical, pixelDecimation)
{
_timer.setSingleShot(false);
_timer.setInterval(grabInterval);
// Connect capturing to the timeout signal of the timer
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
}
@ -18,7 +21,7 @@ const Image<ColorRgb> & X11Wrapper::getScreenshot()
void X11Wrapper::start()
{
_timer.start(100);
_timer.start();
}
void X11Wrapper::stop()

View File

@ -9,7 +9,7 @@ class X11Wrapper : public QObject
{
Q_OBJECT
public:
X11Wrapper(const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation);
X11Wrapper(int grabInterval, const unsigned cropHorizontal, const unsigned cropVertical, const unsigned pixelDecimation);
const Image<ColorRgb> & getScreenshot();

View File

@ -29,6 +29,7 @@ int main(int argc, char ** argv)
OptionsParser optionParser("X11 capture application for Hyperion");
ParameterSet & parameters = optionParser.getParameters();
IntParameter & argFps = parameters.add<IntParameter> ('f', "framerate", "Cpture frame rate [default=10]");
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]");
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]");
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)
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
// set defaults
argFps.setDefault(10);
argCropWidth.setDefault(0);
argCropHeight.setDefault(0);
argSizeDecimation.setDefault(16);
@ -56,7 +58,8 @@ int main(int argc, char ** argv)
}
// Create the X11 grabbing stuff
X11Wrapper x11Wrapper(argCropWidth.getValue(), argCropHeight.getValue(), argSizeDecimation.getValue());
int grabInterval = 1000 / argFps.getValue();
X11Wrapper x11Wrapper(grabInterval, argCropWidth.getValue(), argCropHeight.getValue(), argSizeDecimation.getValue());
if (argScreenshot.isSet())
{