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

Commit f9dc759

Browse files
committed
Fix embedded V4L2 grabber
1 parent 015ff84 commit f9dc759

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

include/utils/Image.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ class Image
1313

1414
typedef Pixel_T pixel_type;
1515

16+
///
17+
/// Default constructor for an image
18+
///
19+
Image() :
20+
Image(1, 1)
21+
{
22+
}
23+
1624
///
1725
/// Constructor for an image with specified width and height
1826
///
@@ -22,8 +30,8 @@ class Image
2230
Image(const unsigned width, const unsigned height) :
2331
_width(width),
2432
_height(height),
25-
_pixels(new Pixel_T[width*height + 1]),
26-
_endOfPixels(_pixels + width*height)
33+
_pixels(new Pixel_T[width * height + 1]),
34+
_endOfPixels(_pixels + width * height)
2735
{
2836
memset(_pixels, 0, (_width*_height+1)*sizeof(Pixel_T));
2937
}
@@ -38,12 +46,24 @@ class Image
3846
Image(const unsigned width, const unsigned height, const Pixel_T background) :
3947
_width(width),
4048
_height(height),
41-
_pixels(new Pixel_T[width*height + 1]),
42-
_endOfPixels(_pixels + width*height)
49+
_pixels(new Pixel_T[width * height + 1]),
50+
_endOfPixels(_pixels + width * height)
4351
{
4452
std::fill(_pixels, _endOfPixels, background);
4553
}
4654

55+
///
56+
/// Copy constructor for an image
57+
///
58+
Image(const Image & other) :
59+
_width(other._width),
60+
_height(other._height),
61+
_pixels(new Pixel_T[other._width * other._height + 1]),
62+
_endOfPixels(_pixels + other._width * other._height)
63+
{
64+
memcpy(_pixels, other._pixels, other._width * other._height * sizeof(Pixel_T));
65+
}
66+
4767
///
4868
/// Destructor
4969
///

libsrc/grabber/v4l2/V4L2Wrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <QMetaType>
2+
13
#include <grabber/V4L2Wrapper.h>
24

35
#include <hyperion/ImageProcessorFactory.h>
@@ -25,6 +27,9 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
2527
_hyperion(hyperion),
2628
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0})
2729
{
30+
// register the image type
31+
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
32+
2833
// connect the new frame signal using a queued connection, because it will be called from a different thread
2934
QObject::connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::QueuedConnection);
3035
}

src/hyperion-v4l2/hyperion-v4l2.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ int main(int argc, char** argv)
3939
setlocale(LC_ALL, "C");
4040
QLocale::setDefault(QLocale::c());
4141

42+
// register the image type to use in signals
43+
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
44+
4245
try
4346
{
4447
// create the option parser and initialize all parameters

0 commit comments

Comments
 (0)