2014-03-31 17:36:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
#include <QString>
|
2014-03-31 17:36:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumeration of the possible pixel formats the grabber can be set to
|
|
|
|
*/
|
2020-06-28 23:05:32 +02:00
|
|
|
enum class PixelFormat {
|
|
|
|
YUYV,
|
|
|
|
UYVY,
|
|
|
|
BGR16,
|
|
|
|
BGR24,
|
|
|
|
RGB32,
|
|
|
|
BGR32,
|
2021-01-03 13:30:37 +01:00
|
|
|
NV12,
|
|
|
|
I420,
|
2020-03-27 23:13:58 +01:00
|
|
|
#ifdef HAVE_JPEG_DECODER
|
2020-06-28 23:05:32 +02:00
|
|
|
MJPEG,
|
2019-04-28 19:53:45 +02:00
|
|
|
#endif
|
2020-06-28 23:05:32 +02:00
|
|
|
NO_CHANGE
|
2014-03-31 17:36:36 +02:00
|
|
|
};
|
|
|
|
|
2020-08-08 23:12:43 +02:00
|
|
|
inline PixelFormat parsePixelFormat(const QString& pixelFormat)
|
2014-03-31 17:36:36 +02:00
|
|
|
{
|
|
|
|
// convert to lower case
|
2020-08-08 23:12:43 +02:00
|
|
|
QString format = pixelFormat.toLower();
|
2014-03-31 17:36:36 +02:00
|
|
|
|
2020-12-18 17:38:21 +01:00
|
|
|
if (format.compare("yuyv") == 0)
|
2014-03-31 17:36:36 +02:00
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::YUYV;
|
2014-03-31 17:36:36 +02:00
|
|
|
}
|
2020-12-18 17:38:21 +01:00
|
|
|
else if (format.compare("uyvy") == 0)
|
2014-03-31 17:36:36 +02:00
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::UYVY;
|
2014-03-31 17:36:36 +02:00
|
|
|
}
|
2020-12-18 17:38:21 +01:00
|
|
|
else if (format.compare("bgr16") == 0)
|
2016-05-26 23:44:27 +02:00
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::BGR16;
|
2016-05-26 23:44:27 +02:00
|
|
|
}
|
2020-12-18 17:38:21 +01:00
|
|
|
else if (format.compare("bgr24") == 0)
|
2016-05-26 23:44:27 +02:00
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::BGR24;
|
2016-05-26 23:44:27 +02:00
|
|
|
}
|
2020-12-18 17:38:21 +01:00
|
|
|
else if (format.compare("rgb32") == 0)
|
2016-05-26 23:44:27 +02:00
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::RGB32;
|
2016-05-26 23:44:27 +02:00
|
|
|
}
|
2020-12-18 17:38:21 +01:00
|
|
|
else if (format.compare("bgr32") == 0)
|
2016-05-26 23:44:27 +02:00
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::BGR32;
|
2016-05-26 23:44:27 +02:00
|
|
|
}
|
2021-01-03 13:30:37 +01:00
|
|
|
else if (format.compare("i420") == 0)
|
|
|
|
{
|
|
|
|
return PixelFormat::I420;
|
|
|
|
}
|
|
|
|
else if (format.compare("nv12") == 0)
|
|
|
|
{
|
|
|
|
return PixelFormat::NV12;
|
|
|
|
}
|
2020-03-27 23:13:58 +01:00
|
|
|
#ifdef HAVE_JPEG_DECODER
|
2020-12-18 17:38:21 +01:00
|
|
|
else if (format.compare("mjpeg") == 0)
|
2019-04-28 19:53:45 +02:00
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::MJPEG;
|
2019-04-28 19:53:45 +02:00
|
|
|
}
|
|
|
|
#endif
|
2014-03-31 17:36:36 +02:00
|
|
|
|
|
|
|
// return the default NO_CHANGE
|
2020-06-28 23:05:32 +02:00
|
|
|
return PixelFormat::NO_CHANGE;
|
2014-03-31 17:36:36 +02:00
|
|
|
}
|
2020-12-18 17:38:21 +01:00
|
|
|
|
|
|
|
inline QString pixelFormatToString(const PixelFormat& pixelFormat)
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( pixelFormat == PixelFormat::YUYV)
|
|
|
|
{
|
2021-01-03 13:30:37 +01:00
|
|
|
return "YUYV";
|
2020-12-18 17:38:21 +01:00
|
|
|
}
|
|
|
|
else if (pixelFormat == PixelFormat::UYVY)
|
|
|
|
{
|
2021-01-03 13:30:37 +01:00
|
|
|
return "UYVY";
|
2020-12-18 17:38:21 +01:00
|
|
|
}
|
|
|
|
else if (pixelFormat == PixelFormat::BGR16)
|
|
|
|
{
|
2021-01-03 13:30:37 +01:00
|
|
|
return "BGR16";
|
2020-12-18 17:38:21 +01:00
|
|
|
}
|
|
|
|
else if (pixelFormat == PixelFormat::BGR24)
|
|
|
|
{
|
2021-01-03 13:30:37 +01:00
|
|
|
return "BGR24";
|
2020-12-18 17:38:21 +01:00
|
|
|
}
|
|
|
|
else if (pixelFormat == PixelFormat::RGB32)
|
|
|
|
{
|
2021-01-03 13:30:37 +01:00
|
|
|
return "RGB32";
|
2020-12-18 17:38:21 +01:00
|
|
|
}
|
|
|
|
else if (pixelFormat == PixelFormat::BGR32)
|
|
|
|
{
|
2021-01-03 13:30:37 +01:00
|
|
|
return "BGR32";
|
|
|
|
}
|
|
|
|
else if (pixelFormat == PixelFormat::I420)
|
|
|
|
{
|
|
|
|
return "I420";
|
|
|
|
}
|
|
|
|
else if (pixelFormat == PixelFormat::NV12)
|
|
|
|
{
|
|
|
|
return "NV12";
|
2020-12-18 17:38:21 +01:00
|
|
|
}
|
|
|
|
#ifdef HAVE_JPEG_DECODER
|
|
|
|
else if (pixelFormat == PixelFormat::MJPEG)
|
|
|
|
{
|
2021-01-03 13:30:37 +01:00
|
|
|
return "MJPEG";
|
2020-12-18 17:38:21 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// return the default NO_CHANGE
|
|
|
|
return "NO_CHANGE";
|
|
|
|
}
|
2021-01-03 13:30:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumeration of the possible flip modes
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum class FlipMode
|
|
|
|
{
|
2021-01-24 12:16:16 +01:00
|
|
|
HORIZONTAL,
|
|
|
|
VERTICAL,
|
|
|
|
BOTH,
|
|
|
|
NO_CHANGE
|
2021-01-03 13:30:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline FlipMode parseFlipMode(const QString& flipMode)
|
|
|
|
{
|
|
|
|
// convert to lower case
|
|
|
|
QString mode = flipMode.toLower();
|
|
|
|
|
2021-01-24 12:16:16 +01:00
|
|
|
if (mode.compare("horizontal") == 0)
|
2021-01-03 13:30:37 +01:00
|
|
|
{
|
|
|
|
return FlipMode::HORIZONTAL;
|
|
|
|
}
|
2021-01-24 12:16:16 +01:00
|
|
|
else if (mode.compare("vertical") == 0)
|
2021-01-03 13:30:37 +01:00
|
|
|
{
|
|
|
|
return FlipMode::VERTICAL;
|
|
|
|
}
|
2021-01-24 12:16:16 +01:00
|
|
|
else if (mode.compare("both") == 0)
|
2021-01-03 13:30:37 +01:00
|
|
|
{
|
|
|
|
return FlipMode::BOTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return the default NO_CHANGE
|
|
|
|
return FlipMode::NO_CHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QString flipModeToString(const FlipMode& flipMode)
|
|
|
|
{
|
|
|
|
if ( flipMode == FlipMode::HORIZONTAL)
|
|
|
|
{
|
|
|
|
return "horizontal";
|
|
|
|
}
|
|
|
|
else if (flipMode == FlipMode::VERTICAL)
|
|
|
|
{
|
|
|
|
return "vertical";
|
|
|
|
}
|
|
|
|
else if (flipMode == FlipMode::BOTH)
|
|
|
|
{
|
|
|
|
return "both";
|
|
|
|
}
|
|
|
|
|
|
|
|
// return the default NO_CHANGE
|
|
|
|
return "NO_CHANGE";
|
|
|
|
}
|