#include <mil.h>
#define IMAGE_FILE M_IMAGE_PATH MIL_TEXT("board.mim")
#define NB_LOOP 100
int MosMain(void)
{
MIL_ID MilApplication,
MilSystem,
MilDisplay,
MilImageDisp,
MilImageProc,
MilImageSrc,
MilDigitizer;
MIL_INT SizeX,
SizeY,
SizeBand,
Selection,
BoardType,
n;
double Time;
MappAlloc(M_NULL, M_DEFAULT, &MilApplication);
MsysAlloc(M_DEFAULT, M_SYSTEM_SOLIOS, M_DEFAULT, M_DEFAULT, &MilSystem);
MsysInquire(MilSystem, M_BOARD_TYPE, &BoardType);
if((BoardType & M_PF) == 0)
{
MosPrintf(MIL_TEXT("This example requires a processing FPGA to run.\n"));
MosPrintf(MIL_TEXT("Press <Enter> to quit.\n"));
MosGetch();
MappFreeDefault(MilApplication, MilSystem, M_NULL, M_NULL, M_NULL);
return 1;
}
MdispAlloc(MilSystem, M_DEV0, MIL_TEXT("M_DEFAULT"), M_DEFAULT, &MilDisplay);
MosPrintf(MIL_TEXT("Please select the type of source image to process:\n"));
MosPrintf(MIL_TEXT("(1)- Grab image\n"));
MosPrintf(MIL_TEXT("(2)- Static image\n"));
Selection = MosGetch();
switch(Selection)
{
case '1':
MdigAlloc(MilSystem, M_DEFAULT, MIL_TEXT("M_DEFAULT"),
M_DEFAULT, &MilDigitizer);
SizeX = MdigInquire(MilDigitizer, M_SIZE_X, M_NULL);
SizeY = MdigInquire(MilDigitizer, M_SIZE_Y, M_NULL);
SizeBand = MdigInquire(MilDigitizer, M_SIZE_BAND, M_NULL);
break;
case '2':
default:
MilDigitizer = M_NULL;
SizeX = MbufDiskInquire(IMAGE_FILE, M_SIZE_X, M_NULL);
SizeY = MbufDiskInquire(IMAGE_FILE, M_SIZE_Y, M_NULL);
SizeBand = MbufDiskInquire(IMAGE_FILE, M_SIZE_BAND, M_NULL);
break;
}
MosPrintf(MIL_TEXT("Processed image will be: %dx%d %d bands"), SizeX, SizeY, SizeBand);
if(MilDigitizer)
{
MbufAllocColor(MilSystem,
SizeBand,
SizeX,
SizeY,
8+M_UNSIGNED,
M_IMAGE+M_GRAB+M_PROC+M_FPGA_ACCESSIBLE+M_SHARED,
&MilImageSrc);
MdigGrab(MilDigitizer, MilImageSrc);
}
else
{
MbufAllocColor(MilSystem,
SizeBand,
SizeX,
SizeY,
8+M_UNSIGNED,
M_IMAGE+M_PROC+M_FPGA_ACCESSIBLE+M_SHARED,
&MilImageSrc);
MbufLoad(IMAGE_FILE, MilImageSrc);
}
MbufAllocColor(MilSystem,
SizeBand,
SizeX,
SizeY,
8+M_UNSIGNED,
M_IMAGE+M_GRAB+M_DISP+M_FPGA_ACCESSIBLE,
&MilImageDisp);
MbufAllocColor(MilSystem,
SizeBand,
SizeX,
SizeY,
8+M_UNSIGNED,
M_IMAGE+M_PROC+M_GRAB+M_HOST_MEMORY+M_FPGA_ACCESSIBLE,
&MilImageProc);
MbufCopy(MilImageSrc, MilImageDisp);
MdispSelect(MilDisplay, MilImageDisp);
MosPrintf(MIL_TEXT("\nMIL FDK:\n"));
MosPrintf(MIL_TEXT("--------\n\n"));
MosPrintf(MIL_TEXT("This example tests and times the AddConstant function\n"));
MosPrintf(MIL_TEXT("accelereted on the Solios Processing FPGA.\n"));
MosPrintf(MIL_TEXT("Press a key to continue.\n\n"));
MosGetch();
for (n= 0; n < NB_LOOP+1; n++)
{
if (n == 1)
MappTimer(M_DEFAULT, M_TIMER_RESET+M_SYNCHRONOUS, M_NULL);
MimArith(MilImageSrc, 0x40, MilImageProc, M_ADD_CONST+M_SATURATION);
}
MappTimer(M_DEFAULT, M_TIMER_READ+M_SYNCHRONOUS, &Time);
MosPrintf(MIL_TEXT("Add constant time: %.3f ms.\n"), Time*1000/NB_LOOP);
MbufCopy(MilImageProc, MilImageDisp);
MosPrintf(MIL_TEXT("Press a key to terminate.\n\n"));
MosGetch();
if(MilDigitizer)
MdigFree(MilDigitizer);
MbufFree(MilImageSrc);
MbufFree(MilImageProc);
MbufFree(MilImageDisp);
MdispFree(MilDisplay);
MsysFree(MilSystem);
MappFree(MilApplication);
return 0;
}