add standalone amlogic grabber

fix standalone dispmanx grabber


Former-commit-id: 5ace9bc90a6fe76f5a51ecef95d6e7119d1102db
This commit is contained in:
redpanther 2016-02-24 16:03:21 +01:00
parent 1b6b90df51
commit 2c831c1110
8 changed files with 138 additions and 52 deletions

View File

@ -0,0 +1,38 @@
// Hyperion-AmLogic includes
#include "AmlogicWrapper.h"
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
_timer(this),
_grabber(grabWidth, grabHeight)
{
_timer.setSingleShot(false);
_timer.setInterval(updateRate_Hz);
// Connect capturing to the timeout signal of the timer
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
}
const Image<ColorRgb> & AmlogicWrapper::getScreenshot()
{
capture();
return _screenshot_rgb;
}
void AmlogicWrapper::start()
{
_timer.start();
}
void AmlogicWrapper::stop()
{
_timer.stop();
}
void AmlogicWrapper::capture()
{
_grabber.grabFrame(_screenshot);
_screenshot.toRgb(_screenshot_rgb);
emit sig_screenshot(_screenshot_rgb);
}

View File

@ -0,0 +1,43 @@
// QT includes
#include <QTimer>
// Hyperion-Dispmanx includes
#include <grabber/AmlogicGrabber.h>
class AmlogicWrapper : public QObject
{
Q_OBJECT
public:
AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
const Image<ColorRgb> & getScreenshot();
///
/// Starts the timed capturing of screenshots
///
void start();
void stop();
signals:
void sig_screenshot(const Image<ColorRgb> & screenshot);
private slots:
///
/// Performs a single screenshot capture and publishes the capture screenshot on the screenshot signal.
///
void capture();
private:
/// The QT timer to generate capture-publish events
QTimer _timer;
/// The grabber for creating screenshots
AmlogicGrabber _grabber;
// image buffers
Image<ColorRgb> _screenshot_rgb;
Image<ColorBgr> _screenshot;
};

View File

