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

Commit 2c55e29

Browse files
committed
- refactored framebuffer grabber to use ImageResampler
- added OsxGrabber for OSX - added binary for imx6 (cubox-i) and updated install script
1 parent c604de9 commit 2c55e29

20 files changed

+513
-89
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,21 @@ endif(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
3535
option(ENABLE_FB "Enable the framebuffer grabber" OFF)
3636
message(STATUS "ENABLE_FB = " ${ENABLE_FB})
3737

38+
option(ENABLE_OSX "Enable the osx grabber" OFF)
39+
message(STATUS "ENABLE_OSX = " ${ENABLE_OSX})
40+
3841
if(ENABLE_FB AND ENABLE_DISPMANX)
3942
message(FATAL_ERROR "dispmanx grabber and framebuffer grabber cannot be used at the same time")
4043
endif(ENABLE_FB AND ENABLE_DISPMANX)
4144

45+
if(ENABLE_FB AND ENABLE_OSX)
46+
message(FATAL_ERROR "osx grabber and framebuffer grabber cannot be used at the same time")
47+
endif(ENABLE_FB AND ENABLE_OSX)
48+
49+
if(ENABLE_OSX AND ENABLE_DISPMANX)
50+
message(FATAL_ERROR "dispmanx grabber and osx grabber cannot be used at the same time")
51+
endif(ENABLE_OSX AND ENABLE_DISPMANX)
52+
4253
# Createt the configuration file
4354
# configure a header file to pass some of the CMake settings
4455
# to the source code
@@ -89,6 +100,10 @@ if(NOT APPLE)
89100
link_directories(${CMAKE_FIND_ROOT_PATH}/lib/arm-linux-gnueabihf)
90101
endif()
91102

103+
if(ENABLE_OSX)
104+
set(CMAKE_EXE_LINKER_FLAGS "-framework CoreGraphics")
105+
endif()
106+
92107
configure_file(bin/install_hyperion.sh ${LIBRARY_OUTPUT_PATH} @ONLY)
93108
configure_file(config/hyperion.config.json ${LIBRARY_OUTPUT_PATH} @ONLY)
94109
configure_file(config/hyperion_x86.config.json ${LIBRARY_OUTPUT_PATH} @ONLY)

CompileHowto.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ cmake ..
2828
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_X11=ON ..
2929
# as an alternative for the dispmanx grabber on non-rpi devices (e.g. cubox-i) you could try the framebuffer grabber
3030
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_FB=ON ..
31+
# for OSX build you need XCode, qt4 libraries and cmake. You can use macport (homebrew might work too) to install them
32+
sudo port install qt4-mac
33+
sudo port install cmake
34+
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_V4L2=OFF -DENABLE_OSX=ON .
3135

3236
# run make to build Hyperion
3337
make

HyperionConfig.h.in

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

24+
// Define to enable the osx grabber
25+
#cmakedefine ENABLE_OSX
26+

bin/install_hyperion.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ IS_XBIAN=`cat /etc/issue | grep XBian | wc -l`
1010
IS_RASPBMC=`cat /etc/issue | grep Raspbmc | wc -l`
1111
IS_OPENELEC=`cat /etc/issue | grep -m 1 OpenELEC | wc -l`
1212

13+
# Find out if its an imx6 device
14+
IS_IMX6=`cat /proc/cpuinfo | grep i.MX6 | wc -l`
15+
1316
# check which init script we should use
1417
USE_INITCTL=`which /sbin/initctl | wc -l`
1518
USE_SERVICE=`which /usr/sbin/service | wc -l`
@@ -34,14 +37,21 @@ fi
3437
echo 'Downloading hyperion'
3538
if [ $IS_OPENELEC -eq 1 ]; then
3639
# OpenELEC has a readonly file system. Use alternative location
40+
if [ $IS_IMX6 -eq 1 ]; then
41+
curl -L --get https://raw.githubusercontent.com/tvdzwan/hyperion/master/deploy/hyperion_imx6.tar.gz | tar -C /storage -xz
42+
else
3743
curl -L --get https://raw.githubusercontent.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz | tar -C /storage -xz
44+
fi
3845
curl -L --get https://raw.githubusercontent.com/tvdzwan/hyperion/master/deploy/hyperion.deps.openelec-rpi.tar.gz | tar -C /storage/hyperion/bin -xz
39-
4046
# modify the default config to have a correct effect path
4147
sed -i 's:/opt:/storage:g' /storage/hyperion/config/hyperion.config.json
48+
else
49+
if [ $IS_IMX6 -eq 1 ]; then
50+
wget https://raw.githubusercontent.com/tvdzwan/hyperion/master/deploy/hyperion_imx6.tar.gz -O - | tar -C /opt -xz
4251
else
4352
wget https://raw.githubusercontent.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz -O - | tar -C /opt -xz
4453
fi
54+
fi
4555

4656
# create links to the binaries
4757
if [ $IS_OPENELEC -ne 1 ]; then
@@ -51,7 +61,7 @@ if [ $IS_OPENELEC -ne 1 ]; then
5161
fi
5262

5363
# create link to the gpio changer (gpio->spi)
54-
if [ $IS_RASPBMC -eq 1 ]; then
64+
if [ $IS_RASPBMC -eq 1 ] && [ $IS_IMX6 -ne 1 ]; then
5565
ln -fs /opt/hyperion/bin/gpio2spi /usr/bin/gpio2spi
5666
fi
5767

deploy/hyperion_imx6.tar.gz

1.04 MB
Binary file not shown.

include/grabber/FramebufferWrapper.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// Utils includes
88
#include <utils/Image.h>
99
#include <utils/ColorRgb.h>
10-
#include <utils/ColorRgba.h>
1110
#include <utils/GrabbingMode.h>
1211
#include <utils/VideoMode.h>
1312

@@ -81,7 +80,7 @@ public slots:
8180
QTimer _timer;
8281

8382
/// The image used for grabbing frames
84-
Image<ColorRgba> _image;
83+
Image<ColorRgb> _image;
8584
/// The actual grabber
8685
FramebufferFrameGrabber * _frameGrabber;
8786
/// The processor for transforming images to led colors

include/grabber/OsxWrapper.h

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

include/utils/PixelFormat.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
enum PixelFormat {
1010
PIXELFORMAT_YUYV,
1111
PIXELFORMAT_UYVY,
12+
PIXELFORMAT_BGR16,
13+
PIXELFORMAT_BGR24,
1214
PIXELFORMAT_RGB32,
1315
PIXELFORMAT_BGR32,
1416
PIXELFORMAT_NO_CHANGE
@@ -27,6 +29,14 @@ inline PixelFormat parsePixelFormat(std::string pixelFormat)
2729
{
2830
return PIXELFORMAT_UYVY;
2931
}
32+
else if (pixelFormat == "bgr16")
33+
{
34+
return PIXELFORMAT_BGR16;
35+
}
36+
else if (pixelFormat == "bgr24")
37+
{
38+
return PIXELFORMAT_BGR24;
39+
}
3040
else if (pixelFormat == "rgb32")
3141
{
3242
return PIXELFORMAT_RGB32;

libsrc/grabber/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ endif (ENABLE_V4L2)
1313
if (ENABLE_X11)
1414
add_subdirectory(x11)
1515
endif()
16+
17+
if (ENABLE_OSX)
18+
add_subdirectory(osx)
19+
endif()

0 commit comments

Comments
 (0)