2017-08-04 23:08:15 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <cstdint>
|
|
|
|
|
2017-08-12 07:55:32 +02:00
|
|
|
#include <utils/ColorRgb.h>
|
2017-08-04 23:08:15 +02:00
|
|
|
#include <utils/Image.h>
|
|
|
|
#include <utils/VideoMode.h>
|
2018-12-27 23:11:32 +01:00
|
|
|
#include <grabber/VideoStandard.h>
|
2017-08-04 23:08:15 +02:00
|
|
|
#include <utils/ImageResampler.h>
|
|
|
|
#include <utils/Logger.h>
|
2019-07-14 22:43:22 +02:00
|
|
|
#include <utils/Components.h>
|
2017-08-04 23:08:15 +02:00
|
|
|
|
2020-06-17 20:55:57 +02:00
|
|
|
#include <QMultiMap>
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
|
|
|
/// @brief The Grabber class is responsible to apply image resizes (with or without ImageResampler)
|
2021-01-31 13:49:31 +01:00
|
|
|
|
2017-08-04 23:08:15 +02:00
|
|
|
class Grabber : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-08-08 23:12:43 +02:00
|
|
|
Grabber(const QString& grabberName = "", int width=0, int height=0, int cropLeft=0, int cropRight=0, int cropTop=0, int cropBottom=0);
|
2017-08-12 07:55:32 +02:00
|
|
|
|
2017-08-04 23:08:15 +02:00
|
|
|
///
|
|
|
|
/// Set the video mode (2D/3D)
|
|
|
|
/// @param[in] mode The new video mode
|
|
|
|
///
|
2017-08-12 07:55:32 +02:00
|
|
|
virtual void setVideoMode(VideoMode mode);
|
2017-08-04 23:08:15 +02:00
|
|
|
|
2021-01-24 12:16:16 +01:00
|
|
|
///
|
|
|
|
/// Apply new flip mode (vertical/horizontal/both)
|
|
|
|
/// @param[in] mode The new flip mode
|
|
|
|
///
|
|
|
|
virtual void setFlipMode(FlipMode mode);
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
|
|
|
/// @brief Apply new crop values, on errors reject the values
|
|
|
|
///
|
2017-08-12 07:55:32 +02:00
|
|
|
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
|
2017-11-22 00:52:55 +01:00
|
|
|
|
2020-06-17 20:55:57 +02:00
|
|
|
///
|
|
|
|
/// @brief Apply new video input (used from v4l)
|
|
|
|
/// @param input device input
|
|
|
|
///
|
|
|
|
virtual bool setInput(int input);
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
|
|
|
/// @brief Apply new width/height values, on errors (collide with cropping) reject the values
|
2019-01-07 18:13:49 +01:00
|
|
|
/// @return True on success else false
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
2018-12-28 18:12:45 +01:00
|
|
|
virtual bool setWidthHeight(int width, int height);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-03-27 23:13:58 +01:00
|
|
|
///
|
|
|
|
/// @brief Apply new framerate (used from v4l)
|
2020-04-17 16:59:20 +02:00
|
|
|
/// @param fps framesPerSecond
|
2020-03-27 23:13:58 +01:00
|
|
|
///
|
|
|
|
virtual bool setFramerate(int fps);
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
2020-08-03 12:31:39 +02:00
|
|
|
/// @brief Apply new pixelDecimation (used from x11, xcb and qt)
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
2020-04-17 16:59:20 +02:00
|
|
|
virtual void setPixelDecimation(int pixelDecimation) {}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Apply new signalThreshold (used from v4l)
|
|
|
|
///
|
|
|
|
virtual void setSignalThreshold(
|
|
|
|
double redSignalThreshold,
|
|
|
|
double greenSignalThreshold,
|
|
|
|
double blueSignalThreshold,
|
2020-04-17 16:59:20 +02:00
|
|
|
int noSignalCounterThreshold = 50) {}
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
|
|
|
/// @brief Apply new SignalDetectionOffset (used from v4l)
|
|
|
|
///
|
|
|
|
virtual void setSignalDetectionOffset(
|
|
|
|
double verticalMin,
|
|
|
|
double horizontalMin,
|
|
|
|
double verticalMax,
|
2020-04-17 16:59:20 +02:00
|
|
|
double horizontalMax) {}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Apply SignalDetectionEnable (used from v4l)
|
|
|
|
///
|
2020-04-17 16:59:20 +02:00
|
|
|
virtual void setSignalDetectionEnable(bool enable) {}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-07-20 20:06:41 +02:00
|
|
|
///
|
|
|
|
/// @brief Apply CecDetectionEnable (used from v4l)
|
|
|
|
///
|
|
|
|
virtual void setCecDetectionEnable(bool enable) {}
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
2021-01-26 20:01:23 +01:00
|
|
|
/// @brief Apply device and videoStandard (used from v4l)
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
2020-04-17 16:59:20 +02:00
|
|
|
virtual void setDeviceVideoStandard(QString device, VideoStandard videoStandard) {}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2021-01-26 20:01:23 +01:00
|
|
|
///
|
|
|
|
/// @brief Apply device (used from MediaFoundation)
|
|
|
|
///
|
|
|
|
virtual bool setDevice(QString device) { return false; }
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
2019-01-06 19:49:56 +01:00
|
|
|
/// @brief Apply display index (used from qt)
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
2020-04-17 16:59:20 +02:00
|
|
|
virtual void setDisplayIndex(int index) {}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Apply path for device (used from framebuffer)
|
|
|
|
///
|
2020-04-17 16:59:20 +02:00
|
|
|
virtual void setDevicePath(const QString& path) {}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief get current resulting height of image (after crop)
|
|
|
|
///
|
2020-04-17 16:59:20 +02:00
|
|
|
virtual int getImageWidth() { return _width; }
|
2017-08-04 23:08:15 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
|
|
|
/// @brief get current resulting width of image (after crop)
|
|
|
|
///
|
2020-04-17 16:59:20 +02:00
|
|
|
virtual int getImageHeight() { return _height; }
|
2017-08-04 23:08:15 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
///
|
|
|
|
/// @brief Prevent the real capture implementation from capturing if disabled
|
|
|
|
///
|
2017-09-01 08:50:37 +02:00
|
|
|
void setEnabled(bool enable);
|
2017-08-04 23:08:15 +02:00
|
|
|
|
2020-04-17 16:59:20 +02:00
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @brief Get a list of all available devices
|
|
|
|
/// @return List of all available devices on success else empty List
|
2020-04-17 16:59:20 +02:00
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
virtual QStringList getDevices() const { return QStringList(); }
|
2020-04-17 16:59:20 +02:00
|
|
|
|
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @brief Get the device name by path
|
2020-04-17 16:59:20 +02:00
|
|
|
/// @param devicePath The device path
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @return The name of the device on success else empty String
|
2020-04-17 16:59:20 +02:00
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
virtual QString getDeviceName(const QString& /*devicePath*/) const { return QString(); }
|
2020-04-17 16:59:20 +02:00
|
|
|
|
2020-06-17 20:55:57 +02:00
|
|
|
///
|
|
|
|
/// @brief Get a name/index pair of supported device inputs
|
|
|
|
/// @param devicePath The device path
|
|
|
|
/// @return multi pair of name/index on success else empty pair
|
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
virtual QMultiMap<QString, int> getDeviceInputs(const QString& /*devicePath*/) const { return {{ "", 0}}; }
|
2020-06-17 20:55:57 +02:00
|
|
|
|
2020-12-18 17:38:21 +01:00
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @brief Get a list of all available device encoding formats depends on device input
|
2020-12-18 17:38:21 +01:00
|
|
|
/// @param devicePath The device path
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @param inputIndex The device input index
|
|
|
|
/// @return List of device encoding formats on success else empty List
|
2020-12-18 17:38:21 +01:00
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
virtual QStringList getAvailableEncodingFormats(const QString& /*devicePath*/, const int& /*deviceInput*/) const { return QStringList(); }
|
2020-12-18 17:38:21 +01:00
|
|
|
|
2020-04-17 16:59:20 +02:00
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @brief Get a list of available device resolutions depends on device input and encoding format
|
2020-04-17 16:59:20 +02:00
|
|
|
/// @param devicePath The device path
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @param inputIndex The device input index
|
|
|
|
/// @param encFormat The device encoding format
|
2020-04-17 16:59:20 +02:00
|
|
|
/// @return List of resolutions on success else empty List
|
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
virtual QStringList getAvailableDeviceResolutions(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/) const { return QStringList(); }
|
2020-04-17 16:59:20 +02:00
|
|
|
|
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @brief Get a list of available device framerates depends on device input, encoding format and resolution
|
2020-04-17 16:59:20 +02:00
|
|
|
/// @param devicePath The device path
|
2021-01-31 13:49:31 +01:00
|
|
|
/// @param inputIndex The device input index
|
|
|
|
/// @param encFormat The device encoding format
|
|
|
|
/// @param width The device width
|
|
|
|
/// @param heigth The device heigth
|
2020-04-17 16:59:20 +02:00
|
|
|
/// @return List of framerates on success else empty List
|
|
|
|
///
|
2021-01-31 13:49:31 +01:00
|
|
|
virtual QStringList getAvailableDeviceFramerates(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/, const unsigned /*width*/, const unsigned /*height*/) const { return QStringList(); }
|
2020-04-17 16:59:20 +02:00
|
|
|
|
2017-08-04 23:08:15 +02:00
|
|
|
protected:
|
|
|
|
ImageResampler _imageResampler;
|
|
|
|
|
2017-08-12 07:55:32 +02:00
|
|
|
bool _useImageResampler;
|
2017-11-22 00:52:55 +01:00
|
|
|
|
2021-01-24 12:16:16 +01:00
|
|
|
/// The selected VideoMode
|
|
|
|
VideoMode _videoMode;
|
|
|
|
|
|
|
|
/// The used Flip Mode
|
|
|
|
FlipMode _flipMode;
|
2017-08-04 23:08:15 +02:00
|
|
|
|
|
|
|
/// With of the captured snapshot [pixels]
|
|
|
|
int _width;
|
2017-11-22 00:52:55 +01:00
|
|
|
|
2017-08-04 23:08:15 +02:00
|
|
|
/// Height of the captured snapshot [pixels]
|
|
|
|
int _height;
|
|
|
|
|
2020-06-17 20:55:57 +02:00
|
|
|
/// frame per second
|
2020-03-27 23:13:58 +01:00
|
|
|
int _fps;
|
|
|
|
|
2020-06-17 20:55:57 +02:00
|
|
|
/// device input
|
|
|
|
int _input;
|
|
|
|
|
|
|
|
/// number of pixels to crop after capturing
|
2017-08-04 23:08:15 +02:00
|
|
|
int _cropLeft, _cropRight, _cropTop, _cropBottom;
|
|
|
|
|
2017-09-01 08:50:37 +02:00
|
|
|
bool _enabled;
|
2017-08-04 23:08:15 +02:00
|
|
|
|
|
|
|
/// logger instance
|
|
|
|
Logger * _log;
|
|
|
|
|
|
|
|
};
|