DFace SDK  1.8.5
dface::Mat类 参考

Mat dface内置的图像数据 dface的所有接口只支持dface::Mat(RGB格式) 更多...

#include <mat.h>

Public 类型

enum  {
  PIXEL_CONVERT_SHIFT = 16, PIXEL_FORMAT_MASK = 0x0000ffff, PIXEL_CONVERT_MASK = 0xffff0000, PIXEL_RGB = 1,
  PIXEL_BGR = (1 << 1), PIXEL_GRAY = (1 << 2), PIXEL_RGBA = (1 << 3), PIXEL_RGB2BGR = PIXEL_RGB | (PIXEL_BGR << PIXEL_CONVERT_SHIFT),
  PIXEL_RGB2GRAY = PIXEL_RGB | (PIXEL_GRAY << PIXEL_CONVERT_SHIFT), PIXEL_BGR2RGB = PIXEL_BGR | (PIXEL_RGB << PIXEL_CONVERT_SHIFT), PIXEL_BGR2GRAY = PIXEL_BGR | (PIXEL_GRAY << PIXEL_CONVERT_SHIFT), PIXEL_GRAY2RGB = PIXEL_GRAY | (PIXEL_RGB << PIXEL_CONVERT_SHIFT),
  PIXEL_GRAY2BGR = PIXEL_GRAY | (PIXEL_BGR << PIXEL_CONVERT_SHIFT), PIXEL_RGBA2RGB = PIXEL_RGBA | (PIXEL_RGB << PIXEL_CONVERT_SHIFT), PIXEL_RGBA2BGR = PIXEL_RGBA | (PIXEL_BGR << PIXEL_CONVERT_SHIFT), PIXEL_RGBA2GRAY = PIXEL_RGBA | (PIXEL_GRAY << PIXEL_CONVERT_SHIFT)
}
 

Public 成员函数

 Mat (int w, size_t elemsize=4)
 
 Mat (int w, int h, size_t elemsize=4)
 
 Mat (int w, int h, int c, size_t elemsize=4)
 
 Mat (const Mat &m)
 
 Mat (int w, void *data, size_t elemsize=4)
 
 Mat (int w, int h, void *data, size_t elemsize=4)
 
 Mat (int w, int h, int c, void *data, size_t elemsize=4)
 
Matoperator= (const Mat &m)
 
void fill (float v)
 
template<typename T >
void fill (T v)
 
Mat clone () const
 
Mat reshape (int w) const
 
Mat reshape (int w, int h) const
 
Mat reshape (int w, int h, int c) const
 
void create (int w, size_t elemsize=4)
 
void create (int w, int h, size_t elemsize=4)
 
void create (int w, int h, int c, size_t elemsize=4)
 
void addref ()
 
void release ()
 
bool empty () const
 
size_t total () const
 
Mat channel (int c)
 
const Mat channel (int c) const
 
float * row (int y)
 
const float * row (int y) const
 
template<typename T >
T * row (int y)
 
template<typename T >
const T * row (int y) const
 
template<typename T >
 operator T * ()
 
template<typename T >
 operator const T * () const
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
void to_pixels (unsigned char *pixels, int type) const
 
void to_pixels_resize (unsigned char *pixels, int type, int target_width, int target_height) const
 
void substract_mean_normalize (const float *mean_vals, const float *norm_vals)
 

静态 Public 成员函数

static Mat from_pixels (const unsigned char *pixels, int type, int w, int h)
 
static Mat from_pixels_resize (const unsigned char *pixels, int type, int w, int h, int target_width, int target_height)
 
static Mat from_float16 (const unsigned short *data, int size)
 

Public 属性

void * data
 
int * refcount
 
size_t elemsize
 
int dims
 
int w
 
int h
 
int c
 
size_t cstep
 

详细描述

Mat dface内置的图像数据 dface的所有接口只支持dface::Mat(RGB格式)

成员函数说明

Mat dface::Mat::from_pixels ( const unsigned char *  pixels,
int  type,
int  w,
int  h 
)
inlinestatic

读取图像二进制字节数组,生成dface::Mat数据(DFace C++所有接口只支持RGB格式的dface::Mat格式)

参数
pixels图像字节数组(RGB,RGBD,BGR,GRAY等格式)
type图像转化格式(PIXEL_RGB, PIXEL_BGR, PIXEL_RGBA, PIXEL_RGB2BGR, PIXEL_RGBA2BGR...)
PIXEL_RGB:以RGB格式读取
PIXEL_BGR:BGR格式读取
PIXEL_GRAY:以灰度图格式读取
PIXEL_RGBA:以RGBA格式读取
PIXEL_RGB2BGR:以RGB格式读取并转化为BGR格式 PIXEL_RGB2GRAY:以RGB格式读取并转化为灰度图格式
PIXEL_RGBA2RGB:以RGBA格式读取并转化为RGB格式 PIXEL_RGBA2BGR:以RGBA格式读取,并转化为BGR
其他依次类推,具体可查看 include/dface/Mat.h
w图像宽
h图像高
返回
返回构造好的dface::Mat对象
注解
(DFace C++所有接口只支持BGR的dface::Mat格式,因此其他格式的数据需要用户手动转成标准的RGB)
void dface::Mat::to_pixels ( unsigned char *  pixels,
int  type 
) const
inline

dface::Mat转成图像二进制字节数组

参数
pixels图像字节数组
type图像转化格式(PIXEL_RGB, PIXEL_BGR, PIXEL_RGBA, PIXEL_RGB2BGR, PIXEL_RGBA2BGR...)
PIXEL_RGB:以RGB格式读取
PIXEL_BGR:BGR格式读取
PIXEL_GRAY:以灰度图格式读取
PIXEL_RGBA:以RGBA格式读取
PIXEL_RGB2BGR:以RGB格式读取并转化为BGR格式 PIXEL_RGB2GRAY:以RGB格式读取并转化为灰度图格式
PIXEL_RGBA2RGB:以RGBA格式读取并转化为RGB格式 PIXEL_RGBA2BGR:以RGBA格式读取,并转化为BGR
其他依次类推,具体可查看 include/dface/Mat.h
返回
参考pixels
注解
(转opencv需要先开辟cv::Mat空间) cv::Mat cv_mat = cv::Mat::zeros(w,h,CV_8UC3); dface_mat.to_pixels(cv_mat.data, dface::Mat::PIXEL_BGR)

该类的文档由以下文件生成: