Skip to main content

MagmDraw

BoardSupported
Host SystemYes
V4L2Yes
Clarity UHDYes
Concord PoENo
GenTLYes
GevIQYes
GigE VisionYes
IndioNo
Iris GTXYes
Radient eV-CLYes
Rapixo CLYes
Rapixo CoFYes
Rapixo CXPYes
USB3 VisionYes

Draw specific features of the model, result occurrence, or training image in an image buffer or 2D graphics list.

Syntax

void MagmDraw(
AIL_ID ContextGraId, //in
AIL_ID ContextOrResultAgmId, //in
AIL_ID DstImageBufOrListGraId, //out
AIL_INT64 Operation, //in
AIL_INT64 Index, //in
AIL_INT64 ControlFlag //in
)

Description

This function draws specific model, result occurrence, or training image features in the destination image buffer or 2D graphics list.

Drawing the trained composite-definition model will help you determine the success of the MagmTrain operation. If the trained composite-definition model does not look like the positively labeled objects in your training images, you should modify the images and repeat the training process.

Parameters

ContextGraId (in, AIL_ID)

Specifies the identifier of the 2D graphics context to use when drawing. This parameter must be set to one of the following values:

For specifying the 2D graphics context

ValueDescription
M_DEFAULTSpecifies that the default 2D graphics context of the current Aurora Imaging Library application is used.

Note: Note that there is a different default 2D graphics context for each thread. | | 2D graphics context identifier | Specifies a valid 2D graphics context identifier, which you have allocated using MgraAlloc. |

ContextOrResultAgmId (in, AIL_ID)

Specifies the find AGM context or AGM result buffer from which to extract the features to draw. The find AGM context must have been previously allocated using MagmAlloc with M_GLOBAL_EDGE_BASED_FIND. The find or train AGM result buffer must have been previously allocated using MagmAllocResult with M_GLOBAL_EDGE_BASED_FIND_RESULT or M_GLOBAL_EDGE_BASED_TRAIN_RESULT and must contain the results of a call to MagmFind or MagmTrain, respectively.

DstImageBufOrListGraId (out, AIL_ID)

Specifies the identifier of the destination image buffer or 2D graphics list in which to draw. The buffer can be any valid 1- or 3-band image buffer allocated using MbufAlloc.... The 2D graphics list must be previously allocated using MgraAllocList. By drawing into a display's overlay buffer or associating the 2D graphics list with the display, you can also annotate an image non-destructively.

Operation (in, AIL_INT64)

Specifies the type of operation to perform. Operations can be added together to draw multiple features at a time. For example, to draw both the result occurrence's position and edges, you would set the Operation parameter to M_DRAW_POSITION+M_DRAW_EDGES. The Operation parameter can be set to a combination of the following values:

For a find AGM context only

ValueDescription
M_DRAW_IMAGEDraws the model image of a single-definition or a composite-definition model. For a composite-definition model, if the image does not exist, an Aurora Imaging Library error is thrown. To inquire if the model image exists, you can use MagmInquire with M_HAS_USER_MODEL.

You can use MagmInquire with M_SIZE_X and M_SIZE_Y to inquire the size of the model. | | M_DRAW_TRAINED_MODEL | Draws the trained composite-definition model.

You can use MagmInquire with M_SIZE_X and M_SIZE_Y to inquire the size of the model. |

For a train AGM result buffer only

ValueDescription
M_DRAW_NEG_RECTANGLESDraws all the rectangles that were used to label the negative model locations in the training image.

You can use MgraControl with M_COLOR set to M_COLOR_RED to reuse these rectangles for another MagmTrain operation. | | M_DRAW_POS_RECTANGLES | Draws all the rectangles that were used to label the positive model locations in the training image.

Note that if the rectangles were realigned, using MagmControl with M_REALIGN_STRENGTH, the realigned rectangles are drawn.

You can use MgraControl with M_COLOR set to M_COLOR_BLUE to reuse these rectangles for another MagmTrain operation. |

For specifying an operation that can extract features to draw from either a find AGM context or a find AGM result buffer

ValueDescription
M_DRAW_BOXDraws the model box, or a bounding box around the occurrence. Note that when drawing an occurrence, the bounding box is drawn according to the occurrence's angle and scale. Since a find AGM result buffer only contains occurrences that are similar in size to the model, the occurrence's scale is close to 1.0. You can get the exact angle and scale of the occurrence, using MagmGetResult with M_ANGLE and M_SCALE.
M_DRAW_EDGESDraws the edges related to the model or result.

When working with result occurrences, the drawing depends on whether you are adding M_MODEL or M_TARGET to M_DRAW_EDGES.

Note that the AGM context must be preprocessed. If it is not preprocessed, an Aurora Imaging Library error is thrown. | | M_DRAW_POSITION | Draws a cross-like symbol at the model's reference axis origin or occurrence position. The cross is drawn maintaining the angle of the model's reference axis or the occurrence. |

For

ValueDescription
M_MODEL (default)Draws the used edges of the model transformed at the occurrence position.

For a composite-definition model, if MagmControl with M_MODEL_SOURCE is set to M_USER_IMAGE, the model image is used for the fit and coverage calculations and the edges of the model image are drawn. If M_MODEL_SOURCE is set to M_FROM_TRAIN, the trained composite-definition model is used for the detection, fit, and coverage calculations and the edges of the trained composite-definition model are drawn. | | M_TARGET | Draws the edges of the target in the region of the occurrence.

This value is only available when M_USE_MAGNITUDE_TARGET is set to M_DISABLE. |

Index (in, AIL_INT64)

Specifies the index of the model in the specified find AGM context, the result occurrence in the specified find AGM result buffer, or the image in the specified train AGM result buffer.

For specifying the index of the model, result occurrence, or image

ValueDescription
M_DEFAULTSame as M_ALL.

Note that this value is only available if a find AGM result buffer is specified. | | M_AGM_IMAGE_INDEX | Specifies that the drawing operation is for a specific image in the train AGM result buffer, if one is specified. | | M_AGM_MODEL_INDEX | Specifies that the drawing operation is for a specific model in the find AGM context, if one is specified. | | M_ALL | Draws the specified feature of all occurrences, if a find AGM result buffer is specified. | | Value >= 0 | Specifies the index of the occurrence in the find AGM result buffer, if one is specified. |

ControlFlag (in, AIL_INT64)

Reserved for future expansion. this parameter must be set to M_DEFAULT.

Copyright © 2026 Zebra Technologies.