MindSpore数据集mindspore::dataset

谷玉韵
2023-12-01

MindSpore数据集mindspore::dataset
ResizeBilinear
#include <image_process.h>
bool ResizeBilinear(LiteMat &src, LiteMat &dst, int dst_w, int dst_h)
通过双线性算法调整图像大小,当前仅支持的数据类型为uint8,当前支持的通道为3和1。
• 参数
o src: 输入的图片数据。
o dst: 输出的图片数据。
o dst_w: 输出图片数据的宽度。
o dst_h: 输出图片数据的高度。
• 返回值
执行成功返回true,否则不满足条件返回false。
InitFromPixel
#include <image_process.h>
bool InitFromPixel(const unsigned char *data, LPixelType pixel_type, LDataType data_type, int w, int h, LiteMat &m)
从像素初始化LiteMat,提供数据为RGB或者BGR格式,不用进行格式转换,当前支持的转换是RGB_TO_BGR、RGBA_To_RGB、RGBA_To_BGR、NV21_To_BGR和NV12_To_BGR。
• 参数
o data: 输入的数据。
o pixel_type: 像素点的类型。
o data_type: 数据的类型。
o w: 输出数据的宽度。
o h: 输出数据的高度。
o mat: 用于存储图像数据。
• 返回值
初始化成功返回true,否则返回false。
ConvertTo
#include <image_process.h>
bool ConvertTo(LiteMat &src, LiteMat &dst, double scale = 1.0)
转换数据类型,当前支持的转换是将uint8转换为float。
• 参数
o src: 输入的图片数据。
o dst: 输出图像数据。
o scale: 对像素做尺度(默认值为1.0)。
• 返回值
转换数据类型成功返回true,否则返回false。
Crop
#include <image_process.h>
bool Crop(LiteMat &src, LiteMat &dst, int x, int y, int w, int h)
裁剪图像,通道支持为3和1。
• 参数
o src: 输入的图片数据。
o dst: 输出图像数据。
o x: 屏幕截图起点的x坐标值。
o y: 屏幕截图起点的y坐标值。
o w: 截图的宽度。
o h: 截图的高度。
• 返回值
裁剪图像成功返回true,否则返回false。
SubStractMeanNormalize
#include <image_process.h>
bool SubStractMeanNormalize(const LiteMat &src, LiteMat &dst, const std::vector &mean, const std::vector &std)
归一化图像,当前支持的数据类型为float。
• 参数
o src: 输入的图片数据。
o dst: 输出图像数据。
o mean: 数据集的均值。
o std: 数据集的方差。
• 返回值
归一化成功返回true,否则返回false。
Pad
#include <image_process.h>
bool Pad(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int right, PaddBorderType pad_type, uint8_t fill_b_or_gray, uint8_t fill_g, uint8_t fill_r)
填充图像,通道支持为3和1。
• 参数
o src: 输入的图片数据。
o dst: 输出图像数据。
o top: 图片顶部长度。
o bottom: 图片底部长度。
o left: 图片左边长度。
o right: 图片右边长度。
o pad_type: padding的类型。
o fill_b_or_gray: R或者GRAY。
o fill_g: G。
o fill_r: R。
• 返回值
填充图像成功返回true,否则返回false。
ExtractChannel
#include <image_process.h>
bool ExtractChannel(const LiteMat &src, LiteMat &dst, int col)
按索引提取图像通道。
• 参数
o src: 输入的图片数据。
o col: 通道的序号。
• 返回值
提取图像通道成功返回true,否则返回false。
Split
#include <image_process.h>
bool Split(const LiteMat &src, std::vector &mv)
将图像通道拆分为单通道。
• 参数
o src: 输入的图片数据。
o mv: 单个通道数据。
• 返回值
图像通道拆分成功返回true,否则返回false。
Merge
#include <image_process.h>
bool Merge(const std::vector &mv, LiteMat &dst)
用几个单通道阵列创建一个多通道图像。
• 参数
o mv: 单个通道数据。
o dst: 输出图像数据。
• 返回值
创建多通道图像成功返回true,否则返回false。
Affine
#include <image_process.h>
void Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<size_t> dsize, UINT8_C1 borderValue)
对1通道图像应用仿射变换。
• 参数
o src: 输入图片数据。
o out_img: 输出图片数据。
o M[6]: 仿射变换矩阵。
o dsize: 输出图像的大小。
o borderValue: 采图之后用于填充的像素值。
void Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<size_t> dsize, UINT8_C3 borderValue)
#include <image_process.h>
对3通道图像应用仿射变换。
• 参数
o src: 输入图片数据。
o out_img: 输出图片数据。
o M[6]: 仿射变换矩阵。
o dsize: 输出图像的大小。
o borderValue: 采图之后用于填充的像素值。
GetDefaultBoxes
#include <image_process.h>
std::vector<std::vector> GetDefaultBoxes(BoxesConfig config)
获取Faster R-CNN,SSD,YOLO等的默认框。
• 参数
o config: BoxesConfig结构体对象。
• 返回值
返回默认框。
ConvertBoxes
#include <image_process.h>
void ConvertBoxes(std::vector<std::vector> &boxes, std::vector<std::vector> &default_boxes, BoxesConfig config)
将预测框转换为(y,x,h,w)的实际框。
• 参数
o boxes: 实际框的大小。
o default_boxes: 默认框。
o config: BoxesConfig结构体对象。
ApplyNms
#include <image_process.h>
std::vector ApplyNms(std::vector<std::vector> &all_boxes, std::vector &all_scores, float thres, int max_boxes)
对实际框的非极大值抑制。
• 参数
o all_boxes: 所有输入的框。
o all_scores: 通过网络执行后所有框的得分。
o thres: IOU的预值。
o max_boxes: 输出框的最大值。
• 返回值
返回框的id。
LiteMat
#include <lite_mat.h>
LiteMat是一个处理图像的类。
构造函数和析构函数
LiteMat
LiteMat()

