#include <mil.h>
#include "ExampleManager.h"
#include "SimpleFixture.h"
#include "ProductCountInspection.h"
#include "HorizontalAndAngleAlignment.h"
#include "VerticalAlignment.h"
#include "PositionInspection.h"
#include "CapOrientation.h"
void PrintHeader()
{
MosPrintf(MIL_TEXT("[EXAMPLE NAME]\n")
MIL_TEXT("AmpouleAndPackageInspection\n\n")
MIL_TEXT("[SYNOPSIS]\n")
MIL_TEXT("This example shows some basic inspection of ampoules\n")
MIL_TEXT("and their packaging. The following features will be inspected:\n")
MIL_TEXT(" 1-2. Fill level and cap\n")
MIL_TEXT(" - Verification of the fill level\n")
MIL_TEXT(" - Verification of the cap position\n")
MIL_TEXT(" - Verification of the cap orientation\n")
MIL_TEXT(" 3. Packaging ampoule count\n\n")
MIL_TEXT("[MODULES USED]\n")
MIL_TEXT("Modules used: Application, system, graphic, measurement,\n")
MIL_TEXT(" pattern matching\n\n")
MIL_TEXT("[ADDITIONNAL INSTRUCTIONS]\n")
MIL_TEXT("Left click on an image to view results in a zoomable display.\n\n")
MIL_TEXT("Press <Enter> to continue.\n\n"));
MosGetch();
}
#define ARRAY_COUNT(x) (sizeof((x))/sizeof((x)[0]))
#define EXAMPLE_IMAGE_PATH M_IMAGE_PATH MIL_TEXT("AmpouleAndPackageInspection/")
#define PRODUCT0_PATH EXAMPLE_IMAGE_PATH MIL_TEXT("Product0/")
int MosMain(void)
{
CHorizontalAndAngleAlignment Prod0HorzAlignment (PRODUCT0_PATH MIL_TEXT("HorizontalAlignmentAmpoule.mrk"), M_RED);
CVerticalAlignment Prod0VertAlignment (PRODUCT0_PATH MIL_TEXT("VerticalAlignmentAmpoule.mrk"), M_RED, &Prod0HorzAlignment);
CSimpleFixture Prod0FillLevelFixture (0, 68, 90, &Prod0VertAlignment);
CPositionInspection Prod0FillLevel (PRODUCT0_PATH MIL_TEXT("FillLevel.mrk"), MIL_TEXT("fill level"), 0, 10, M_RED, &Prod0FillLevelFixture);
CCapOrientation Prod0CapOrientation (PRODUCT0_PATH MIL_TEXT("CapOrientation.mrk"), 83, 5, M_RED, &Prod0VertAlignment);
CSimpleFixture Prod0CapPositionFixture (0, -170, 90, &Prod0VertAlignment);
CPositionInspection Prod0CapPosition (PRODUCT0_PATH MIL_TEXT("CapPosition.mrk"), MIL_TEXT("cap"), 0, 5, M_RED, &Prod0CapPositionFixture);
CHorizontalAndAngleAlignment Prod0HorzAlignment2 (PRODUCT0_PATH MIL_TEXT("HorizontalAlignmentAmpoule.mrk"), M_RED);
CVerticalAlignment Prod0VertAlignment2 (PRODUCT0_PATH MIL_TEXT("VerticalAlignmentAmpoule.mrk"), M_RED, &Prod0HorzAlignment2);
CSimpleFixture Prod0FillLevelFixture2 (0, 68, 90, &Prod0VertAlignment2);
CPositionInspection Prod0FillLevel2 (PRODUCT0_PATH MIL_TEXT("FillLevel.mrk"), MIL_TEXT("fill level"), 0, 10, M_RED, &Prod0FillLevelFixture2);
CCapOrientation Prod0CapOrientation2 (PRODUCT0_PATH MIL_TEXT("CapOrientation.mrk"), 83, 5, M_RED, &Prod0VertAlignment2);
CSimpleFixture Prod0CapPositionFixture2 (0, -170, 90, &Prod0VertAlignment2);
CPositionInspection Prod0CapPosition2 (PRODUCT0_PATH MIL_TEXT("CapPosition.mrk"), MIL_TEXT("cap"), 0, 5, M_RED, &Prod0CapPositionFixture2);
CProductCountInspection Prod0Count (PRODUCT0_PATH MIL_TEXT("Pattern.mod"), 30, M_RED);
CInspectionTask* Prod0Image0Tasks[] = { &Prod0HorzAlignment , &Prod0VertAlignment , &Prod0FillLevelFixture , &Prod0FillLevel , &Prod0CapOrientation , &Prod0CapPositionFixture , &Prod0CapPosition };
CInspectionTask* Prod0Image1Tasks[] = { &Prod0HorzAlignment2, &Prod0VertAlignment2, &Prod0FillLevelFixture2, &Prod0FillLevel2, &Prod0CapOrientation2, &Prod0CapPositionFixture2, &Prod0CapPosition2 };
CInspectionTask* Prod0Image2Tasks[] = { &Prod0Count };
SImageTaskList Prod0ImagesTaskList[] =
{
CREATE_LIST(Prod0Image0Tasks, MIL_TEXT("Fill level and cap")),
CREATE_LIST(Prod0Image1Tasks, MIL_TEXT("Fill level and cap")),
CREATE_LIST(Prod0Image2Tasks, MIL_TEXT("Packaging ampoule count"))
};
static MIL_CONST_TEXT_PTR Prod0ImagesAvi[ARRAY_COUNT(Prod0ImagesTaskList)] =
{
PRODUCT0_PATH MIL_TEXT("View0.avi"),
PRODUCT0_PATH MIL_TEXT("View1.avi"),
PRODUCT0_PATH MIL_TEXT("View2.avi")
};
SProductInfo ProductsInfoList[] =
{
{ ARRAY_COUNT(Prod0ImagesTaskList), enParallel, Prod0ImagesAvi, Prod0ImagesTaskList },
};
MIL_ID MilApplication = MappAlloc(M_NULL, M_DEFAULT, M_NULL);
MIL_ID MilSystem = MsysAlloc(M_DEFAULT, M_SYSTEM_HOST, M_DEFAULT, M_DEFAULT, M_NULL);
MosPrintf(MIL_TEXT("AMPOULE AND PACKAGE INSPECTION:\n"));
MosPrintf(MIL_TEXT("---------------------------------------\n\n"));
PrintHeader();
CExampleMngr *pExampleManager = new CExampleMngr(MilSystem);
pExampleManager->Run(ProductsInfoList, ARRAY_COUNT(ProductsInfoList));
delete pExampleManager;
MsysFree(MilSystem);
MappFree(MilApplication);
return 0;
}