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

Commit 7522d53

Browse files
committed
Merge branch 'add_aml_grabber'
2 parents b5be5f6 + e459cdf commit 7522d53

File tree

16 files changed

+745
-63
lines changed

16 files changed

+745
-63
lines changed

CMakeLists.txt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,40 @@ cmake_minimum_required(VERSION 2.8)
77
#set(CMAKE_TOOLCHAIN_FILE /opt/raspberrypi/Toolchain-RaspberryPi.cmake)
88

99
# set the build options
10+
option(ENABLE_AMLOGIC "Enable the AMLOGIC video grabber" OFF)
11+
message(STATUS "ENABLE_AMLOGIC = " ${ENABLE_AMLOGIC})
12+
1013
option(ENABLE_DISPMANX "Enable the RPi dispmanx grabber" ON)
1114
message(STATUS "ENABLE_DISPMANX = " ${ENABLE_DISPMANX})
1215

16+
option(ENABLE_FB "Enable the framebuffer grabber" OFF)
17+
message(STATUS "ENABLE_FB = " ${ENABLE_FB})
18+
19+
option(ENABLE_OSX "Enable the osx grabber" OFF)
20+
message(STATUS "ENABLE_OSX = " ${ENABLE_OSX})
21+
22+
option(ENABLE_PROTOBUF "Enable PROTOBUF server" ON)
23+
message(STATUS "ENABLE_PROTOBUF = " ${ENABLE_PROTOBUF})
24+
1325
option(ENABLE_SPIDEV "Enable the SPIDEV device" ON)
1426
message(STATUS "ENABLE_SPIDEV = " ${ENABLE_SPIDEV})
1527

16-
option(ENABLE_WS2812BPWM "Enable the WS2812b-PWM device" OFF)
17-
message(STATUS "ENABLE_WS2812BPWM = " ${ENABLE_WS2812BPWM})
28+
option(ENABLE_TINKERFORGE "Enable the TINKERFORGE device" ON)
29+
message(STATUS "ENABLE_TINKERFORGE = " ${ENABLE_TINKERFORGE})
1830

1931
option(ENABLE_V4L2 "Enable the V4L2 grabber" ON)
2032
message(STATUS "ENABLE_V4L2 = " ${ENABLE_V4L2})
2133

34+
option(ENABLE_WS2812BPWM "Enable the WS2812b-PWM device" OFF)
35+
message(STATUS "ENABLE_WS2812BPWM = " ${ENABLE_WS2812BPWM})
36+
2237
option(ENABLE_X11 "Enable the X11 grabber" OFF)
2338
message(STATUS "ENABLE_X11 = " ${ENABLE_X11})
2439

25-
option(ENABLE_TINKERFORGE "Enable the TINKERFORGE device" ON)
26-
message(STATUS "ENABLE_TINKERFORGE = " ${ENABLE_TINKERFORGE})
27-
28-
option(ENABLE_PROTOBUF "Enable PROTOBUF server" ON)
29-
message(STATUS "ENABLE_PROTOBUF = " ${ENABLE_PROTOBUF})
30-
3140
if(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
3241
message(FATAL_ERROR "V4L2 grabber requires PROTOBUF. Disable V4L2 or enable PROTOBUF")
3342
endif(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
3443

35-
option(ENABLE_FB "Enable the framebuffer grabber" OFF)
36-
message(STATUS "ENABLE_FB = " ${ENABLE_FB})
37-
38-
option(ENABLE_OSX "Enable the osx grabber" OFF)
39-
message(STATUS "ENABLE_OSX = " ${ENABLE_OSX})
40-
4144
if(ENABLE_FB AND ENABLE_DISPMANX)
4245
message(FATAL_ERROR "dispmanx grabber and framebuffer grabber cannot be used at the same time")
4346
endif(ENABLE_FB AND ENABLE_DISPMANX)
@@ -89,10 +92,6 @@ find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED QUIET)
8992
find_package(libusb-1.0 REQUIRED)
9093
find_package(Threads REQUIRED)
9194

92-
if (ENABLE_TINKERFORGE)
93-
#find_package(libtinkerforge-1.0 REQUIRED)
94-
endif (ENABLE_TINKERFORGE)
95-
9695
include(${QT_USE_FILE})
9796
add_definitions(${QT_DEFINITIONS})
9897
# TODO[TvdZ]: This linking directory should only be added if we are cross compiling

HyperionConfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
// Define to enable the framebuffer grabber
2222
#cmakedefine ENABLE_FB
2323

24+
// Define to enable the amlogic grabber
25+
#cmakedefine ENABLE_AMLOGIC
26+
2427
// Define to enable the osx grabber
2528
#cmakedefine ENABLE_OSX
2629

include/grabber/AmlogicWrapper.h

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#pragma once
2+
3+
// QT includes
4+
#include <QObject>
5+
#include <QTimer>
6+
7+
// Utils includes
8+
#include <utils/Image.h>
9+
#include <utils/ColorBgr.h>
10+
#include <utils/ColorRgb.h>
11+
#include <utils/GrabbingMode.h>
12+
#include <utils/VideoMode.h>
13+
14+
// Forward class declaration
15+
class AmlogicGrabber;
16+
class Hyperion;
17+
class ImageProcessor;
18+
19+
///
20+
/// The DispmanxWrapper uses an instance of the DispmanxFrameGrabber to obtain ImageRgb's from the
21+
/// displayed content. This ImageRgb is processed to a ColorRgb for each led and commmited to the
22+
/// attached Hyperion.
23+
///
24+
class AmlogicWrapper : public QObject
25+
{
26+
Q_OBJECT
27+
public:
28+
///
29+
/// Constructs the dispmanx frame grabber with a specified grab size and update rate.
30+
///
31+
/// @param[in] grabWidth The width of the grabbed image [pixels]
32+
/// @param[in] grabHeight The height of the grabbed images [pixels]
33+
/// @param[in] updateRate_Hz The image grab rate [Hz]
34+
/// @param[in] hyperion The instance of Hyperion used to write the led values
35+
///
36+
AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, Hyperion * hyperion);
37+
38+
///
39+
/// Destructor of this dispmanx frame grabber. Releases any claimed resources.
40+
///
41+
virtual ~AmlogicWrapper();
42+
43+
public slots:
44+
///
45+
/// Starts the grabber wich produces led values with the specified update rate
46+
///
47+
void start();
48+
49+
///
50+
/// Performs a single frame grab and computes the led-colors
51+
///
52+
void action();
53+
54+
///
55+
/// Stops the grabber
56+
///
57+
void stop();
58+
59+
///
60+
/// Set the grabbing mode
61+
/// @param[in] mode The new grabbing mode
62+
///
63+
void setGrabbingMode(const GrabbingMode mode);
64+
65+
///
66+
/// Set the video mode (2D/3D)
67+
/// @param[in] mode The new video mode
68+
///
69+
void setVideoMode(const VideoMode videoMode);
70+
71+
private:
72+
/// The update rate [Hz]
73+
const int _updateInterval_ms;
74+
/// The timeout of the led colors [ms]
75+
const int _timeout_ms;
76+
/// The priority of the led colors
77+
const int _priority;
78+
79+
/// The timer for generating events with the specified update rate
80+
QTimer _timer;
81+
82+
/// The image used for grabbing frames
83+
Image<ColorBgr> _image;
84+
/// The actual grabber
85+
AmlogicGrabber * _frameGrabber;
86+
/// The processor for transforming images to led colors
87+
ImageProcessor * _processor;
88+
89+
/// The list with computed led colors
90+
std::vector<ColorRgb> _ledColors;
91+
92+
/// Pointer to Hyperion for writing led values
93+
Hyperion * _hyperion;
94+
};

