#include <mil.h>
#include "ExampleManager.h"
#include "CapScrewInspection_CapAndContent.h"
#include "ModelFinderAlignmentTask.h"
#include "TargetAlignmentTask.h"
#include "PositionInspection.h"
#include "DefectDetectionTask.h"
#include "SimpleFixture.h"
void PrintHeader()
{
MosPrintf(MIL_TEXT("[EXAMPLE NAME]\n")
MIL_TEXT("BottleCapAndContentInspection\n\n")
MIL_TEXT("[SYNOPSIS]\n")
MIL_TEXT("This example shows some basic inspection steps for bottle caps\n")
MIL_TEXT("and content. The following features will be inspected:\n")
MIL_TEXT(" 1. Surface defect detection\n")
MIL_TEXT(" 2. Fill level measurement \n")
MIL_TEXT(" 3. Cap screw verification\n\n")
MIL_TEXT("[MODULES USED]\n")
MIL_TEXT("Modules used: Application, system, graphic, calibration, measurement, \n")
MIL_TEXT(" blob, model finder\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("BottleCapAndContentInspection/")
#define PRODUCT0_PATH EXAMPLE_IMAGE_PATH MIL_TEXT("Product0/")
int MosMain(void)
{
CTargetAlignmentTask Prod0TargetAlignment(PRODUCT0_PATH MIL_TEXT("BottleContour.mmf"), PRODUCT0_PATH MIL_TEXT("EmptyBottleTemplate.mim"), M_RED);
CDefectDetectionTask Prod0DefectDetection(PRODUCT0_PATH MIL_TEXT("EmptyBottleTemplate.mim"),
PRODUCT0_PATH MIL_TEXT("EmptyBottleTemplateMask.mim"),
enAbsoluteDiff,
enTriangleBisection,
M_RED,
&Prod0TargetAlignment,
&Prod0TargetAlignment);
CModAlignmentTask Prod0View1Alignment(PRODUCT0_PATH MIL_TEXT("BottleContour.mmf"), M_RED);
CSimpleFixture Prod0FillLevelFixture(0, 0, -90, &Prod0View1Alignment);
CPositionInspection Prod0FillLevel(PRODUCT0_PATH MIL_TEXT("FillLevel.mrk"), MIL_TEXT("fill level"), -170, 5, M_RED, &Prod0FillLevelFixture);
CModAlignmentTask Prod0View2Alignment(PRODUCT0_PATH MIL_TEXT("BottleContour.mmf"), M_RED);
CSimpleFixture Prod0CapFixture(0, -330, 0, &Prod0View2Alignment);
CCapScrewInspection Prod0CapScrew(PRODUCT0_PATH MIL_TEXT("CapScrew.mrk"), 5, 2, M_RED, &Prod0CapFixture);
CInspectionTask* Prod0Image0Tasks[] = { &Prod0TargetAlignment, &Prod0DefectDetection };
CInspectionTask* Prod0Image1Tasks[] = { &Prod0View1Alignment , &Prod0FillLevelFixture, &Prod0FillLevel };
CInspectionTask* Prod0Image2Tasks[] = { &Prod0View2Alignment , &Prod0CapFixture , &Prod0CapScrew };
SImageTaskList Prod0ImagesTaskList[] =
{
CREATE_LIST(Prod0Image0Tasks, MIL_TEXT("Surface defect detection")),
CREATE_LIST(Prod0Image1Tasks, MIL_TEXT("Fill level measurement")),
CREATE_LIST(Prod0Image2Tasks, MIL_TEXT("Cap screw verification")),
};
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), enSequential, 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("BOTTLE CAP AND CONTENT 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;
}