| MIL 10 Reference
| Customize Help
| Save Settings

MpatAllocModel



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Allocate a pattern matching model from a source image.
Syntax
MIL_ID MpatAllocModel(
MIL_ID SystemId, //in
MIL_ID SrcImageBufId, //in
MIL_INT OffX, //in
MIL_INT OffY, //in
MIL_INT SizeX, //in
MIL_INT SizeY, //in
MIL_INT64 ModelType, //in
MIL_ID *ModelIdPtr //out
)
Description

This function allocates a model, using data from the specified area of the model's source image.

You can change a model's search parameter settings at any time, using the appropriate MpatSet...() function. When the model is no longer required, you should release its memory, using MpatFree().

An M_NORMALIZED type model (without overscan data) is usually used for an image with an inconsistent surrounding region, such as an image of loose nuts and bolts lying on a metal sheet. To perform an angular search, define the angular range in which the model can appear using MpatSetAngle(). When preprocessing an M_NORMALIZED model (without overscan data) for which an angular search range is specified, rotated versions of the model are created assigning "don't care" pixels to regions that do not have corresponding data in the original model.

Angular search is fastest when performed with an M_CIRCULAR_OVERSCAN model; however, M_CIRCULAR_OVERSCAN should only be used when the region around the model is consistent, for example, when searching for a chip in the image of an integrated circuit.

When preprocessing an M_CIRCULAR_OVERSCAN model for which an angular search range has been specified, a set of models is extracted from rotated versions of the M_CIRCULAR_OVERSCAN model, creating models that would appear upright if the target image were rotated. For this type of model, a larger region than the one defined is extracted from the model's source image so as to allow creation of models at different angles.

You can only define models that respect the following condition: (maxvalue 2 * SizeX * SizeY) < 2 63 where maxvalue is the maximum pixel value (typically, 255) in the target image and the model. This restriction is imposed to avoid overflows in the internal 64-bit accumulators.

The total area of the defined model must be greater or equal to 4 pixels (SizeX * SizeY >= 4).

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
SystemId INQ

Specifies the system on which to allocate the model.

This parameter should be set to one of the following values:

function map For specifying the system identifier
CollapseValue Description
Collapse M_DEFAULT_HOST

Specifies the default Host system of the current MIL application.

Collapse MIL system identifier

Specifies a valid system identifier, previously allocated using MsysAlloc().

SrcImageBufId

Specifies the identifier of the image buffer from which to extract the model (that is, the model's source image). This function currently supports only 8-bit unsigned grayscale images.

This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.

OffX INQ

Specifies the coordinates of the model origin in the source image (SrcImageBufId). The specified model position (OffX) must be valid in the source image.

OffY INQ

Specifies the coordinates of the model origin in the source image (SrcImageBufId). The specified model position (OffY) must be valid in the source image.

SizeX INQ

Specifies the width of the model. The specified model width (SizeX) must be valid in the source image.

SizeY INQ

Specifies the height of the model. The specified model height (SizeY) must be valid in the source image.

ModelType INQ

Specifies the type of the model. This parameter must be set to the following:

function map For specifying the type of model
CollapseValue Description
Collapse M_NORMALIZED +

Specifies a model used to search for the position, match score, and angle (if angular search is enabled) of a model occurrence in a target image, using MpatFindModel() and MpatFindMultipleModel().

Combination constant for any of the possible values of the ModelType parameter.

You can add the following value to the above-mentioned value to extract the model, as well as circular overscan data.

function map For the ModelType parameter
CollapseCombination value Description
Collapse M_CIRCULAR_OVERSCAN

Specifies that the model is extracted from the source image with the circular overscan data. The overscan data is determined by rotating the area from which to extract the model, about its center. The overscan data of an M_CIRCULAR_OVERSCAN type model is used if you search for an occurrence of the model at an angle.

The model must not be extracted from a region too close to the edge of the model's source image. In addition, the M_CIRCULAR_OVERSCAN model should be complex enough so that if models are created from it at the required angles, they are representative of the pattern being sought.

For this model, you cannot define "don't care" regions (MpatSetDontCare()).

(summarize)
ModelIdPtr

Specifies the address of the variable in which to write the model identifier. This identifier is required to use the model with other pattern matching functions. Since MpatAllocModel() also returns the model identifier, you can set this parameter to M_NULL.

Return value
The returned value is the model identifier if the allocation is successful. If allocation fails, M_NULL is returned.
Compilation information
Header Include mil.h.
Library Use mil.lib; milpat.lib.
DLL Requires mil.dll; milpat.dll.
DEFAULT HOST UNSIGNED PROC NONE SIZE X SIZE Y SIZE X SIZE Y NORMALIZED CIRCULAR OVERSCAN