@ -14,6 +14,7 @@ include_directories(
)
set(Hyperion_AML_QT_HEADERS
AmlogicWrapper.h
)
set(Hyperion_AML_HEADERS
@ -21,12 +22,13 @@ set(Hyperion_AML_HEADERS
set(Hyperion_AML_SOURCES
hyperion-aml.cpp
AmlogicWrapper.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
QT5_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
else(ENABLE_QT5)
QT4_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
QT4_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
endif(ENABLE_QT5)
add_executable(hyperion-amlogic

View File

@ -7,16 +7,16 @@
// getoptPlusPLus includes
#include <getoptPlusPlus/getoptpp.h>
#include <grabber/AmlogicGrabber.h>
#include <protoserver/ProtoConnectionWrapper.h>
#include "AmlogicWrapper.h"
using namespace vlofgren;
// save the image as screenshot
void saveScreenshot(const char * filename, const Image<ColorBgr> & image)
void saveScreenshot(const char * filename, const Image<ColorRgb> & image)
{
// store as PNG
QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888);
pngImage = pngImage.rgbSwapped();
pngImage.save(filename);
}
@ -30,16 +30,17 @@ int main(int argc, char ** argv)
OptionsParser optionParser("X11 capture application for Hyperion");
ParameterSet & parameters = optionParser.getParameters();
//IntParameter & argFps = parameters.add<IntParameter> ('f', "framerate", "Capture frame rate [default=10]");
IntParameter & argFps = parameters.add<IntParameter> ('f', "framerate", "Capture frame rate [default=10]");
IntParameter & argWidth = parameters.add<IntParameter> (0x0, "width", "Width of the captured image [default=128]");
IntParameter & argHeight = parameters.add<IntParameter> (0x0, "height", "Height of the captured image [default=128]");
SwitchParameter<> & argScreenshot = parameters.add<SwitchParameter<>> (0x0, "screenshot", "Take a single screenshot, save it to file and quit");
StringParameter & argAddress = parameters.add<StringParameter> ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]");
IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]");
//SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
// set defaults
argFps.setDefault(10);
argWidth.setDefault(160);
argHeight.setDefault(160);
argAddress.setDefault("127.0.0.1:19445");
@ -57,29 +58,36 @@ int main(int argc, char ** argv)
int width = argWidth.getValue();
int height = argHeight.getValue();
if (width < 160 || height < 60)
if (width < 160 || height < 160)
{
std::cout << "Minimum width and height is 160" << std::endl;
width = std::max(160, width);
height = std::max(160, height);
}
int grabInterval = 1000 / argFps.getValue();
AmlogicWrapper amlWrapper(argWidth.getValue(),argHeight.getValue(),grabInterval);
if (argScreenshot.isSet())
{
// Create the grabber
AmlogicGrabber amlGrabber(width, height);
// Capture a single screenshot and finish
Image<ColorBgr> screenshot;
amlGrabber.grabFrame(screenshot);
const Image<ColorRgb> & screenshot = amlWrapper.getScreenshot();
saveScreenshot("screenshot.png", screenshot);
}
else
{
// TODO[TvdZ]: Implement the proto-client mechanisme
std::cerr << "The PROTO-interface has not been implemented yet" << std::endl;
}
// Create the Proto-connection with hyperiond
ProtoConnectionWrapper protoWrapper(argAddress.getValue(), argPriority.getValue(), 1000, argSkipReply.isSet());
// Connect the screen capturing to the proto processing
QObject::connect(&amlWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &protoWrapper, SLOT(receiveImage(Image<ColorRgb>)));
// Start the capturing
amlWrapper.start();
// Start the application
app.exec();
}
}
catch (const std::runtime_error & e)
{

View File

@ -12,12 +12,7 @@ else(ENABLE_QT5)
endif(ENABLE_QT5)
# Find the BCM-package (VC control)
#find_package(BCM REQUIRED)
SET( BCM_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/dependencies/external/rapsi_vc )
SET( BCM_LIBRARIES "" )
ADD_DEFINITIONS ( -DDISPMANX_DUMMY )
find_package(BCM REQUIRED)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/protoserver

View File

@ -1,5 +1,5 @@
// Hyperion-X11 includes
// Hyperion-Dispmanx includes
#include "DispmanxWrapper.h"
DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :

View File

@ -7,36 +7,36 @@
class DispmanxWrapper : public QObject
{
Q_OBJECT
Q_OBJECT
public:
DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
const Image<ColorRgb> & getScreenshot();
const Image<ColorRgb> & getScreenshot();
///
/// Starts the timed capturing of screenshots
///
void start();
///
/// Starts the timed capturing of screenshots
///
void start();
void stop();
void stop();
signals:
void sig_screenshot(const Image<ColorRgb> & screenshot);
void sig_screenshot(const Image<ColorRgb> & screenshot);
private slots:
///
/// Performs a single screenshot capture and publishes the capture screenshot on the screenshot
/// signal.
///
void capture();
///
/// Performs a single screenshot capture and publishes the capture screenshot on the screenshot
/// signal.
///
void capture();
private:
/// The QT timer to generate capture-publish events
QTimer _timer;
/// The QT timer to generate capture-publish events
QTimer _timer;
/// The grabber for creating screenshots
DispmanxFrameGrabber _grabber;
Image<ColorRgb> _screenshot_rgb;
Image<ColorRgba> _screenshot;
/// The grabber for creating screenshots
DispmanxFrameGrabber _grabber;
Image<ColorRgb> _screenshot_rgb;
Image<ColorRgba> _screenshot;
};

View File

@ -6,7 +6,7 @@
// getoptPlusPLus includes
#include <getoptPlusPlus/getoptpp.h>
#include "protoserver/ProtoConnectionWrapper.h"
#include <protoserver/ProtoConnectionWrapper.h>
#include "DispmanxWrapper.h"
using namespace vlofgren;
@ -81,12 +81,12 @@ int main(int argc, char ** argv)
app.exec();
}
}
catch (const std::runtime_error & e)
{
// An error occured. Display error and quit
std::cerr << e.what() << std::endl;
return -1;
}
catch (const std::runtime_error & e)
{
// An error occured. Display error and quit
std::cerr << e.what() << std::endl;
return -1;
}
return 0;
return 0;
}