LiteMat(int width, LDataType data_type = LDataType::UINT8)

LiteMat(int width, int height, LDataType data_type = LDataType::UINT8)

LiteMat(int width, int height, int channel, LDataType data_type = LDataType::UINT8)
MindSpore中dataset模块下LiteMat的构造方法,使用参数的默认值。
~LiteMat
~LiteMat()
MindSpore dataset LiteMat的析构函数。
公有成员函数
Init
void Init(int width, LDataType data_type = LDataType::UINT8)

void Init(int width, int height, LDataType data_type = LDataType::UINT8)

void Init(int width, int height, int channel, LDataType data_type = LDataType::UINT8)
该函数用于初始化图像的通道,宽度和高度,参数不同。
IsEmpty
bool IsEmpty() const
确定对象是否为空的函数。
• 返回值
返回true或者false。
Release
void Release()
释放内存的函数。
公有属性
data_ptr_
data_ptr_
pointer类型,表示存放图像数据的地址。
elem_size_
elem_size_
int类型,表示元素的字节数。
width_
width_
int类型,表示图像的宽度。
height_
height_
int类型,表示图像的高度。
channel_
channel_
int类型,表示图像的通道数。
c_step_
c_step_
int类型,表示经过对齐后的图像宽高之积。
dims_
dims_
int类型,表示图像的维数。
size_
size_
size_t类型,表示图像占用内存的大小。
data_type_
data_type_
LDataType类型,表示图像的数据类型。
ref_count_
ref_count_
pointer类型,表示引用计数器的地址。
Subtract
#include <lite_mat.h>
bool Subtract(const LiteMat &src_a, const LiteMat &src_b, LiteMat *dst)
计算每个元素的两个图像之间的差异。
• 参数
o src_a: 输入的图像a的数据。
o src_b: 输入的图像b的数据。
o dst: 输出图像的数据。
• 返回值
满足条件的计算返回true,否则返回false。
Divide
#include <lite_mat.h>
bool Divide(const LiteMat &src_a, const LiteMat &src_b, LiteMat *dst)
计算每个元素在两个图像之间的划分。
• 参数
o src_a: 输入的图像a的数据。
o src_b: 输入的图像b的数据。
o dst: 输出图像的数据。
• 返回值
满足条件的计算返回true,否则返回false。
Multiply
#include <lite_mat.h>
bool Multiply(const LiteMat &src_a, const LiteMat &src_b, LiteMat *dst)
计算每个元素在两个图像之间的相乘值。
• 参数
o src_a: 输入的图像a的数据。
o src_b: 输入的图像b的数据。
o dst: 输出图像的数据。
• 返回值
满足条件的计算返回true,否则返回false。

 类似资料: