mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
- Image format NV12 and I420 added
- Flip mode - Scaling factor for MJPEG - VSCode (compile before run) - CI (push) dependency libjpeg-turbo added
This commit is contained in:
@@ -9,12 +9,13 @@ class ImageResampler
|
||||
{
|
||||
public:
|
||||
ImageResampler();
|
||||
~ImageResampler();
|
||||
~ImageResampler() {}
|
||||
|
||||
void setHorizontalPixelDecimation(int decimator);
|
||||
void setVerticalPixelDecimation(int decimator);
|
||||
void setHorizontalPixelDecimation(int decimator) { _horizontalDecimation = decimator; }
|
||||
void setVerticalPixelDecimation(int decimator) { _verticalDecimation = decimator; }
|
||||
void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
|
||||
void setVideoMode(VideoMode mode);
|
||||
void setVideoMode(VideoMode mode) { _videoMode = mode; }
|
||||
void setFlipMode(FlipMode mode) { _flipMode = mode; }
|
||||
void processImage(const uint8_t * data, int width, int height, int lineLength, PixelFormat pixelFormat, Image<ColorRgb> & outputImage) const;
|
||||
|
||||
private:
|
||||
@@ -25,5 +26,6 @@ private:
|
||||
int _cropTop;
|
||||
int _cropBottom;
|
||||
VideoMode _videoMode;
|
||||
FlipMode _flipMode;
|
||||
};
|
||||
|
||||
|
@@ -12,6 +12,8 @@ enum class PixelFormat {
|
||||
BGR24,
|
||||
RGB32,
|
||||
BGR32,
|
||||
NV12,
|
||||
I420,
|
||||
#ifdef HAVE_JPEG_DECODER
|
||||
MJPEG,
|
||||
#endif
|
||||
@@ -47,6 +49,14 @@ inline PixelFormat parsePixelFormat(const QString& pixelFormat)
|
||||
{
|
||||
return PixelFormat::BGR32;
|
||||
}
|
||||
else if (format.compare("i420") == 0)
|
||||
{
|
||||
return PixelFormat::I420;
|
||||
}
|
||||
else if (format.compare("nv12") == 0)
|
||||
{
|
||||
return PixelFormat::NV12;
|
||||
}
|
||||
#ifdef HAVE_JPEG_DECODER
|
||||
else if (format.compare("mjpeg") == 0)
|
||||
{
|
||||
@@ -63,35 +73,97 @@ inline QString pixelFormatToString(const PixelFormat& pixelFormat)
|
||||
|
||||
if ( pixelFormat == PixelFormat::YUYV)
|
||||
{
|
||||
return "yuyv";
|
||||
return "YUYV";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::UYVY)
|
||||
{
|
||||
return "uyvy";
|
||||
return "UYVY";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::BGR16)
|
||||
{
|
||||
return "bgr16";
|
||||
return "BGR16";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::BGR24)
|
||||
{
|
||||
return "bgr24";
|
||||
return "BGR24";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::RGB32)
|
||||
{
|
||||
return "rgb32";
|
||||
return "RGB32";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::BGR32)
|
||||
{
|
||||
return "bgr32";
|
||||
return "BGR32";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::I420)
|
||||
{
|
||||
return "I420";
|
||||
}
|
||||
else if (pixelFormat == PixelFormat::NV12)
|
||||
{
|
||||
return "NV12";
|
||||
}
|
||||
#ifdef HAVE_JPEG_DECODER
|
||||
else if (pixelFormat == PixelFormat::MJPEG)
|
||||
{
|
||||
return "mjpeg";
|
||||
return "MJPEG";
|
||||
}
|
||||
#endif
|
||||
|
||||
// return the default NO_CHANGE
|
||||
return "NO_CHANGE";
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration of the possible flip modes
|
||||
*/
|
||||
|
||||
enum class FlipMode
|
||||
{
|
||||
HORIZONTAL = 1,
|
||||
VERTICAL = 2,
|
||||
BOTH = HORIZONTAL | VERTICAL,
|
||||
NO_CHANGE = 4
|
||||
};
|
||||
|
||||
inline FlipMode parseFlipMode(const QString& flipMode)
|
||||
{
|
||||
// convert to lower case
|
||||
QString mode = flipMode.toLower();
|
||||
|
||||
if (flipMode.compare("horizontal") == 0)
|
||||
{
|
||||
return FlipMode::HORIZONTAL;
|
||||
}
|
||||
else if (flipMode.compare("vertical") == 0)
|
||||
{
|
||||
return FlipMode::VERTICAL;
|
||||
}
|
||||
else if (flipMode.compare("both") == 0)
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
Reference in New Issue
Block a user