开启左侧

算子write/read_metrology_model的使用

[复制链接]
LBD 发表于 2019-4-13 16:44:20 | 显示全部楼层 |阅读模式
最近在使用2d_metrology的相关算子做量测项目,遇到一个问题,说明如下:
用create_metrology_model创建测量句柄后,用set_metrology_object_param设置相关参数,然后用write_metrology_model保存测量模型到文件中,再用read_metrology_model来读取相关参数,然后用get_metrology_object_param来读取之前设置的相关参数,用来验证之前设置的参数是否正确的保存到文件中,然后发现大多数的参数还是正常保存了,只有'distance_threshold'这个参数,并不是我之前设置的数值,而是默认值3.5,请问是怎么回事,我用的是Halcon12,以下是代码
微信截图_20190413164153.png


 楼主| LBD 发表于 2019-4-15 07:58:43 | 显示全部楼层
没人吗?
 楼主| LBD 发表于 2019-4-15 17:06:51 | 显示全部楼层
求各位大神帮忙解答一下
Criss 发表于 2019-4-16 10:40:41 | 显示全部楼层
亲,麻烦别人给你解决问题能否直接粘贴代码出来?你贴个那个多代码的图片是什么意思?让我们帮你一个一个写出来帮你解决么?
 楼主| LBD 发表于 2019-4-16 17:02:10 | 显示全部楼层
dev_close_window ()
read_image (Point103222116296, 'E:/My Projects/SC/胶路检测/胶宽/图片/样品1/处理图/横向/0/Point1_03-28-18-55-02.499.png')
get_image_size (Point103222116296, Width, Height)
dev_open_window (0, 0, Width/5, Height/5, 'black', WindowHandle)
dev_set_draw ('margin')
dev_set_line_width (1)
dev_set_color ('green')
dev_display (Point103222116296)
*定义测量模型Line1
Line1StartRow:=850
Line1StartColumn:=1025
Line1EndRow:=850
Line1EndColumn:=1375
ShapeParam1:= [Line1StartRow, Line1StartColumn, Line1EndRow, Line1EndColumn]
*定义测量模型Line2
Line2StartRow:=1320
Line2StartColumn:=1025
Line2EndRow:=1320
Line2EndColumn:=1375
ShapeParam2:= [Line2StartRow, Line2StartColumn, Line2EndRow, Line2EndColumn]
*创建测量句柄
create_metrology_model (MetrologyHandle)
set_metrology_model_image_size (MetrologyHandle, Width, Height)
*添加线模型
add_metrology_object_generic (MetrologyHandle, 'line', ShapeParam1, 150, 1, 8, 120, [], [], Index1)
add_metrology_object_generic (MetrologyHandle, 'line', ShapeParam2, 150, 1, 8, 120, [], [], Index2)
*设置参数,这里根据自己需求设置
set_metrology_object_param (MetrologyHandle, 'all', 'measure_distance',5)
set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all')
set_metrology_object_param (MetrologyHandle, Index1, 'measure_transition', 'negative')
set_metrology_object_param (MetrologyHandle, Index2, 'measure_transition', 'positive')
set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'bicubic')
set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7)
set_metrology_object_param (MetrologyHandle, 'all', 'distance_threshold',10)

write_metrology_model (MetrologyHandle, 'C:/Users/Administrator/Desktop/123.mtr')
read_metrology_model ('C:/Users/Administrator/Desktop/123.mtr', MetrologyHandle1)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_length1', length1)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_length2', length2)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_distance_max', distance)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_sigma', sigma)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_threshold', threshold)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_select', select)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_transition', transition)
get_metrology_object_param (MetrologyHandle1, 'all', 'measure_interpolation', interpolation)
get_metrology_object_param (MetrologyHandle1, 'all', 'min_score', score)
get_metrology_object_param (MetrologyHandle1, 'all', 'distance_threshold', distance_threshold_1)
get_metrology_object_param (MetrologyHandle, 'all', 'distance_threshold', distance_threshold)
get_metrology_object_param (MetrologyHandle1, 'all', 'object_params', object_params)
get_metrology_object_param (MetrologyHandle1, 'all', 'object_type', object_type)
 楼主| LBD 发表于 2019-4-16 17:03:21 | 显示全部楼层
OK,我想上面的代码可以满足要求了
 楼主| LBD 发表于 2019-4-17 17:49:20 | 显示全部楼层
我用Halcon18.05也试过,也是这种情况
 楼主| LBD 发表于 2019-4-23 15:16:55 | 显示全部楼层
哎,这是没希望了吗?
绝地武士 发表于 2019-4-23 17:35:07 | 显示全部楼层
LBD 发表于 2019-4-23 15:16
哎,这是没希望了吗?

我试过了,确实是这个样子的,好像根本不能通过write进行写入,读取后就是默认值,楼主可以用其他比如tup单独存储,然后每次调用之前可以读取tup文件再设置属性值!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表