MpatAllocRotatedModel()函数

Synopsis

Rotate a pattern matching model.

Format

MIL_ID MpatAllocRotatedModel(SystemId, SrcModelId, Angle, InterpolationMode, ModelType, NewModelIdPtr)

MIL_ID SystemId; System identifier
MIL_ID SrcModelId; Source model identifier
double Angle; Angle of rotation
long InterpolationMode Interpolation mode used in rotation
long ModelType Type of model to rotate
MIL_ID *NewModelIdPtr; Storage location for new rotated model identifier

Description

This function allocates a new model and initializes it with the rotated version of a source model. It rotates the source model counter-clockwise by 0 to 360 degrees. You may want to rotate a model if the target image is presented to the camera differently at run time than when the model was allocated.

The SystemId parameter specifies the system on which the rotated model buffer will be allocated. This parameter must be set to a valid system identifier, M_DEFAULT_HOST or M_DEFAULT. To use the default Host system of the current MIL application, specify M_DEFAULT_HOST. If you specify M_DEFAULT, MIL will select the most appropriate system on which to allocate the buffer (the Host system or any already allocated system).

The SrcModelId parameter specifies the identifier of the source model. A new rotated model is generated from this model. Once you have a rotated version of a model, if you no longer require the original source model, it can be deleted with MpatFree.

The Angle parameter specifies the angle at which to rotate the model. This parameter can be set to any value from 0 to 360 degrees.

The InterpolationMode parameter specifies the mode of interpolation. This parameter can be set to one of the following:

M_NEAREST_NEIGHBOR Nearest neighbor interpolation.
M_BILINEAR Bilinear interpolation.
M_BICUBIC Bicubic interpolation.
M_DEFAULT Same as M_NEAREST_NEIGHBOR.

The ModelType parameter specifies the type and capabilities of the model. If set to M_NORMALIZED (normalized grayscale correlation), it finds the position and match score of the model in a target image, using MpatFindModel. If set to M_ORIENTATION (containing rotational information), it finds the global orientation (not position) of the model in a target image, using MpatFindOrientation. Note, a model of M_ORIENTATION type must contain all the significant features of the target image (for example, a unique object on a plain background). Combining the types allows the model to be used for both purposes (M_NORMALIZED+M_ORIENTATION).

Normalized models are directly associated with a set of search parameters. Upon allocation of an M_NORMALIZED model type, these model-search parameters are set to the following:

Positional accuracy: M_MEDIUM (+- 0.25 pixels)
Expected position: M_ALL (full image)
Positional uncertainty: M_ALL (full image)
Search number: 1
Search speed: M_MEDIUM
Acceptance level: 70%
Certainty level: 80%
Search angle:
Center of model An integer value equal to
((SizeX – 1) / 2, (SizeY – 1) / 2) (relative to the model origin).

You can change a model’s search parameters at any time, using the appropriate MpatSet…() command (MpatSetAcceptance, MpatSetAccuracy, MpatSetAngle, MpatSetCenter, MpatSetCertainty, MpatSetDontCare, MpatSetNumber, MpatSetPosition, MpatSetSpeed).

The NewModelIdPtr parameter specifies the address of the variable in which the rotated model buffer identifier is to be written. Since the MpatAllocRotatedModel function also returns the model buffer identifier, you can set this parameter to M_NULL.

Note that the allocated model size is usually greater than
the size of its source, due to the rectangular shape of the model and the nature of the rotation operation. The additional pixel locations produced by the rotation, which have no corresponding pixels in the source model, are set to don’t care value. The size (X,Y) of the new model can be inquired, using MpatInquire. If created from a source model, the new model’s search area is the same as that of the source.

Returned value

The returned value is the new model buffer identifier. If the rotation fails, M_NULL is returned.

See also

MpatSetPosition, MpatSetSearchParameter, MpatFree, MpatInquire