#include <ansi_c.h>
#include <analysis.h>
#include <formatio.h>
#include "Imaq_CVI.h"
#include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */
#include <userint.h>
#include "FACE_RECOGNIZE.h"
#include "stdio.h"
#include "stdlib.h"
/**************************************全局变量定义**************************************************/
static int TEXTBOX;
static int panelHandle;
static IPIImageRef DestImage_1,SourceImage_1,SourceImage_2,DestImage_2,DestImage_3,SourceImage_3;
double b[112][92],SourceArray[112][92],All_Image[10304][200],Aver_Vector[10304],Devition_Image[10304][200],Tran_Devi_Image[10304][200];
static ComplexNum Eigen_Vectors[200][200];
double stigma_matrix[200*200];
double Sort_Eigen_matrix[200][200];
static double pro_base[10304][200];
static double base[10304][200]; //特征向量空间
static char File_path[260];
static double all_coor[200][200];
int red,green,blue;//图像RGB向二值化转变的颜色分量设置,视图像的质量而定
int left_border, border_width, top_border, border_height;
/*****************************************************************************************************/
/****************************************main*********************************************************/
int main (int argc, char *argv[])
{
IPIError Error;
if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "FACE_RECOGNIZE.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
IPI_Create (&SourceImage_1, IPI_PIXEL_RGB32, 0);
IPI_Create (&DestImage_1, IPI_PIXEL_RGB32, 0);
IPI_Create (&SourceImage_2, IPI_PIXEL_U8, 0);
IPI_Create (&DestImage_2, IPI_PIXEL_U8, 0);
IPI_Create (&DestImage_3, IPI_PIXEL_RGB32, 0);
IPI_Create (&SourceImage_3, IPI_PIXEL_U8, 0);
RunUserInterface ();
IPI_CloseSys ();
return 0;
}
/************************************************************************88****************************/
/****************************open a color image and aver_filter******************************************/
int CVICALLBACK Open_Color_Image (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char lPath[260];
IPIError lError;
int lStatus;
int x,y,i,j,width,height,aver_color_value;
int rgb_color_value,sum=0;
switch (event)
{
case EVENT_COMMIT:
/************************averfilter*********************************************************/
lStatus=FileSelectPopup ("C:\\CVI401\\IMAQ_CVI\\Images", "*.bmp;*.tif;*.apd",
"", "", VAL_LOAD_BUTTON, 0, 0, 1, 0, lPath);
if(lStatus==VAL_EXISTING_FILE_SELECTED)
{
InsertTextBoxLine (PANEL, PANEL_TEXTBOX, -1,"彩图打开成功");
InsertTextBoxLine (PANEL, PANEL_TEXTBOX, -1,lPath);
lError = IPI_ReadFile (SourceImage_1, lPath, TRUE, NULL, NULL);
if(lError==IPI_ERR_NOERROR)
{
IPI_SetWindowAttribute (0, ATTR_LEFT, 10);
IPI_SetWindowAttribute (0, ATTR_TOP, 15);
IPI_WindDraw (SourceImage_1, 0, "Source Image", TRUE);
}
}
break;
}
return 0;
}
/************************color image averfilter and display image**************************************/
int CVICALLBACK Aver_Filter (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
IPI_ColorEqualize (SourceImage_1, DestImage_1, TRUE);
IPI_SetWindowAttribute (0, ATTR_LEFT, 10);
IPI_SetWindowAttribute (0, ATTR_TOP, 15);
IPI_WindDraw (DestImage_1, 0, "Destination Image", TRUE);
break;
}
return 0;
}
/********************************************************************************************************/
/******************************initiate the RGB value for 2_valuate****************************************/
int CVICALLBACK Bi_value (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
SetCtrlVal (PANEL, PANEL_R, 101);
SetCtrlVal (PANEL, PANEL_G, 99);
SetCtrlVal (PANEL, PANEL_B, 86);//RGB的初始值可依不同的相片设定
SetCtrlVal (PANEL, PANEL_NUMERICSLIDE_LEFT, 77);
SetCtrlVal (PANEL, PANEL_NUMERICSLIDE_RIGHT, 200);
SetCtrlVal (PANEL, PANEL_NUMERICSLIDE_UP, 120);
SetCtrlVal (PANEL, PANEL_NUMERICSLIDE_DOWN,200); //边界初始值设置
GetCtrlVal (PANEL, PANEL_R, &red);
GetCtrlVal (PANEL, PANEL_G, &green);
GetCtrlVal (PANEL, PANEL_B, &blue);
IPI_ColorThreshold (DestImage_1, SourceImage_2, IPI_RGB, 255, red,
255, green, 255, blue, 255);
IPI_SetWindowAttribute (0, ATTR_LEFT, 10);
IPI_SetWindowAttribute (0, ATTR_TOP, 15);
IPI_WindDraw (SourceImage_2, 0, "2_Value Image", TRUE);
break;
}
return 0;
}
/*********************************************************************************************************/
/********************************color image to 2 value RGB threshold seting******************************/
int CVICALLBACK SET_R (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (PANEL, PANEL_R, &red);
GetCtrlVal (PANEL, PANEL_G, &green);
GetCtrlVal (PANEL, PANEL_B, &blue);
IPI_ColorThreshold (SourceImage_1, SourceImage_2, IPI_RGB, 255, red,
255, green, 255, blue, 255);
IPI_SetWindowAttribute (0, ATTR_LEFT, 10);
IPI_SetWindowAttribute (0, ATTR_TOP, 15);
IPI_WindDraw (SourceImage_2, 0, "2_Value Image", TRUE);
break;
}
return 0;
}
int CVICALLBACK SET_G (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (PANEL, PANEL_R, &red);
GetCtrlVal (PANEL, PANEL_G, &green);
GetCtrlVal (PANEL, PANEL_B, &blue);
IPI_ColorThreshold (SourceImage_1, SourceImage_2, IPI_RGB, 255, red,
255, green, 255, blue, 255);
IPI_SetWindowAttribute (0, ATTR_LEFT, 10);
IPI_SetWindowAttribute (0, ATTR_TOP, 15);
IPI_WindDraw (SourceImage_2, 0, "2_Value Image", TRUE);
break;
}
return 0;
}
int CVICALLBACK SET_B (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int threshold_value;
int lHistogram[256];
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (PANEL, PANEL_R, &red);
GetCtrlVal (PANEL, PANEL_G, &green);
GetCtrlVal (PANEL, PANEL_B, &blue);
IPI_ColorThreshold (SourceImage_1, SourceImage_2, IPI_RGB, 255, red,
255, green, 255, blue, 255);
IPI_SetWindowAttribute (0, ATTR_LEFT, 10);
IPI_SetWindowAttribute (0, ATTR_TOP, 15);
IPI_WindDraw (SourceImage_2, 0, "2_Value Image", TRUE);
/*IPI_Histogram (SourceImage_1, IPI_NOMASK, 256, 0, 255, lHistogram, NULL);
DeleteGraphPlot (panel, PANEL_GRAPH_SHUIPING, -1, VAL_IMMEDIATE_DRAW);
PlotY (panel, PANEL_GRAPH_SHUIPING, lHistogram, 256, VAL_INTEGER,
VAL_THIN_LINE, VAL_SMALL_CROSS, VAL_SOLID, 1, VAL_DK_GREEN);*/
break;
}
return 0;
}
/*******************************************************************************************/
/*******************cut the up_down and left_right border***********************************/
int CVICALLBACK Border_Confirm (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
Rect Image_Scale;
switch (event)
{
case EVENT_COMMIT:
Image_Scale.top=top_border;
Image_Scale.left=left_border;
Image_Scale.width=border_width;
Image_Scale.height=border_height;
IPI_Extract (DestImage_2, SourceImage_3, 1, 1, Image_Scale);
IPI_Set
评论1