对象检测模型
1.对图像上的特征对象进行矩形框标注类别(轴对齐矩形和自由矩形)
2.调用hdl可得矩形框(轴对齐矩形和自由矩形),类别,置信度
轴对齐矩形
dev_get_window (WindowHandle)
*读取神经网络模型
read_dl_model ('C:/Users/zhang/Desktop/MVTecDLT/hdl调用/对象检测药片轴对齐矩形模型.hdl', DLModelHandle)
*设置模型参数
set_dl_model_param (DLModelHandle, 'runtime', 'cpu')
*获取模型参数
get_dl_model_param(DLModelHandle, 'image_dimensions', ImageDimensions) //获取图像的尺寸224*224*3通道
get_dl_model_param(DLModelHandle, 'class_ids', ClassIDs) //获取ClassIDs,一共5类
get_dl_model_param (DLModelHandle, 'class_names', ClassNames)//获取类别的名字
*获得系统路径
get_system ('example_dir', PathExample)
* Give all folders that contain images.
ImageBaseFolder := PathExample + '/images/food/'
RawImageFolder := ImageBaseFolder + ['apple_braeburn','apple_golden_delicious','apple_topaz','peach','pear']
*读取图像路径的图像到字典里
read_dl_dataset_classification (RawImageFolder, 'last_folder', DLDataset)
*从模型里面获取图像前处理参数到字典里
create_dl_preprocess_param_from_model (DLModelHandle, 'none', 'full_domain', [], [], [], DLPreprocessParam)
*创建一个窗口字典
*读取图像
read_image (Image, 'C:/Users/zhang/Desktop/MVTecDLT/hdl调用/pill_bag/pill_bag_001.png')
*用图像生成一个样本字典
gen_dl_samples_from_images (Image, DLSample)
*对图像的样本字典进行前处理
preprocess_dl_samples (DLSample, DLPreprocessParam)
*对处理后的样本字典送进模型进行推理,得到推理结果
apply_dl_model (DLModelHandle, DLSample, [], DLResult)
* 获取推理数据
* 获取推理数据
get_dict_tuple (DLResult, 'bbox_row1', bbox_row1)
get_dict_tuple (DLResult, 'bbox_col1', bbox_col1)
get_dict_tuple (DLResult, 'bbox_row2', bbox_row2)
get_dict_tuple (DLResult, 'bbox_col2', bbox_col2)
get_dict_tuple (DLResult, 'bbox_class_id', bbox_id)
get_dict_tuple (DLResult, 'bbox_class_name', bbox_name)
get_dict_tuple (DLResult, 'bbox_confidence', bbox_confi)
dev_get_window (WindowHandle1)
dev_set_draw ('margin')
dev_set_line_width (3)
zoom_image_size (Image, ImageZoom, ImageDimensions[0], ImageDimensions[1], 'constant')
gen_rectangle1 (Rectangle, bbox_row1, bbox_col1, bbox_row2, bbox_col2)
自由矩形
dev_get_window (WindowHandle)
*读取神经网络模型
read_dl_model ('C:/Users/zhang/Desktop/MVTecDLT/hdl调用/对象检测螺丝钉自由矩形模型.hdl', DLModelHandle)
*设置模型参数
set_dl_model_param (DLModelHandle, 'runtime', 'cpu')
*获取模型参数
get_dl_model_param(DLModelHandle, 'image_dimensions', ImageDimensions) //获取图像的尺寸224*224*3通道
get_dl_model_param(DLModelHandle, 'class_ids', ClassIDs) //获取ClassIDs,一共5类
get_dl_model_param (DLModelHandle, 'class_names', ClassNames)//获取类别的名字
*从模型里面获取图像前处理参数到字典里
create_dl_preprocess_param_from_model (DLModelHandle, 'none', 'full_domain', [], [], [], DLPreprocessParam)
*读取图像
read_image (Image, 'C:/Users/zhang/Desktop/MVTecDLT/hdl调用/screws/screws_001.png')
*用图像生成一个样本字典
gen_dl_samples_from_images (Image, DLSample)
*对图像的样本字典进行前处理
preprocess_dl_samples (DLSample, DLPreprocessParam)
*对处理后的样本字典送进模型进行推理,得到推理结果
apply_dl_model (DLModelHandle, DLSample, [], DLResult)
* 获取推理数据
get_dict_tuple (DLResult, 'bbox_row', bbox_row)
get_dict_tuple (DLResult, 'bbox_col', bbox_col)
get_dict_tuple (DLResult, 'bbox_length1', bbox_len1)
get_dict_tuple (DLResult, 'bbox_length2', bbox_len2)
get_dict_tuple (DLResult, 'bbox_phi', bbox_phi)
get_dict_tuple (DLResult, 'bbox_class_id', bbox_id)
get_dict_tuple (DLResult, 'bbox_class_name', bbox_name)
get_dict_tuple (DLResult, 'bbox_confidence', bbox_confi)
dev_set_draw ('margin')
zoom_image_size (Image, ImageZoom, 256, 256, 'constant')
gen_rectangle2 (Rectangle, bbox_row, bbox_col, bbox_phi, bbox_len1, bbox_len2)
get_image_size (Image, Width, Height)