Inspect_gasket_local_deformable.hdev (网上也有相关的)相关例程学习
来源:互联网 发布:虚拟主机绑定域名 编辑:程序博客网 时间:2024/06/13 08:52
Index:.../Applications/Measuring-2D/inspect_gasket_local_deformable.hdev
猛一看就是一个deformable的模板匹配,但里面还有些不同。
首先就是这个变分?模型的建立
* Create variation model
sobel_amp (ModelImage, EdgeAmplitude, 'thin_max_abs', 5)
create_variation_model (425, 410, 'byte', 'direct', VariationModelID)
prepare_direct_variation_model (ModelImage, EdgeAmplitude, VariationModelID, 30, 1.5)
*
从帮助文档看到,create_variation_model一般都是训练一堆图像的,但选择 'direct'时,可以In this case, the variation model can only be trained by specifying the ideal image and the variation image directly withprepare_direct_variation_model.
并且文档最后一句说,为了减小变分模型的大小,先用sobel算子提取下边缘。
prepare_direct_variation_model 这个函数就是让模板和变分模型的句柄建立联系的函数。
然后往下是建立 deformable model。看来又是老一套
* Create locally deformable model
create_local_deformable_model (ModelImage, 'auto', rad(-10), rad(20), 'auto', 0.9, 1.1, 'auto', 0.9, 1.1, 'auto', 'none', 'use_polarity', 'auto', 'auto', [], [], ModelID)
get_deformable_model_contours (ModelContours, ModelID, 1)
area_center (ModelImage, Area, Row, Column)
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_translate (HomMat2DIdentity, Row, Column, HomMat2DTranslate)
affine_trans_contour_xld (ModelContours, ContoursAffinTrans, HomMat2DTranslate)
*
create_local_deformable_model 参数选择都差不多
然后下面是画出来deformable model的样子,用仿射变换。
NumImages := 7
for Index := 1 to NumImages by 1
read_image (Image, 'gasket/gasket_' + Index$'02')
dev_set_window (WindowHandle2)
dev_display (Image)
disp_message (WindowHandle2, 'Search ...', 'window', 12, 12, 'black', 'true')
* Find the model in the search image.
* As result, the rectified image, the respective
* vector field, and the found contours are queried.
count_seconds (S1)
find_local_deformable_model (Image, ImageRectified, VectorField, DeformedContours, ModelID, rad(-10), rad(20), 1, 1, 1, 1, 0.93, 1, 0.7, 0, 0.4, ['image_rectified','vector_field','deformed_contours'], ['deformation_smoothness','expand_border','subpixel'], [Smoothness,0,1], Score, Row, Column)
count_seconds (S2)
接下来就是检测,读取新的图片,然后find_local_deformable_model
再往下又是老东西,gen_warped_mesh_region (VectorField, MeshRegion, Smoothness)画那个全是格的函数
gen_region_contour_xld (DeformedContours, EdgeRegion, 'margin')
dilation_circle (EdgeRegion, RegionDilation, 2 * Smoothness)
intersection (RegionDilation, MeshRegion, RegionIntersection)
*
这就开始不同了,把匹配物品的XLD膨胀然后与生成的格做与运算。其实这些都是为了美观
然后 compare_variation_model (ImageRectified, Region, VariationModelID)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 30, 99999)
count_obj (SelectedRegions, Number)
compare_variation_model 这个是用来找之前用find找到的模板匹配出来的图像与一开始创建的变分模型句柄来比较。
比较结果放在Region里面。(草草草,我忽然发现变分模型比较和一个东西很像,那个东西叫差影法,用来提取仪表刻度的,用变分模型的话,是不是也可以提取刻度呢,比如先做deformable匹配,刻度匹配上了然后把不对的地方变分消去,然后就剩下刻度了可以用来与指针做运算。以后可以试试。)
比较结果做了一些形态学检测,也就是不同面积多于多少的就判定为不ok
- Inspect_gasket_local_deformable.hdev (网上也有相关的)相关例程学习
- Creat_average_shape_model.hdev例程相关学习(一)
- Creat_average_shape_model.hdev例程相关学习(二)
- Creat_average_shape_model.hdev例程相关学习(三)
- decode_bar_code_rectangle2.hdev相关例程学习(解码)
- Creat_average_shape_model.hdev例程相关学习(一)
- find_pads.hdev例程相关学习
- Creat_local_deformable_model_xld.hdev例程相关学习
- Determine_grid_rotation_fft.hdev相关例程学习
- determine_ncc_model_params.hdev相关例程学习
- Find_cocoa_packages_local_deformable.hdev相关例程学习
- Find_mirror_dies.hdev相关例程学习
- find_scratches_bandpass_fft.hdev相关例程学习
- find_surface_model.hdev相关例程学习
- find_text_bottle_label.hdev相关例程学习
- find_text_dongle.hdev相关例程学习
- Fit_primitives_object_model_3d.hdev相关例程学习
- Gray_erosion_subpix.hdev相关例程学习
- UVA120istringstream和deque的用法
- C++实现二叉树相关操作
- 如何找出单链表中的倒数第K个元素
- Just Do It: 学习Sinatra
- 解决PHPCMS添加栏目时报错
- Inspect_gasket_local_deformable.hdev (网上也有相关的)相关例程学习
- android优化bmob聊天组件
- 使用PostThreadMessage向发送线程消息失败的解决方法
- USB驱动开发之mass storage的枚举识别过程
- 让设计深入人心
- hdu 5316 Magician(2015 Multi-University Training Contest 3)
- spring mongodb Criteria中"and"与"andOperator"方法的区别及"$and"如何工作
- iOS开发实现页面间的数据传递
- NYOJ-水池数目