// TestLoadImageFromFile.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "LuxandFaceSDK.h"
#include <iostream>
using namespace std;
#pragma comment(lib,"facesdk.lib")
int _tmain(int argc, _TCHAR* argv[])
{
if (FSDKE_OK != FSDK_ActivateLibrary("52D447EB32185AA618548333953F33318792F8EE9"))
{
MessageBox(NULL,L"请输入正确的类库注册信息",L"错误",MB_OK | MB_ICONSTOP);
exit(-1);
}
//初始化类库
FSDK_Initialize("");
HImage hFirestImage; //第一幅图像句柄
if (FSDKE_OK != FSDK_LoadImageFromFile(&hFirestImage, ".//picture//k.jpg") )
{
MessageBox(NULL,L"第一幅图像载入失败",L"错误",MB_OK | MB_ICONSTOP);
exit(-1);
}
HImage hSecondImage; //第二幅图像句柄
if (FSDKE_OK != FSDK_LoadImageFromFile(&hSecondImage, ".//picture//k.jpg") )
{
MessageBox(NULL,L"第二幅图像载入失败",L"错误",MB_OK | MB_ICONSTOP);
exit(-1);
}
int nFirstImageWidth = 0;
int nFirstImageHeight = 0;
FSDK_GetImageWidth(hFirestImage,&nFirstImageWidth);
FSDK_GetImageHeight(hFirestImage,&nFirstImageHeight);
cout<<nFirstImageWidth<<endl;
cout<<nFirstImageHeight<<endl;
TFacePosition FirstFacePostion;
TFacePosition SecondFacePostion ;
//检测第一幅图像的人脸
if (FSDKE_OK == FSDK_DetectFace(hFirestImage,&FirstFacePostion))
{
cout<<"貌似检测到人脸了"<<endl;
cout<<"人脸的位置大致在于 : "<<endl;
cout<<FirstFacePostion.xc<<endl;
cout<<FirstFacePostion.yc<<endl;
cout<<FirstFacePostion.angle<<endl;
cout<<FirstFacePostion.w<<endl;
}
else
{
cout<<"貌似没有检测到人脸"<<endl;
exit(-1);
}
if ( FSDKE_OK == FSDK_DetectFace(hSecondImage,&SecondFacePostion))
{
cout<<"貌似又检测到人脸了"<<endl;
cout<<"人脸的大致位置在于 :"<<endl;
cout<<SecondFacePostion.xc<<endl;
cout<<SecondFacePostion.yc<<endl;
cout<<SecondFacePostion.w<<endl;
cout<<SecondFacePostion.angle<<endl;
}
else
{
cout<<"貌似又没检测到人脸"<<endl;
exit(-1);
}
getchar();
return 0;
}
运行结果如下图所示 :