MindSpore数据集mindspore::dataset
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。
總結
以上是生活随笔為你收集整理的MindSpore数据集mindspore::dataset的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MindSpore接口mindspore
- 下一篇: MindSpore API编程概述