include/utils/ColorBgr.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#pragma once
2+
3+
// STL includes
4+
#include <cstdint>
5+
#include <iostream>
6+
7+
struct ColorBgr;
8+
9+
///
10+
/// Plain-Old-Data structure containing the red-green-blue color specification. Size of the
11+
/// structure is exactly 3-bytes for easy writing to led-device
12+
///
13+
struct ColorBgr
14+
{
15+
/// The blue color channel
16+
uint8_t blue;
17+
/// The green color channel
18+
uint8_t green;
19+
/// The red color channel
20+
uint8_t red;
21+
22+
/// 'Black' RgbColor (0, 0, 0)
23+
static ColorBgr BLACK;
24+
/// 'Red' RgbColor (255, 0, 0)
25+
static ColorBgr RED;
26+
/// 'Green' RgbColor (0, 255, 0)
27+
static ColorBgr GREEN;
28+
/// 'Blue' RgbColor (0, 0, 255)
29+
static ColorBgr BLUE;
30+
/// 'Yellow' RgbColor (255, 255, 0)
31+
static ColorBgr YELLOW;
32+
/// 'White' RgbColor (255, 255, 255)
33+
static ColorBgr WHITE;
34+
};
35+
36+
/// Assert to ensure that the size of the structure is 'only' 3 bytes
37+
static_assert(sizeof(ColorBgr) == 3, "Incorrect size of ColorRgb");
38+
39+
///
40+
/// Stream operator to write ColorRgb to an outputstream (format "'{'[red]','[green]','[blue]'}'")
41+
///
42+
/// @param os The output stream
43+
/// @param color The color to write
44+
/// @return The output stream (with the color written to it)
45+
///
46+
inline std::ostream& operator<<(std::ostream& os, const ColorBgr& color)
47+
{
48+
os << "{" << unsigned(color.red) << "," << unsigned(color.green) << "," << unsigned(color.blue) << "}";
49+
return os;
50+
}
51+
52+
53+
/// Compare operator to check if a color is 'smaller' than another color
54+
inline bool operator<(const ColorBgr & lhs, const ColorBgr & rhs)
55+
{
56+
return (lhs.red < rhs.red) && (lhs.green < rhs.green) && (lhs.blue < rhs.blue);
57+
}
58+
59+
/// Compare operator to check if a color is 'smaller' than or 'equal' to another color
60+
inline bool operator<=(const ColorBgr & lhs, const ColorBgr & rhs)
61+
{
62+
return (lhs.red <= rhs.red) && (lhs.green <= rhs.green) && (lhs.blue <= rhs.blue);
63+
}

libsrc/grabber/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
if (ENABLE_AMLOGIC)
2+
add_subdirectory(amlogic)
3+
endif (ENABLE_AMLOGIC)
4+
15
if (ENABLE_DISPMANX)
26
add_subdirectory(dispmanx)
37
endif (ENABLE_DISPMANX)
@@ -6,14 +10,14 @@ if (ENABLE_FB)
610
add_subdirectory(framebuffer)
711
endif (ENABLE_FB)
812

13+
if (ENABLE_OSX)
14+
add_subdirectory(osx)
15+
endif()
16+
917
if (ENABLE_V4L2)
1018
add_subdirectory(v4l2)
1119
endif (ENABLE_V4L2)
1220

1321
if (ENABLE_X11)
1422
add_subdirectory(x11)
1523
endif()
16-
17-
if (ENABLE_OSX)
18-
add_subdirectory(osx)
19-
endif()

0 commit comments

Comments
 (0)