Cpp-Processing
Classes | Functions
Image Encoding

Utilities for encoding and decoding images in JPEG formats, including handling EXIF metadata. More...

Collaboration diagram for Image Encoding:

Classes

struct  celantur::ExifMetadata
 Structure to manage EXIF metadata for images. This structure encapsulates EXIF data and provides methods to manipulate and retrieve information from it. It is used in conjunction with JPEG encoding and decoding functions to preserve image metadata. More...
 

Functions

std::vector< unsigned char > celantur::jpeg_encode (cv::Mat image, int jpeg_quality=95, std::optional< ExifMetadata > exif_metadata=std::nullopt)
 Encode an image to JPEG format with optional EXIF metadata. This function compresses the input image to JPEG format, allowing specification of JPEG quality and embedding of EXIF metadata if provided. More...
 
cv::Mat celantur::jpeg_decode (const unsigned char *data, size_t size)
 Decode a JPEG image from a byte array. This function takes a byte array containing JPEG-encoded data and decodes it into an OpenCV cv::Mat image. More...
 
cv::Mat celantur::jpeg_decode (std::vector< unsigned char > data)
 Decode a JPEG image from a vector of bytes. More...
 
ExifMetadata celantur::jpeg_get_exif_metadata (const unsigned char *data, size_t size)
 Extract EXIF metadata from a JPEG byte array. This function parses the EXIF metadata from a JPEG image provided as a byte array and returns it as an ExifMetadata object. More...
 
cv::Mat celantur::rotate_image (const cv::Mat &image, int orientation)
 Rotate an image based on EXIF orientation. This function rotates the input image according to the specified EXIF orientation value, ensuring correct display orientation. More...
 

Detailed Description

Utilities for encoding and decoding images in JPEG formats, including handling EXIF metadata.

Function Documentation

◆ jpeg_decode() [1/2]

cv::Mat celantur::jpeg_decode ( const unsigned char *  data,
size_t  size 
)

Decode a JPEG image from a byte array. This function takes a byte array containing JPEG-encoded data and decodes it into an OpenCV cv::Mat image.

Parameters
dataPointer to the byte array containing the JPEG data.
sizeSize of the byte array in bytes.
Returns
Decoded image as a cv::Mat object.

◆ jpeg_decode() [2/2]

cv::Mat celantur::jpeg_decode ( std::vector< unsigned char >  data)

Decode a JPEG image from a vector of bytes.

Parameters
dataA vector of unsigned char containing the JPEG data.
Returns
Decoded image as a cv::Mat object.

References celantur::jpeg_decode().

◆ jpeg_encode()

std::vector< unsigned char > celantur::jpeg_encode ( cv::Mat  image,
int  jpeg_quality = 95,
std::optional< ExifMetadata exif_metadata = std::nullopt 
)

Encode an image to JPEG format with optional EXIF metadata. This function compresses the input image to JPEG format, allowing specification of JPEG quality and embedding of EXIF metadata if provided.

Parameters
imageThe input image as a cv::Mat object.
jpeg_qualityThe quality of the JPEG compression, ranging from 0 to 100 (default is 95). Higher values indicate better quality and larger file size.
exif_metadataOptional ExifMetadata object containing EXIF data to be embedded in the JPEG image. If not provided, no EXIF data will be included.
Returns
A vector of unsigned char containing the JPEG-encoded image data.

References celantur::rotate_image().

◆ jpeg_get_exif_metadata()

ExifMetadata celantur::jpeg_get_exif_metadata ( const unsigned char *  data,
size_t  size 
)

Extract EXIF metadata from a JPEG byte array. This function parses the EXIF metadata from a JPEG image provided as a byte array and returns it as an ExifMetadata object.

Parameters
dataPointer to the byte array containing the JPEG data.
sizeSize of the byte array in bytes.
Returns
An ExifMetadata object containing the extracted EXIF data.

◆ rotate_image()

cv::Mat celantur::rotate_image ( const cv::Mat &  image,
int  orientation 
)

Rotate an image based on EXIF orientation. This function rotates the input image according to the specified EXIF orientation value, ensuring correct display orientation.

Parameters
imageThe input image as a cv::Mat object.
orientationThe EXIF orientation value (1, 3, 6, or 8).
Returns
The rotated image as a cv::Mat object. see also ExifMetadata::get_orientation()