| Table of Contents / Matching / Deformable | Operators |
create_planar_uncalib_deformable_model — Creates a deformable model for uncalibrated, perspective matching.
create_planar_uncalib_deformable_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleRMin, ScaleRMax, ScaleRStep, ScaleCMin, ScaleCMax, ScaleCStep, Optimization, Metric, Contrast, MinContrast, ParamName, ParamValue : ModelID)
The operator create_planar_uncalib_deformable_model prepares a template, which is passed in the image Template, as a deformable model used for uncalibrated perspective matching. The ROI of the model is passed as the domain of Template.
The planar uncalibrated matching can be used to detect planar objects or planar subparts of non-planar objects that are distorted by a projective view.
This is an alternative to create_shape_model, create_scaled_shape_model and create_aniso_shape_model, where typically the search image must be rectified by calibrate_cameras and gen_image_to_world_plane_map beforehand.
In contrast to create_shape_model_3d there is no need to pre-generate different views of an object, resulting into a smaller memory consumption. Hence, in case of a planar perspectively distorted object, create_planar_uncalib_deformable_model should be prefered.
The model is generated using multiple image pyramid levels and is stored in memory. The output parameter ModelID is a handle for this model, which is used in subsequent calls to find_planar_uncalib_deformable_model.
The number of pyramid levels is determined with the parameter NumLevels. It should be chosen as large as possible because by this the time necessary to find the object is significantly reduced. On the other hand, NumLevels must be chosen such that the model is still recognizable and contains a sufficient number of points on the highest pyramid level. If not enough model points are generated, the number of pyramid levels is reduced internally until enough model points are found on the highest pyramid level. If this procedure would lead to a model with no pyramid levels, i.e., if the number of model points is already too small on the lowest pyramid level, create_planar_uncalib_deformable_model returns with an error message. If NumLevels is set to 'auto', create_planar_uncalib_deformable_model determines the number of pyramid levels automatically. The automatically computed number of pyramid levels can be queried using get_deformable_model_params. In rare cases, it might happen that create_planar_uncalib_deformable_model determines a value for the number of pyramid levels that is too large or too small. If the number of pyramid levels is chosen too large, the model may not be recognized in the image or it may be necessary to select very low parameters for MinScore or Greediness in find_planar_uncalib_deformable_model in order to find the model. If the number of pyramid levels is chosen too small, the time required to find the model in find_planar_uncalib_deformable_model increases. In these cases, the number of pyramid levels should be selected using the output of inspect_shape_model.
The range parameters AngleStart, AngleExtent, ScaleRMin, ScaleRMax, ScaleCMin and ScaleCMax are used to specify a basic range of up to an anisotropic transformation that is exhaustively searched on the top level of the image pyramid. Note that the operator find_planar_uncalib_deformable_model finds objects outside this range, e.g., even when the object is perspectively distorted. Hence, the range parameters are a kind of suggestion for the search algorithm find_planar_uncalib_deformable_model, and starting from there a certain bigger range can be detected that depends on the pyramid levels that are used and on the model/image content. It is important to note that, e.g., small scale changes can be tolerated without the need to specify a scale range, leading to faster execution times.
The parameters AngleStart and AngleExtent determine the range of possible rotations, in which the model is exhaustively searched in the image. The parameter AngleStep determines the step length within the selected range of angles. AngleStep should be chosen based on the size of the object. Smaller models do not have many different discrete rotations in the image, and hence AngleStep should be chosen larger for smaller models. If AngleExtent is not an integer multiple of AngleStep, AngleStep is modified accordingly.
The parameters ScaleRMin, ScaleRMax, ScaleCMin, and ScaleCMax determine the range of possible anisotropic scales that are exhaustively searched in the image. A scale of 1 in both scale factors corresponds to the original size of the model. The parameters ScaleRStep and ScaleCStep determine the step length within the selected range of scales. Like AngleStep, ScaleRStep and ScaleCStep should be chosen based on the size of the object. If the respective range of scales is not an integer multiple of ScaleRStep and ScaleCStep, ScaleRStep and ScaleCStep are modified accordingly.
If the object is expected to have significant scale changes, but only small perspective distortions, isotropic scaling is required and ScaleCMin and ScaleCMax should be both set to the value 1.0 to signal that no anisotropic scaling is needed. If the object should be detected despite severe perspective distortions anisotropic scaling is required. Here, ScaleRMin and ScaleRMax specify the anisotropic scaling in row, ScaleCMin and ScaleCMax in column direction.
Note that the transformations are treated internally such that the scalings are applied first, followed by the rotation. Therefore, the model should usually be aligned such that it appears horizontally or vertically in the model image.
For particularly large models, it may be useful to reduce the number of model points by setting Optimization to a value different from 'none'. If Optimization = 'none', all model points are stored. In all other cases, the number of points is reduced according to the value of Optimization. If the number of points is reduced, it may be necessary in find_planar_uncalib_deformable_model to set the parameter Score and Greediness to a smaller value. For small models, the reduction of the number of model points does not result in a speed-up of the search because in this case usually significantly more potential instances of the model must be examined. If Optimization is set to 'auto', create_planar_uncalib_deformable_model automatically determines the reduction of the number of model points.
The parameter Contrast determines the contrast the model points (edges) must have. The contrast is a measure for local gray value differences between the object and the background and between different parts of the object. Contrast should be chosen such that only the significant features of the template are used for the model. Contrast can also contain a tuple with two values. In this case, the model is segmented using a method similar to the hysteresis threshold method used in edges_image. Here, the first element of the tuple determines the lower threshold, while the second element determines the upper threshold. For more information about the hysteresis threshold method, see hysteresis_threshold. If Contrast is set to 'auto', create_planar_uncalib_deformable_model determines the two above described values automatically. Alternatively, only the contrast ('auto_contrast') or the hysteresis thresholds ('auto_contrast_hyst') can be determined automatically. The remaining values that are not determined automatically can additionally be passed in the form of a tuple. In certain cases, it might happen that the automatic determination of the contrast thresholds is not satisfying. For example, a manual setting of these parameters should be preferred if certain model components should be included or suppressed because of application-specific reasons or if the object contains several different contrasts. Therefore, the contrast thresholds should be automatically determined with determine_deformable_model_params and subsequently verified using inspect_shape_model before calling create_planar_uncalib_deformable_model.
With MinContrast, it can be determined which minimal contrast the model must have in the recognition performed by find_planar_uncalib_deformable_model. In other words, this parameter separates the model from the noise in the image. Therefore, a good choice is the range of gray value changes caused by the noise in the image. If, for example, the gray values fluctuate within a range of 10 gray levels, MinContrast should be set to 10. Obviously, MinContrast must be smaller than Contrast. If the model should be recognized in very low contrast images, MinContrast must be set to a correspondingly small value. If the model should be recognized even if it is severely occluded, MinContrast should be slightly larger than the range of gray value fluctuations created by noise in order to ensure that the position and rotation of the model are extracted robustly and accurately by find_planar_uncalib_deformable_model. If MinContrast is set to 'auto', the minimum contrast is determined automatically based on the noise in the model image. Consequently, an automatic determination only makes sense if the image noise during the recognition is similar to the noise in the model image. Furthermore, in some cases it is advisable to increase the automatically determined value in order to increase the robustness against occlusions (see above). The automatically computed minimum contrast can be queried using get_deformable_model_params. The MinContrast of a deformable model can later be changed with the help of set_deformable_model_param.
The parameter Metric determines the conditions under which the model is recognized in the image. If Metric = 'use_polarity', the object in the image and the model must have the same contrast. If, for example, the model is a bright object on a dark background, the object is found only if it is also brighter than the background. If Metric = 'ignore_global_polarity', the object is found in the image also if the contrast reverses globally. In the above example, the object hence is also found if it is darker than the background. The runtime of find_planar_uncalib_deformable_model will increase slightly in this case. If Metric = 'ignore_part_polarity', the the contrast polarity is allowed to change only between different parts of the model, whereas the polarity of model points that are within the same model part must not change. Please note that the term 'ignore_part_polarity' is capable of being misunderstood. It means that polarity changes between neighboring model parts do not influence the score, and hence are ignored. If Metric = 'ignore_local_polarity', the model is found even if the contrast changes for each individual model point. This mode can, for example, be useful if the object consists of a part with medium gray value, within which either darker or brighter sub-objects lie. In this case the runtime of find_planar_uncalib_deformable_model increases significantly. The above four metrics can only be applied to single-channel images. If a multichannel image is used as the model image or as the search image only the first channel will be used (and no error message will be returned). If Metric = 'ignore_color_polarity', the model is found even if the color contrast changes locally. This is, for example, the case if parts of the object can change their color, e.g., from red to green. In particular, this mode is useful if it is not known in advance in which channels the object is visible. In this mode, the runtime of find_planar_uncalib_deformable_model can also increase significantly. The metric 'ignore_color_polarity' can be used for images with an arbitrary number of channels. If it is used for single-channel images it has the same effect as 'ignore_local_polarity'. It should be noted that for Metric = 'ignore_color_polarity' the number of channels in the model creation with create_planar_uncalib_deformable_model and in the search with find_planar_uncalib_deformable_model can be different. This can, for example, be used to create a model from a synthetically generated single-channel image. Furthermore, it should be noted that the channels do not need to contain a spectral subdivision of the light (like in an RGB image). The channels can, for example, also contain images of the same object that were obtained by illuminating the object from different directions.
With the help of the generic parameters ParamName and ParamValue, the user can set parameters for the deformable model generation that are needed only in rare cases. Currently, it is used to adapt the average size of the sub-parts that the deformable model should consist of. Here, ParamName should be set to 'part_size' and ParamValue should be set to 'small', 'medium' or 'big'. For objects that consist of many small contours, 'small' should be selected. For objects that consist of only big contours, 'big' should be set. Optionally, ParamName = 'min_size' can determine a threshold for the selection of significant model components based on the size of the components, i.e., components that have fewer points than the minimum size specified in the corresponding ParamValue are suppressed. This threshold for the minimum size is divided by two for each successive pyramid level. The center of gravity of the domain (region) of the model image Template is used as the origin (reference point) of the model. A different origin for the model can be set with set_deformable_model_origin.
Input image whose domain will be used to create the model.
Maximum number of pyramid levels.
Default value: 'auto'
List of values: 'auto', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Smallest rotation of the pattern.
Default value: -0.39
Suggested values: -3.14, -1.57, -0.79, -0.39, -0.20, 0.0
Extent of the rotation angles.
Default value: 0.79
Suggested values: 6.29, 3.14, 1.57, 0.79, 0.39
Restriction: AngleExtent >= 0
Step length of the angles (resolution).
Default value: 'auto'
Suggested values: 'auto', 0.0175, 0.0349, 0.0524, 0.0698, 0.0873
Restriction: AngleStep >= 0
Minimum scale of the pattern in row direction.
Default value: 1.0
Suggested values: 0.5, 0.6, 0.7, 0.8, 0.9, 1.0
Restriction: ScaleRMin > 0
Maximum scale of the pattern in row direction.
Default value: 1.0
Suggested values: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5
Restriction: ScaleRMax >= ScaleRMin
Scale step length (resolution) in row direction.
Default value: 'auto'
Suggested values: 'auto', 0.01, 0.02, 0.05, 0.1, 0.15, 0.2
Restriction: ScaleRStep >= 0
Minimum scale of the pattern in column direction.
Default value: 1.0
Suggested values: 0.5, 0.6, 0.7, 0.8, 0.9, 1.0
Restriction: ScaleCMin > 0
Maximum scale of the pattern in column direction.
Default value: 1.0
Suggested values: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5
Restriction: ScaleCMax >= ScaleCMin
Scale step length (resolution) in column direction.
Default value: 'auto'
Suggested values: 'auto', 0.01, 0.02, 0.05, 0.1, 0.15, 0.2
Restriction: ScaleCStep >= 0
Kind of optimization used for generating the model.
Default value: 'none'
List of values: 'auto', 'none', 'point_reduction_low', 'point_reduction_medium', 'point_reduction_high'
Match metric.
Default value: 'use_polarity'
List of values: 'use_polarity', 'ignore_global_polarity', 'ignore_part_polarity', 'ignore_local_polarity', 'ignore_color_polarity'
Thresholds or hysteresis thresholds for the contrast of the object in the template image.
Default value: 'auto'
Suggested values: 'auto', 10, 20, 30, 40, 60, 80, 100, 120, 140, 160
Minimum contrast of the objects in the search images.
Default value: 'auto'
Suggested values: 'auto', 1, 2, 3, 5, 7, 10, 20, 30, 40
Restriction: MinContrast < Contrast
The generic parameter names.
Default value: []
List of values: [], 'min_size', 'part_size'
Values of the generic parameter.
Default value: []
List of values: [], 'small', 'medium', 'big'
Handle of the model.
If the parameters are valid, the operator create_planar_uncalib_deformable_model returns the value 2 (H_MSG_TRUE). If necessary an exception is raised.
determine_deformable_model_params
set_deformable_model_origin, set_deformable_model_param, get_deformable_model_contours, find_planar_uncalib_deformable_model, get_deformable_model_params, write_deformable_model, clear_deformable_model
Matching
| Table of Contents / Matching / Deformable | Operators |
| HALCON Reference Manual 10.0.2 | Copyright © 1996-2011 MVTec Software GmbH |