Halcon匹配方法

如果图像中物体存在缩放,则不能使用 correlation-based matching方法。

 Shape-based matching should be choosen if occlusions or clutter can not be avoided or if a matching of objects with changing color is applied.

correlation-based matching is suitable for objects with a random and changing texture or for objects with a slightly changing shape.Additionally,correlation-based matching is to be preferred when handing strongly defocused images.

 

 Speed Up Match

  • Restrict Search Space:Depending on the matching approach, this space encompasses not only the two dimensions of the image, but also other parameters like the possible range of scales and orientations or the question of how much of the object must be visible. The more you can restrict the search space, the faster the search will be.
  •  Image pyramid subsample:

Match Result

  To locate objects in images, information like the position and orientation of the searched objects must be returned by the matching. This information is available in different representations, depending on the selected matching approach. That is, for a strict 2D matching the position and orientation are returned separately, i.e., the position consists of a row and a column value and the orientation consists of a single value describing the angle. In contrast, the uncalibrated perspective approaches return the position and orientation together in a projective transformation matrix (2D homography) and the calibrated perspective approaches return them together in a 3D pose. Besides the position and orientation, many approaches return further information like the scale of the found object or information about the quality of the match, which is called score.

基于形状的匹配

不可缩放模板

create_shape_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, Optimization, Metric, Contrast, MinContrast : ModelID)

 create_shape_model_xld(Contours : : NumLevels, AngleStart, AngleExtent, AngleStep, Optimization, Metric, MinContrast : ModelID)

各项同性可缩放模板

create_scaled_shape_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleMin, ScaleMax, ScaleStep, Optimization, Metric, Contrast, MinContrast : ModelID)

 create_scaled_shape_model_xld(Contours : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleMin, ScaleMax, ScaleStep, Optimization, Metric, MinContrast : ModelID)

各向异性可缩放模板

create_aniso_shape_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleRMin, ScaleRMax, ScaleRStep, ScaleCMin, ScaleCMax, ScaleCStep, Optimization, Metric, Contrast, MinContrast : ModelID)

 create_aniso_shape_model_xld(Contours : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleRMin, ScaleRMax, ScaleRStep, ScaleCMin, ScaleCMax, ScaleCStep, Optimization, Metric, MinContrast : ModelID)

可方便的检查创建模板的图像金字塔层数和对比度参数

inspect_shape_model(Image : ModelImages, ModelRegions : NumLevels, Contrast : )

如果通过XLD创建模板,经过第一次匹配后,建议通过set_shape_model_metric()指定模板极性。

 参数

Contrast

传入1个元素时,直接提取边缘

传入2个元素时,表示使用磁滞分割来提取边缘,第一个元素为上阈值,第二个元素为下阈值

传入3个参数时,表示使用磁滞分割来提取边缘,第三个参数表示所提取的边缘的最小长度

Optimization

一些模板包含了太多的像素点,这导致模板过大,增加了执行时间和内存需求

none  不减少像素

point_reduction_low  大约一半点

point_reduction_medium  大约1/3

point_reduction_high  大约1/4

该参数除了可以用来减少像素,还可以用于控制模板的创建方式,来选择是内存优先还是速度优先。

pregeneration  模板预先创建,牺牲内存来换取查找速度

no_pregeneration  在查找时才创建必须数据,占用内存少

通过set_system('pregenerate_shape_models','true'/'false')可以统一设置

MinContrast

MinContrast参数是被查找图片的最小对比度

  If the object’s rotation may vary in the search images you can specify the allowed range in the parameter AngleExtent and the starting angle of this range in the parameter AngleStart (unit: radians). Note that the range of rotation is defined relative to the reference image, i.e., a starting angle of 0 corresponds to the orientation the object has in the reference image. Therefore, to allow rotations up to +/-5 ◦ , e.g.,you should set the starting angle to -rad(5) and the angle extent to rad(10).

查找

find_shape_model(Image : : ModelID, AngleStart, AngleExtent, MinScore, NumMatches, MaxOverlap, SubPixel, NumLevels, Greediness : Row, Column, Angle, Score)

find_shape_models(Image : : ModelIDs, AngleStart, AngleExtent, MinScore, NumMatches, MaxOverlap, SubPixel, NumLevels, Greediness : Row, Column, Angle, Score, Model)    可同时搜寻多个模板

边界处理

set_system('border_shape_models','true')  模板可以部分在ROI外

set_system('border_shape_models','false')  模板必须在ROI内

基于组件的匹配

 基于组件的匹配是形状匹配的扩展算法,只有一个组件会在整个ROI区域搜索,其余组件会根据组件之间的关联关系去小范围搜索。

In contrast to shape-based matching,for component-based matching no scaling in size is possible.

 

create_component_model()

create_trained_component_model()

train_model_components()

find_component_model()

基于灰度的(互相关)匹配

归一化互相关系数匹配(Normalized Cross Correlation Matching,NCC),受光照变换不明显,对于物体有轻微变形,图像模糊、边缘不清晰的图片,图片有文理的情况,使用形状匹配比较困难,而NCC可以解决。

局部变形匹配

 The result of local deformable matching differ from those of other matching approaches.Though it returns also a position and a score,it does not return an orientation or even a scale.Instead, a set of iconic objects can be returned that helps to inspect the deformations of found object instance.Depending on the selected values of ResultType,the following iconic objects are returned:RectifiedInage,VectorField,DeformedContours

 Perspective Deformable Matching

Like shape-based matching, perspective deformable matching extracts contours and matches their shapes against the shapes of previously created models. But in contrast to shape-based matching, also perspectively deformed contours can be found. For the perspective deformable matching, an uncalibrated as well as a calibrated version is provided.

 create_planar_uncalib_deformable_model()

 create_planar_uncalib_deformable_model_xld()

find_planar_uncalib_deformable_model()

 

 create_planar_calib_deformable_model()

 create_planar_calib_deformable_model_xld()

find_planar_calib_deformable_model()

 

get_deformable_model_contours()

projective_trans_contour_xld()

clear_deformable_model()

Descriptor-Based Matching

Similar to the perspective deformable matching, the descriptor-based matching is able to find objects even if they are perspectively deformed. Again, the matching can be applied either for a calibrated camera or for an uncalibrated camera. In contrast to the perspective deformable matching, the template
is not built by the shapes of contours but by a set of so-called interest points. These points are first extracted by a detector and then are described, i.e., classified according to their location and their local gray value neighborhood, by a descriptor.

 

posted @ 2019-08-19 08:50  summer91  阅读(3033)  评论(0编辑  收藏  举报