m0_46066983:
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
*包含预处理数据参数的dict文件
PreprocessParamFileName:='E:/middle report/output_data_512_320/dl_preprocess_param_512_320.hdict'
*检测神经网路的文件
RetrainedModeFileName:='E:/middle report/best_dl_model_detection.hdl'
*设置类名
ClassNames:=['圆']
ClassIDs:=[0]
*推理期间的批大小
BatchSizeInference:=1
*检测模型的后处理参数(不建议更改)
MinConfidence := 0.6
MaxOverlap := 0.2
MaxOverlapClassAgnostic := 0.7
*推理可以在GPU或者CPU上运行
UseGPU := true
if (UseGPU)
get_system ('cuda_loaded', CudaLoaded)
get_system ('cudnn_loaded', CuDNNLoaded)
get_system ('cublas_loaded', CuBlasLoaded)
if (not (CudaLoaded == 'true' and CuDNNLoaded == 'true' and CuBlasLoaded == 'true'))
UseGPU := false
endif
endif
*读取再训练模型
read_dl_model (RetrainedModeFileName, DLModelHandle)
set_dl_model_param (DLModelHandle, 'batch_size', 1)
if (not UseGPU)
set_dl_model_param (DLModelHandle, 'runtime', 'cpu')
endif
set_dl_model_param (DLModelHandle, 'runtime_init', 'immediately')
set_dl_model_param (DLModelHandle, 'min_confidence', MinConfidence)
set_dl_model_param (DLModelHandle, 'max_overlap', MaxOverlap)
set_dl_model_param (DLModelHandle, 'max_overlap_class_agnostic', MaxOverlapClassAgnostic)
*获取用于预处理的参数
read_dict (PreprocessParamFileName, [], [], DLPreprocessParam)
*创建显示结果的窗口字典
create_dict (WindowDict)
create_dict (DLDataInfo)
set_dict_tuple (DLDataInfo, 'class_names', ClassNames)
set_dict_tuple (DLDataInfo, 'class_ids', ClassIDs)
*为可视化设置参数
create_dict (GenParam)
set_dict_tuple (GenParam, 'scale_windows', 1.2)
*读取图像
open_framegrabber ('GigEVision2', 0, 0, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', 'c42f90fba890_Hikvision_MVCA01320GM', 0, -1, AcqHandle)
set_framegrabber_param (AcqHandle, 'TriggerMode', 'Off')
grab_image_start (AcqHandle, -1)
*检测拍照得到的数据
*设置图像大小
zoom_image_size (GrayImage, ImageZoom, 512, 320, 'constant')
dev_display (ImageZoom)
gen_dl_samples_from_images (ImageZoom, DLSampleInference)
preprocess_dl_samples (DLSampleInference, DLPreprocessParam)
apply_dl_model (DLModelHandle, DLSampleInference, [], DLResultBatch)
get_dict_tuple (DLResultBatch,'bbox_row1', BboxRow1)
get_dict_tuple (DLResultBatch,'bbox_col1', BboxCol1)
get_dict_tuple (DLResultBatch,'bbox_row2', BboxRow2)
get_dict_tuple (DLResultBatch,'bbox_col2', BboxCol2)
get_dict_tuple (DLResultBatch,'bbox_class_id', BboxClasses)
tuple_length (BboxCol1, Length)
gen_rectangle1 (Rectangle1, BboxRow1, BboxCol1, BboxRow2, BboxCol2)
sub_image (GrayImage, ImageZoom, ImageSub, 1, 128)
reduce_domain (ImageZoom, Rectangle1, ImageReduced)