grabber api and feature unification (#462)

* move setvideomode to common place

* implement more croping and 3d support

* more api unification

* more refactoring

* osx fix

* next step

* add a mock for osx grabber. Now it is possible to test compile on none osx platforms.

* more unifications ...

* remove obsolete includes and grabbers are not dyn allocated. dispmanx needs rework an probaly not work atm

* first version of dispmanx mock. it compiles, but outputs a black image

* now dispmanx mock works!

* activate mocks in travis linux build
prepare dispmanx to rgb image out

* dispmanx now with image rgb output
fix deadlock with w/h -1 in grabber v4l
cleanups

* fix json

* fix some runtime stuff

* Update FramebufferWrapper.cpp

fix missing code

* unify grabframe

* 3d and croping for amlogic

* fix setimage not working

* make use of templates
save some codelines

* save more code lines
This commit is contained in:
redPanther
2017-08-12 07:55:32 +02:00
committed by GitHub
parent 317a903b14
commit 9eff6384cc
61 changed files with 830 additions and 748 deletions

View File

@@ -52,10 +52,6 @@ AmlogicGrabber::~AmlogicGrabber()
bool AmlogicGrabber::isVideoPlaying()
{
// TODO crop resulting image accroding member _videoMode
// TODO add croping
const QString videoDevice = "/dev/amvideo";
// Open the video device
@@ -81,13 +77,10 @@ bool AmlogicGrabber::isVideoPlaying()
return videoDisabled == 0;
}
int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
int AmlogicGrabber::grabFrame(Image<ColorRgb> & image)
{
// resize the given image if needed
if (image.width() != (unsigned)_width || image.height() != (unsigned)_height)
{
image.resize(_width, _height);
}
// TODO crop resulting image accroding member _videoMode
// TODO add croping
// Make sure video is playing, else there is nothing to grab
if (!isVideoPlaying())
@@ -95,7 +88,6 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
return -1;
}
// If the device is not open, attempt to open it
if (_amlogicCaptureDev == -1)
{
@@ -121,7 +113,7 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
}
// Read the snapshot into the memory
void * image_ptr = image.memptr();
void * image_ptr = _image.memptr();
const ssize_t bytesToRead = _width * _height * sizeof(ColorBgr);
const ssize_t bytesRead = pread(_amlogicCaptureDev, image_ptr, bytesToRead, 0);
@@ -150,5 +142,10 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
_amlogicCaptureDev = -1;
readCnt = 0;
}
_imageResampler.setHorizontalPixelDecimation(_width);
_imageResampler.setVerticalPixelDecimation(_height);
_imageResampler.processImage((const uint8_t*)image_ptr, _width, _height, 3, PIXELFORMAT_BGR24, image);
return 0;
}

View File

@@ -1,53 +1,11 @@
// QT includes
#include <QDateTime>
// Hyperion includes
#include <hyperion/Hyperion.h>
#include <hyperion/ImageProcessorFactory.h>
#include <hyperion/ImageProcessor.h>
// Amlogic grabber includes
#include <grabber/AmlogicWrapper.h>
#include <grabber/AmlogicGrabber.h>
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority)
: GrabberWrapper("AmLogic", priority)
, _updateInterval_ms(1000/updateRate_Hz)
, _timeout_ms(2 * _updateInterval_ms)
, _image(grabWidth, grabHeight)
, _grabber(new AmlogicGrabber(grabWidth, grabHeight))
, _ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0})
{
// Configure the timer to generate events every n milliseconds
_timer.setInterval(_updateInterval_ms);
_processor->setSize(grabWidth, grabHeight);
}
AmlogicWrapper::~AmlogicWrapper()
{
delete _grabber;
}
: GrabberWrapper("AmLogic", &_grabber, grabWidth, grabHeight, updateRate_Hz, priority, hyperion::COMP_GRABBER)
, _grabber(grabWidth, grabHeight)
{}
void AmlogicWrapper::action()
{
// Grab frame into the allocated image
if (_grabber->grabFrame(_image) < 0)
{
// Frame grab failed, maybe nothing playing or ....
return;
}
Image<ColorRgb> image_rgb;
_image.toRgb(image_rgb);
emit emitImage(_priority, image_rgb, _timeout_ms);
_processor->process(_image, _ledColors);
setColors(_ledColors, _timeout_ms);
}
void AmlogicWrapper::setVideoMode(const VideoMode mode)
{
_grabber->setVideoMode(mode);
transferFrame(_grabber);
}