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

Commit d403dea

Browse files
committed
Added tool to create screenshot for amlogic grabber
1 parent fdb9c1c commit d403dea

File tree

3 files changed

+137
-8
lines changed

3 files changed

+137
-8
lines changed

src/CMakeLists.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ add_subdirectory(hyperion-remote)
33

44
# The following clients depend on the protobuf library
55
if(ENABLE_PROTOBUF)
6-
# Add the 'Video 4 Linux' grabber if it is enabled
7-
if(ENABLE_V4L2)
8-
add_subdirectory(hyperion-v4l2)
9-
endif()
6+
if (ENABLE_AMLOGIC)
7+
add_subdirectory(hyperion-aml)
8+
endif()
9+
# Add the 'Video 4 Linux' grabber if it is enabled
10+
if(ENABLE_V4L2)
11+
add_subdirectory(hyperion-v4l2)
12+
endif()
1013

11-
# Add the X11 grabber if it is enabled
12-
if(ENABLE_X11)
13-
add_subdirectory(hyperion-x11)
14-
endif()
14+
# Add the X11 grabber if it is enabled
15+
if(ENABLE_X11)
16+
add_subdirectory(hyperion-x11)
17+
endif()
1518
endif()

src/hyperion-aml/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Configure minimum CMAKE version
2+
cmake_minimum_required(VERSION 2.8)
3+
4+
# Set the project name
5+
project(hyperion-aml)
6+
7+
# find Qt4
8+
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork)
9+
10+
include_directories(
11+
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/protoserver
12+
${QT_INCLUDES}
13+
${PROTOBUF_INCLUDE_DIRS}
14+
)
15+
16+
set(Hyperion_AML_QT_HEADERS
17+
)
18+
19+
set(Hyperion_AML_HEADERS
20+
)
21+
22+
set(Hyperion_AML_SOURCES
23+
hyperion-aml.cpp
24+
)
25+
26+
QT4_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
27+
28+
add_executable(hyperion-amlogic
29+
${Hyperion_AML_HEADERS}
30+
${Hyperion_AML_SOURCES}
31+
${Hyperion_AML_HEADERS_MOC}
32+
)
33+
34+
target_link_libraries(hyperion-amlogic
35+
getoptPlusPlus
36+
blackborder
37+
hyperion-utils
38+
protoserver
39+
amlogic-grabber
40+
pthread
41+
)
42+
43+
qt4_use_modules(hyperion-amlogic
44+
Core
45+
Gui
46+
Network)

src/hyperion-aml/hyperion-aml.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
3+
// QT includes
4+
#include <QCoreApplication>
5+
#include <QImage>
6+
7+
// getoptPlusPLus includes
8+
#include <getoptPlusPlus/getoptpp.h>
9+
10+
#include "../../libsrc/grabber/amlogic/AmlogicGrabber.h"
11+
12+
using namespace vlofgren;
13+
14+
// save the image as screenshot
15+
void saveScreenshot(const char * filename, const Image<ColorRgb> & image)
16+
{
17+
// store as PNG
18+
QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888);
19+
pngImage.save(filename);
20+
}
21+
22+
int main(int argc, char ** argv)
23+
{
24+
QCoreApplication app(argc, argv);
25+
26+
try
27+
{
28+
// create the option parser and initialize all parameters
29+
OptionsParser optionParser("X11 capture application for Hyperion");
30+
ParameterSet & parameters = optionParser.getParameters();
31+
32+
//IntParameter & argFps = parameters.add<IntParameter> ('f', "framerate", "Capture frame rate [default=10]");
33+
IntParameter & argWidth = parameters.add<IntParameter> (0x0, "width", "Width of the captured image [default=128]");
34+
IntParameter & argHeight = parameters.add<IntParameter> (0x0, "height", "Height of the captured image [default=128]");
35+
SwitchParameter<> & argScreenshot = parameters.add<SwitchParameter<>> (0x0, "screenshot", "Take a single screenshot, save it to file and quit");
36+
StringParameter & argAddress = parameters.add<StringParameter> ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]");
37+
IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]");
38+
//SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
39+
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
40+
41+
// set defaults
42+
argWidth.setDefault(64);
43+
argHeight.setDefault(64);
44+
argAddress.setDefault("127.0.0.1:19445");
45+
argPriority.setDefault(800);
46+
47+
// parse all options
48+
optionParser.parse(argc, const_cast<const char **>(argv));
49+
50+
// check if we need to display the usage. exit if we do.
51+
if (argHelp.isSet())
52+
{
53+
optionParser.usage();
54+
return 0;
55+
}
56+
57+
if (argScreenshot.isSet())
58+
{
59+
// Create the grabber
60+
AmlogicGrabber amlGrabber(argWidth.getValue(), argHeight.getValue());
61+
62+
// Capture a single screenshot and finish
63+
Image<ColorRgb> screenshot;
64+
amlGrabber.grabFrame(screenshot);
65+
saveScreenshot("screenshot.png", screenshot);
66+
}
67+
else
68+
{
69+
// TODO[TvdZ]: Implement the proto-client mechanisme
70+
}
71+
72+
}
73+
catch (const std::runtime_error & e)
74+
{
75+
// An error occured. Display error and quit
76+
std::cerr << e.what() << std::endl;
77+
return -1;
78+
}
79+
return 0;
80+
}

0 commit comments

Comments
 (0)