Magm
This example demonstrates the usage of the Advanced Geometric Matcher module.
Language: C#
Functions used: MappAlloc, MappFree, MappTimer, MbufFree, MbufRestore, MdispAlloc, MdispControl, MdispFree, MdispSelect, MgraAllocList, MgraClear, MgraFree, MagmAlloc, MagmAllocResult, MagmControl, MagmDefine, MagmDraw, MagmFind, MagmFree, MagmGetResult, MagmPreprocess, MagmTrain, MagmCopyResult, MsysAlloc, MsysFree
Categories: Overview, General, Industries, Applications, Finding/Locating, Modules, Advanced Geometric Matcher, Buffer, Display, Graphics, What's New, AIL 10.0 SP7, AIL 10.0 SP6
///////////////////////////////////////////////////////////////////////////////
// Aurora Imaging Library
// Filename: Magm.cs
//
// Description: This program consists of 2 examples that use the AGM module
// to define a model and search for model occurrences in target images.
// The first example extracts a single-definition model from a source image,
// then quickly finds occurrences in a cluttered target image.
// The second example constructs a composite-definition model through training,
// then finds occurrences with slight variations in appearance in different target images.
//
// (C) 1992-2026 Zebra Technologies Corp. and/or its affiliates
// All Rights Reserved
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using System.Text;
using Zebra.AuroraImagingLibrary;
namespace MImProcessing
{
class Program
{
// Path definitions.
private const string EXAMPLE_IMAGE_DIR_PATH = AIL.M_IMAGE_PATH + "/Magm/";
private const string MODEL_IMAGE_0_PATH = EXAMPLE_IMAGE_DIR_PATH + "CircuitPinsModel.mim";
private const string MODEL_IMAGE_1_PATH = EXAMPLE_IMAGE_DIR_PATH + "SwitchModel.mim";
private const string TARGET_IMAGE_0_PATH = EXAMPLE_IMAGE_DIR_PATH + "CircuitBoardTarget.mim";
private const string TARGET_IMAGE_1_PATH = EXAMPLE_IMAGE_DIR_PATH + "SwitchTarget.mim";
private const string TRAIN_IMAGES_PATH = EXAMPLE_IMAGE_DIR_PATH + "LabeledTrainImages.mbufc";
private const string TEST_IMAGES_DIR_PATH = EXAMPLE_IMAGE_DIR_PATH + "Testset/";
//****************************************************************************
// Execute Single-definition model example.
//****************************************************************************
static void ExecuteSingleModelExample(
AIL_ID AilSystem,
AIL_ID AilModelDisplay,
AIL_ID AilTargetDisplay,
string ModelImagePath,
string TargetImagePath,
double DetectionSearchAngleDeltaPos = 0.0)
{
AIL_ID AilGraphicList = AIL.M_NULL; // Graphic list identifier.
AIL_ID AilFindContext = AIL.M_NULL; // Find AGM context identifier.
AIL_ID AilSearchResult = AIL.M_NULL; // Find AGM result buffer identifier.
AIL_ID AilModelImage = AIL.M_NULL; // Image buffer identifier.
AIL_ID AilTargetImage = AIL.M_NULL; // Image buffer identifier.
// Allocate a graphic list to hold the subpixel annotations to draw.
AIL.MgraAllocList(AilSystem, AIL.M_DEFAULT, ref AilGraphicList);
// Associate the graphic list to the display for annotations.
AIL.MdispControl(AilTargetDisplay, AIL.M_ASSOCIATED_GRAPHIC_LIST_ID, AilGraphicList);
// Restore the model image.
AIL.MbufRestore(ModelImagePath, AilSystem, ref AilModelImage);
// Make the display a little bigger since the image is small.
AIL_INT ModelWindowSizeX = AIL.MbufInquire(AilModelImage, AIL.M_SIZE_X, AIL.M_NULL) + 150;
AIL_INT ModelWindowSizeY = AIL.MbufInquire(AilModelImage, AIL.M_SIZE_Y, AIL.M_NULL) + 150;
AIL.MdispControl(AilModelDisplay, AIL.M_WINDOW_INITIAL_SIZE_X, ModelWindowSizeX);
AIL.MdispControl(AilModelDisplay, AIL.M_WINDOW_INITIAL_SIZE_Y, ModelWindowSizeY);
// Sets the initial, left-most, X-coordinate of the model disaplay and target display
AIL.MdispControl(AilModelDisplay, AIL.M_WINDOW_INITIAL_POSITION_X, 10);
AIL.MdispControl(AilModelDisplay, AIL.M_WINDOW_INITIAL_POSITION_Y, 10);
AIL.MdispControl(AilTargetDisplay, AIL.M_WINDOW_INITIAL_POSITION_X, ModelWindowSizeX + 90);
AIL.MdispControl(AilTargetDisplay, AIL.M_WINDOW_INITIAL_POSITION_Y, 10);
// Display the model image.
AIL.MdispSelect(AilModelDisplay, AilModelImage);
Console.Write("A single-definition model was defined ");
Console.Write("from the displayed model image.\n\n");
// Allocate a find AGM context.
AIL.MagmAlloc(AilSystem, AIL.M_GLOBAL_EDGE_BASED_FIND, AIL.M_DEFAULT, ref AilFindContext);
// Allocate a find AGM result buffer.
AIL.MagmAllocResult(AilSystem, AIL.M_GLOBAL_EDGE_BASED_FIND_RESULT, AIL.M_DEFAULT, ref AilSearchResult);
// Define the single-definition model.
AIL.MagmDefine(AilFindContext, AIL.M_ADD, AIL.M_DEFAULT, AIL.M_SINGLE, AilModelImage, AIL.M_DEFAULT);
// Set the minimum acceptable detection score.
AIL.MagmControl(AilFindContext, AIL.M_AGM_MODEL_INDEX(0), AIL.M_ACCEPTANCE_DETECTION, 75);
// Set the search angle range for the detection.
AIL.MagmControl(AilFindContext, AIL.M_AGM_MODEL_INDEX(0), AIL.M_DETECTION_DELTA_POS_ANGLE, DetectionSearchAngleDeltaPos);
// Preprocess the find AGM context.
AIL.MagmPreprocess(AilFindContext, AIL.M_DEFAULT);
// Restore the target image.
AIL.MbufRestore(TargetImagePath, AilSystem, ref AilTargetImage);
// Reset the time.
double FindTime = 0.0;
AIL.MappTimer(AIL.M_DEFAULT, AIL.M_TIMER_RESET + AIL.M_SYNCHRONOUS, AIL.M_NULL);
// Find the model.
AIL.MagmFind(AilFindContext, AilTargetImage, AilSearchResult, AIL.M_DEFAULT);
// Read the find time.
AIL.MappTimer(AIL.M_DEFAULT, AIL.M_TIMER_READ + AIL.M_SYNCHRONOUS, ref FindTime);
// Get the number of occurrences found.
AIL_INT NumOccurrences = 0;
AIL.MagmGetResult(AilSearchResult, AIL.M_DEFAULT, AIL.M_NUMBER + AIL.M_TYPE_AIL_INT, ref NumOccurrences);
if (NumOccurrences > 0)
{
double[] XPositions = new double[NumOccurrences];
double[] YPositions = new double[NumOccurrences];
double[] Angles = new double[NumOccurrences];
double[] DetectionScores = new double[NumOccurrences];
double[] FitScores = new double[NumOccurrences];
double[] CoverageScores = new double[NumOccurrences];
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_POSITION_X , XPositions);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_POSITION_Y , YPositions);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_ANGLE , Angles);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_SCORE_DETECTION, DetectionScores);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_SCORE_FIT , FitScores);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_SCORE_COVERAGE , CoverageScores);
// Print the results for each occurrence found.
Console.Write("The model was found in the target image:\n\n");
Console.Write("Result X Position Y Position Angle DetectionScore FitScore CoverageScore\n\n");
for (AIL_INT i = 0; i < NumOccurrences; ++i)
{
Console.Write("{0,-9}{1,-13:F2}{2,-13:F2}{3,-9:F2}{4,-17:F2}{5,-11:F2}{6,-11:F2}\n",
i, XPositions[i], YPositions[i], Angles[i], DetectionScores[i], FitScores[i], CoverageScores[i]);
}
Console.Write("\nNumber of occurrences found in the target image: {0}\n", NumOccurrences);
Console.Write("Search time: {0} ms\n", FindTime * 1000.0);
// Draw green edges and bounding boxes over the occurrences that were found.
AIL.MgraControl(AIL.M_DEFAULT, AIL.M_COLOR, AIL.M_COLOR_GREEN);
AIL.MagmDraw(AIL.M_DEFAULT, AilSearchResult, AilGraphicList, AIL.M_DRAW_EDGES + AIL.M_DRAW_BOX, AIL.M_ALL, AIL.M_DEFAULT);
// Draw red positions over the occurrences that were found.
AIL.MgraControl(AIL.M_DEFAULT, AIL.M_COLOR, AIL.M_COLOR_RED);
AIL.MagmDraw(AIL.M_DEFAULT, AilSearchResult, AilGraphicList, AIL.M_DRAW_POSITION, AIL.M_ALL, AIL.M_DEFAULT);
}
else
{
Console.Write("The model was not found in the target image.\n");
}
// Display the target image.
AIL.MdispSelect(AilTargetDisplay, AilTargetImage);
Console.Write("Press any key to continue.\n\n");
Console.ReadKey(true);
// Put the display back to its default state.
AIL.MdispControl(AilModelDisplay, AIL.M_WINDOW_INITIAL_SIZE_X, AIL.M_DEFAULT);
AIL.MdispControl(AilModelDisplay, AIL.M_WINDOW_INITIAL_SIZE_Y, AIL.M_DEFAULT);
// Remove the display.
AIL.MdispSelect(AilModelDisplay , AIL.M_NULL);
AIL.MdispSelect(AilTargetDisplay, AIL.M_NULL);
// Free objects.
AIL.MgraFree(AilGraphicList);
AIL.MagmFree(AilFindContext);
AIL.MagmFree(AilSearchResult);
AIL.MbufFree(AilModelImage);
AIL.MbufFree(AilTargetImage);
}
//****************************************************************************
// Single-definition model example.
//****************************************************************************
static void SingleModelExample(AIL_ID AilSystem)
{
Console.Write("This example shows that AGM is able ");
Console.Write("to quickly find occurrences\n");
Console.Write("in a large cluttered target image.\n");
Console.Write("Press any key to continue.\n\n");
Console.ReadKey(true);
AIL_ID AilModelDisplay = AIL.M_NULL; // Model display identifier.
AIL_ID AilTargetDisplay = AIL.M_NULL; // Target display identifier.
// Allocate the model and target displays
AIL.MdispAlloc(AilSystem, AIL.M_DEFAULT, "M_DEFAULT", AIL.M_DEFAULT, ref AilModelDisplay);
AIL.MdispAlloc(AilSystem, AIL.M_DEFAULT, "M_DEFAULT", AIL.M_DEFAULT, ref AilTargetDisplay);
// Set the model and target display's titles
AIL.MdispControl(AilModelDisplay , AIL.M_TITLE, "Model");
AIL.MdispControl(AilTargetDisplay, AIL.M_TITLE, "Target");
ExecuteSingleModelExample(AilSystem, AilModelDisplay, AilTargetDisplay, MODEL_IMAGE_0_PATH, TARGET_IMAGE_0_PATH);
Console.Write("AGM can also find oriented occurrences.\n\n");
ExecuteSingleModelExample(AilSystem, AilModelDisplay, AilTargetDisplay, MODEL_IMAGE_1_PATH, TARGET_IMAGE_1_PATH, 360.0);
// Free objects.
AIL.MdispFree(AilModelDisplay);
AIL.MdispFree(AilTargetDisplay);
}
//****************************************************************************
// Composite-definition model example.
//****************************************************************************
static void CompositeModelExample(AIL_ID AilSystem)
{
AIL_ID AilDisplay = AIL.M_NULL; // Display identifier
AIL_ID AilGraphicList = AIL.M_NULL; // Graphic list identifier.
AIL_ID AilTrainContext = AIL.M_NULL; // Train AGM context identifier.
AIL_ID AilTrainResult = AIL.M_NULL; // Train AGM result buffer identifier.
AIL_ID AilFindContext = AIL.M_NULL; // Find context identifier.
AIL_ID AilSearchResult = AIL.M_NULL; // Find AGM result buffer identifier.
AIL_ID Regions = AIL.M_NULL; // Graphic list identifier.
AIL_ID TrainImagesContainer = AIL.M_NULL; // Container buffer identifier.
Console.Write("This example shows that AGM is able ");
Console.Write("to confidently find occurrences with appearance\n");
Console.Write("variation in a complex background ");
Console.Write("after training a composite-definition model.\n");
// Allocate the display
AIL.MdispAlloc(AilSystem, AIL.M_DEFAULT, "M_DEFAULT", AIL.M_DEFAULT, ref AilDisplay);
// Restore the training images.
AIL.MbufRestore(TRAIN_IMAGES_PATH, AilSystem, ref TrainImagesContainer);
// Print message about training image labels.
Console.Write("\n*******************************************************\n");
Console.Write("LOADING LABELED TRAINING IMAGES...\n");
Console.Write("*******************************************************\n");
Console.Write("Training requires labeled images with positive and negative samples.\n");
Console.Write("Positive samples are occurrences delimited by blue boxes and\n");
Console.Write("negative samples are background parts delimited by red boxes.\n");
Console.Write("Typically, when false positives are detected in training images,\n");
Console.Write("they should be used as negative samples to improve the training.\n");
Console.Write("To ease the labeling of images, use the example AgmLabelingTool.\n");
// Wait for a key to be pressed.
Console.Write("\nPress any key to show the labeled images used in this training.\n");
Console.ReadKey(true);
// Get the components from the container.
AIL_INT NumTrainImage = 0;
AIL.MbufInquireContainer(TrainImagesContainer, AIL.M_CONTAINER, AIL.M_COMPONENT_LIST + AIL.M_NB_ELEMENTS, ref NumTrainImage);
AIL_ID[] TrainImages = new AIL_ID[NumTrainImage];
AIL.MbufInquireContainer(TrainImagesContainer, AIL.M_CONTAINER, AIL.M_COMPONENT_LIST, TrainImages);
// Allocate a graphic list to hold the subpixel annotations to draw.
AIL.MgraAllocList(AilSystem, AIL.M_DEFAULT, ref Regions);
// Associate the graphic list to the display for annotations.
AIL.MdispControl(AilDisplay, AIL.M_ASSOCIATED_GRAPHIC_LIST_ID, Regions);
Console.Write("\nOnly positive samples are given because AGM is able\n");
Console.Write("to automatically generate negative samples.\n\n");
// Display each labeled training image.
for (AIL_INT i = 0; i < NumTrainImage; ++i)
{
AIL.MgraClear(AIL.M_DEFAULT, Regions);
AIL.MbufSetRegion(TrainImages[i], Regions, AIL.M_DEFAULT, AIL.M_EXTRACT, AIL.M_DEFAULT);
AIL.MdispSelect(AilDisplay, TrainImages[i]);
Console.Write("Training image {0}/{1}\n", i + 1, NumTrainImage);
Console.Write("Press any key to continue.\n");
Console.ReadKey(true);
}
// Disassociate the graphic list from the display and stop displaying the training images.
AIL.MdispControl(AilDisplay, AIL.M_ASSOCIATED_GRAPHIC_LIST_ID, AIL.M_NULL);
AIL.MdispSelect(AilDisplay, AIL.M_NULL);
// Allocate a find AGM context.
AIL.MagmAlloc(AilSystem, AIL.M_GLOBAL_EDGE_BASED_FIND, AIL.M_DEFAULT, ref AilFindContext);
// Allocate a find AGM result buffer.
AIL.MagmAllocResult(AilSystem, AIL.M_GLOBAL_EDGE_BASED_FIND_RESULT, AIL.M_DEFAULT, ref AilSearchResult);
// Allocate a train AGM context.
AIL.MagmAlloc(AilSystem, AIL.M_GLOBAL_EDGE_BASED_TRAIN, AIL.M_DEFAULT, ref AilTrainContext);
// Allocate a train AGM result buffer.
AIL.MagmAllocResult(AilSystem, AIL.M_GLOBAL_EDGE_BASED_TRAIN_RESULT, AIL.M_DEFAULT, ref AilTrainResult);
// Define the composite-definition model.
AIL.MagmDefine(AilTrainContext, AIL.M_ADD, AIL.M_DEFAULT, AIL.M_COMPOSITE, AIL.M_NULL, AIL.M_DEFAULT);
// Enable the automatic generation of negative labels.
AIL.MagmControl(AilTrainContext, AIL.M_AGM_MODEL_INDEX(0), AIL.M_NEGATIVE_LABELS_MODE, AIL.M_AUTO);
// Preprocess the train AGM context.
AIL.MagmPreprocess(AilTrainContext, AIL.M_DEFAULT);
// Train the composite-definition model.
Console.Write("\n*******************************************************\n");
Console.Write("TRAINING... THIS WILL TAKE SOME TIME...\n");
Console.Write("*******************************************************\n");
AIL.MagmTrain(AilTrainContext, ref TrainImagesContainer, 1, AilTrainResult, AIL.M_DEFAULT);
// Check that the training process completed successfully.
AIL_INT TrainStatus = -1;
AIL.MagmGetResult(AilTrainResult, AIL.M_DEFAULT, AIL.M_STATUS + AIL.M_TYPE_AIL_INT, ref TrainStatus);
if (TrainStatus == AIL.M_COMPLETE)
{
Console.Write("Training complete!\n");
// Ensure that the trained model is valid before copying to the find AGM context.
AIL_INT TrainedModelStatus = -1;
AIL.MagmGetResult(AilTrainResult, AIL.M_AGM_MODEL_INDEX(0), AIL.M_STATUS, ref TrainedModelStatus);
if (TrainedModelStatus == AIL.M_STATUS_TRAIN_OK)
{
// Display all the positive and negative labels on the training images.
Console.Write("Here are the training images with the positive labels\n");
Console.Write("and the automatically generated negative labels.\n\n");
AIL.MdispControl(AilDisplay, AIL.M_ASSOCIATED_GRAPHIC_LIST_ID, Regions);
for (int i = 0; i < NumTrainImage; ++i)
{
AIL.MgraClear(AIL.M_DEFAULT, Regions);
AIL.MgraControl(AIL.M_DEFAULT, AIL.M_COLOR, AIL.M_COLOR_BLUE);
AIL.MagmDraw(AIL.M_DEFAULT, AilTrainResult, Regions, AIL.M_DRAW_POS_RECTANGLES, AIL.M_AGM_IMAGE_INDEX(i), AIL.M_DEFAULT);
AIL.MgraControl(AIL.M_DEFAULT, AIL.M_COLOR, AIL.M_COLOR_RED);
AIL.MagmDraw(AIL.M_DEFAULT, AilTrainResult, Regions, AIL.M_DRAW_NEG_RECTANGLES, AIL.M_AGM_IMAGE_INDEX(i), AIL.M_DEFAULT);
AIL.MdispSelect(AilDisplay, TrainImages[i]);
Console.Write("Training image {0}/{1}\n", i + 1, NumTrainImage);
Console.Write("Press any key to continue.\n");
Console.ReadKey(true);
}
// Disassociate the graphic list from the display and stop displaying the training images.
AIL.MdispControl(AilDisplay, AIL.M_ASSOCIATED_GRAPHIC_LIST_ID, AIL.M_NULL);
AIL.MdispSelect(AilDisplay, AIL.M_NULL);
// Copy the trained model to a find AGM context.
AIL.MagmCopyResult(AilTrainResult, AIL.M_DEFAULT, AilFindContext, AIL.M_DEFAULT, AIL.M_TRAINED_MODEL, AIL.M_DEFAULT);
}
}
// Preprocess find AGM context.
AIL.MagmPreprocess(AilFindContext, AIL.M_DEFAULT);
Console.Write("\n*******************************************************\n");
Console.Write("FINDING WITH THE TRAINED MODEL...\n");
Console.Write("*******************************************************\n");
// Restore test images.
AIL_INT NumberOfImages = 0;
string FilesToSearch = TEST_IMAGES_DIR_PATH + "*.mim";
AIL.MappFileOperation(AIL.M_DEFAULT, FilesToSearch, AIL.M_NULL, AIL.M_NULL, AIL.M_FILE_NAME_FIND+AIL.M_NB_ELEMENTS, AIL.M_DEFAULT, ref NumberOfImages);
AIL_ID[] TestImages = new AIL_ID[NumberOfImages];
for (AIL_INT i = 0; i < NumberOfImages; i++)
{
StringBuilder Filename = new StringBuilder();
AIL.MappFileOperation(AIL.M_DEFAULT, FilesToSearch, AIL.M_NULL, AIL.M_NULL, AIL.M_FILE_NAME_FIND, i, Filename);
string FilePath = TEST_IMAGES_DIR_PATH + Filename;
AIL.MbufRestore(FilePath, AilSystem, ref TestImages[i]);
}
// Allocate a graphic list to hold the subpixel annotations to draw.
AIL.MgraAllocList(AilSystem, AIL.M_DEFAULT, ref AilGraphicList);
// Associate the graphic list to the display for annotations.
AIL.MdispControl(AilDisplay, AIL.M_ASSOCIATED_GRAPHIC_LIST_ID, AilGraphicList);
// Assign the color to draw.
AIL.MgraControl(AIL.M_DEFAULT, AIL.M_COLOR, AIL.M_COLOR_GREEN);
for (AIL_INT i = 0; i < NumberOfImages; ++i)
{
// Find the model in the test image.
AIL.MagmFind(AilFindContext, TestImages[i], AilSearchResult, AIL.M_DEFAULT);
// Get the number of occurrences found.
AIL_INT NumOccurrences = 0;
AIL.MagmGetResult(AilSearchResult, AIL.M_DEFAULT, AIL.M_NUMBER, ref NumOccurrences);
if (NumOccurrences > 0)
{
// Get the results of the search.
double[] XPositions = new double[NumOccurrences];
double[] YPositions = new double[NumOccurrences];
double[] DetectionScores = new double[NumOccurrences];
double[] FitScores = new double[NumOccurrences];
double[] CoverageScores = new double[NumOccurrences];
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_POSITION_X , XPositions);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_POSITION_Y , YPositions);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_SCORE_DETECTION, DetectionScores);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_SCORE_FIT , FitScores);
AIL.MagmGetResult(AilSearchResult, AIL.M_ALL, AIL.M_SCORE_COVERAGE , CoverageScores);
// Print the results for each occurrence foud.
Console.Write("The model was found in the target image:\n\n");
Console.Write("Result X Position Y Position DetectionScore FitScore CoverageScore\n\n");
for (AIL_INT j = 0; j < NumOccurrences; ++j)
{
Console.Write("{0,-9}{1,-13:F2}{2,-13:F2}{3,-17:F2}{4,-11:F2}{5,-11:F2}\n",
j, XPositions[j], YPositions[j], DetectionScores[j], FitScores[j], CoverageScores[j]);
}
// Empty the graphic list.
AIL.MgraClear(AIL.M_DEFAULT, AilGraphicList);
// Draw bounding box
AIL.MagmDraw(AIL.M_DEFAULT, AilSearchResult, AilGraphicList, AIL.M_DRAW_BOX, AIL.M_ALL, AIL.M_DEFAULT);
}
else
{
Console.Write("The model was not found in the target image.\n");
}
// Display the test image.
AIL.MdispSelect(AilDisplay, TestImages[i]);
// Wait for a key to be pressed.
if (i < NumberOfImages - 1)
{
Console.Write("Press any key to continue.\n\n");
Console.ReadKey(true);
}
}
// Remove the display.
AIL.MdispSelect(AilDisplay, AIL.M_NULL);
// Free objects.
for (AIL_INT i = 0; i < NumberOfImages; ++i)
{
AIL.MbufFree(TestImages[i]);
}
AIL.MgraFree(AilGraphicList);
AIL.MgraFree(Regions);
AIL.MagmFree(AilTrainContext);
AIL.MagmFree(AilTrainResult);
AIL.MagmFree(AilFindContext);
AIL.MagmFree(AilSearchResult);
AIL.MbufFree(TrainImagesContainer);
AIL.MdispFree(AilDisplay);
}
static void Main(string[] args)
{
AIL_ID AilApplication = AIL.M_NULL; // Application identifier.
AIL_ID AilSystem = AIL.M_NULL; // System identifier.
// Allocate defaults.
AIL.MappAllocDefault(AIL.M_DEFAULT, ref AilApplication, ref AilSystem, AIL.M_NULL, AIL.M_NULL, AIL.M_NULL);
// Print the example synopsis.
Console.Write("[EXAMPLE NAME]\n");
Console.Write("Magm\n\n");
Console.Write("[SYNOPSIS]\n");
Console.Write("This program shows the use of the AGM module.\n\n");
Console.Write("[MODULES USED]\n");
Console.Write("Advanced Geometric Matcher, Buffer, Display, Graphics.\n\n");
// Run single-definition model example.
SingleModelExample(AilSystem);
// Run composite-definition model example.
CompositeModelExample(AilSystem);
// Wait for a key to be pressed.
Console.Write("Press any key to end.\n");
Console.ReadKey(true);
AIL.MappFreeDefault(AilApplication, AilSystem, AIL.M_NULL, AIL.M_NULL, AIL.M_NULL);
}
}
}