| digiKam Developer Documentation Professional Photo Management with the Power of Open Source

Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
Digikam::QtOpenCVImg Class Reference

## Public Types
enum | MatColorOrder { MCO_BGR , MCO_RGB , MCO_BGRA = MCO_BGR , MCO_RGBA = MCO_RGB , MCO_ARGB , MCO_INVALID }

## Static Public Member Functions
static cv::Mat | image2Mat (const DImg &img, int requiredMatType=CV_8UC(0), MatColorOrder requiredOrder=MCO_BGR)
| Convert DImg to cv::Mat.
static cv::Mat | image2Mat (const QImage &img, int requiredMatType=CV_8UC(0), MatColorOrder requiredOrder=MCO_BGR)
| Convert QImage from cv::Mat.
static cv::Mat | image2Mat_shared (const QImage &img, MatColorOrder *const order=nullptr)
| Convert QImage to/from cv::Mat without data copy.
static QImage | mat2Image (const cv::Mat &mat, MatColorOrder order=MCO_BGR, QImage::Format formatHint=QImage::Format_Invalid)
| Convert cv::Mat to QImage.
static QImage | mat2Image_shared (const cv::Mat &mat, QImage::Format formatHint=QImage::Format_Invalid)
| Convert QImage to cv::Mat without data copy.

## Member Function Documentation

## ◆ image2Mat()

cv::Mat Digikam::QtOpenCVImg::image2Mat | ( | const QImage & | img,
|  | int | requiredMatType = `CV_8UC(0)`,
|  | MatColorOrder | requiredOrder = `MCO_BGR`
| ) |  |
| static

- cv::Mat
  - Supported channels
    - 1 channel
    - 3 channels (B G R), (R G B)
    - 4 channels (B G R A), (R G B A), (A R G B)
  - Supported depth
    - CV_8U [0, 255]
    - CV_16U [0, 65535]
    - CV_32F [0, 1.0]
- QImage
  - All of the formats of QImage are supported.

## ◆ image2Mat_shared()

cv::Mat Digikam::QtOpenCVImg::image2Mat_shared | ( | const QImage & | img,
|  | MatColorOrder *const | order = `nullptr`
| ) |  |
| static

- Supported QImage formats and cv::Mat types are:
  - QImage::Format_Indexed8 <==> CV_8UC1
  - QImage::Format_Alpha8 <==> CV_8UC1
  - QImage::Format_Grayscale8 <==> CV_8UC1
  - QImage::Format_RGB888 <==> CV_8UC3 (R G B)
  - QImage::Format_RGB32 <==> CV_8UC4 (A R G B or B G R A)
  - QImage::Format_ARGB32 <==> CV_8UC4 (A R G B or B G R A)
  - QImage::Format_ARGB32_Premultiplied <==> CV_8UC4 (A R G B or B G R A)
  - QImage::Format_RGBX8888 <==> CV_8UC4 (R G B A)
  - QImage::Format_RGBA8888 <==> CV_8UC4 (R G B A)
  - QImage::Format_RGBA8888_Premultiplied <==> CV_8UC4 (R G B A)
- For QImage::Format_RGB32 ,QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, the color channel order of cv::Mat will be (B G R A) in little endian system or (A R G B) in big endian system.
- User must make sure that the color channels order is the same as the color channels order required by QImage.

## ◆ mat2Image()

QImage Digikam::QtOpenCVImg::mat2Image | ( | const cv::Mat & | mat,
|  | MatColorOrder | order = `MCO_BGR`,
|  | QImage::Format | formatHint = `QImage::Format_Invalid`
| ) |  |
| static

Note
  same support than image2Mat().

## ◆ mat2Image_shared()

QImage Digikam::QtOpenCVImg::mat2Image_shared | ( | const cv::Mat & | mat,
|  | QImage::Format | formatHint = `QImage::Format_Invalid`
| ) |  |
| static

Note
  same support than image2Mat_shared().