VC++开发人脸识别

来源:互联网 发布:aics6软件下载中文版 编辑:程序博客网 时间:2024/06/02 07:43

在论坛上看到一个用VC++写人脸识别应用程序的方法。

 声明:转自http://blog.csdn.net/yincheng01/article/details/8839154

FaceSDK可以帮助Visual C++, C#, VB, Jav以及Borland Delphi开发者构建基于Web, Windows, Linux和Macintosh的具有人脸识别功能的应用程序。

头文件如下,可以轻易构建一个人脸识别的应用程序。


软件下载:http://download.csdn.net/detail/yincheng01/4173385



[cpp] view plaincopyprint?
  1. #ifndef _LUXANDFACESDK_  
  2. #define _LUXANDFACESDK_  
  3.   
  4. #if defined( _WIN32 ) || defined ( _WIN64 )  
  5.     #define _FSDKIMPORT_ __declspec(dllimport) __cdecl  
  6.     #include <windows.h>  
  7. #else  
  8.     #define _FSDKIMPORT_  
  9.     #define __cdecl  
  10. #endif  
  11.   
  12. #ifdef __cplusplus  
  13. extern "C" {  
  14. #endif  
  15.   
  16. // Error codes  
  17.   
  18. #define FSDKE_OK                0  
  19. #define FSDKE_FAILED            -1  
  20. #define FSDKE_NOT_ACTIVATED     -2  
  21. #define FSDKE_OUT_OF_MEMORY     -3  
  22. #define FSDKE_INVALID_ARGUMENT  -4  
  23. #define FSDKE_IO_ERROR          -5  
  24. #define FSDKE_IMAGE_TOO_SMALL  -6  
  25. #define FSDKE_FACE_NOT_FOUND  -7  
  26. #define FSDKE_INSUFFICIENT_BUFFER_SIZE  -8  
  27. #define FSDKE_UNSUPPORTED_IMAGE_EXTENSION   -9  
  28. #define FSDKE_CANNOT_OPEN_FILE -10  
  29. #define FSDKE_CANNOT_CREATE_FILE -11  
  30. #define FSDKE_BAD_FILE_FORMAT -12  
  31. #define FSDKE_FILE_NOT_FOUND -13  
  32. #define FSDKE_CONNECTION_CLOSED     -14  
  33. #define FSDKE_CONNECTION_FAILED     -15  
  34. #define FSDKE_IP_INIT_FAILED    -16  
  35. #define FSDKE_NEED_SERVER_ACTIVATION -17  
  36.   
  37. // Facial feature count  
  38.   
  39. #define FSDK_FACIAL_FEATURE_COUNT   66  
  40.   
  41. // Types  
  42.   
  43. typedef enum {  
  44.     FSDK_MJPEG  
  45. } FSDK_VIDEOCOMPRESSIONTYPE;  
  46.   
  47. typedef enum {  
  48.     FSDK_IMAGE_GRAYSCALE_8BIT,  
  49.     FSDK_IMAGE_COLOR_24BIT,  
  50.     FSDK_IMAGE_COLOR_32BIT    
  51. } FSDK_IMAGEMODE;   
  52.   
  53. typedef unsigned int HImage;  
  54.       
  55. typedef struct {   
  56.     int x, y;   
  57. } TPoint;  
  58.   
  59. typedef TPoint TPointArray [FSDK_FACIAL_FEATURE_COUNT];  
  60.   
  61. typedef TPoint FSDK_Features [FSDK_FACIAL_FEATURE_COUNT];  
  62.   
  63. typedef float FSDK_ConfidenceLevels [FSDK_FACIAL_FEATURE_COUNT];  
  64.   
  65. typedef struct {  
  66.     int xc, yc, w;  
  67.     double angle;  
  68. } TFacePosition;  
  69.   
  70. typedef struct {   
  71.     char ftemplate[16384];    
  72. } FSDK_FaceTemplate;   
  73.   
  74.   
  75.   
  76. typedef void (__cdecl *FSDK_ProgressCallbackFunction)(int);  
  77.   
  78. // Facial features  
  79.   
  80. #define FSDKP_LEFT_EYE  0  
  81. #define FSDKP_RIGHT_EYE 1  
  82. #define FSDKP_LEFT_EYE_INNER_CORNER 24  
  83. #define FSDKP_LEFT_EYE_OUTER_CORNER 23  
  84. #define FSDKP_LEFT_EYE_LOWER_LINE1  38  
  85. #define FSDKP_LEFT_EYE_LOWER_LINE2  27  
  86. #define FSDKP_LEFT_EYE_LOWER_LINE3  37  
  87. #define FSDKP_LEFT_EYE_UPPER_LINE1  35  
  88. #define FSDKP_LEFT_EYE_UPPER_LINE2  28  
  89. #define FSDKP_LEFT_EYE_UPPER_LINE3  36  
  90. #define FSDKP_LEFT_EYE_LEFT_IRIS_CORNER 29  
  91. #define FSDKP_LEFT_EYE_RIGHT_IRIS_CORNER    30  
  92. #define FSDKP_RIGHT_EYE_INNER_CORNER    25  
  93. #define FSDKP_RIGHT_EYE_OUTER_CORNER    26  
  94. #define FSDKP_RIGHT_EYE_LOWER_LINE1 41  
  95. #define FSDKP_RIGHT_EYE_LOWER_LINE2 31  
  96. #define FSDKP_RIGHT_EYE_LOWER_LINE3 42  
  97. #define FSDKP_RIGHT_EYE_UPPER_LINE1 40  
  98. #define FSDKP_RIGHT_EYE_UPPER_LINE2 32  
  99. #define FSDKP_RIGHT_EYE_UPPER_LINE3 39  
  100. #define FSDKP_RIGHT_EYE_LEFT_IRIS_CORNER    33  
  101. #define FSDKP_RIGHT_EYE_RIGHT_IRIS_CORNER   34  
  102. #define FSDKP_LEFT_EYEBROW_INNER_CORNER 13  
  103. #define FSDKP_LEFT_EYEBROW_MIDDLE   16  
  104. #define FSDKP_LEFT_EYEBROW_MIDDLE_LEFT  18  
  105. #define FSDKP_LEFT_EYEBROW_MIDDLE_RIGHT 19  
  106. #define FSDKP_LEFT_EYEBROW_OUTER_CORNER 12  
  107. #define FSDKP_RIGHT_EYEBROW_INNER_CORNER    14  
  108. #define FSDKP_RIGHT_EYEBROW_MIDDLE  17  
  109. #define FSDKP_RIGHT_EYEBROW_MIDDLE_LEFT 20  
  110. #define FSDKP_RIGHT_EYEBROW_MIDDLE_RIGHT    21  
  111. #define FSDKP_RIGHT_EYEBROW_OUTER_CORNER    15  
  112. #define FSDKP_NOSE_TIP  2  
  113. #define FSDKP_NOSE_BOTTOM   49  
  114. #define FSDKP_NOSE_BRIDGE   22  
  115. #define FSDKP_NOSE_LEFT_WING    43  
  116. #define FSDKP_NOSE_LEFT_WING_OUTER  45  
  117. #define FSDKP_NOSE_LEFT_WING_LOWER  47  
  118. #define FSDKP_NOSE_RIGHT_WING   44  
  119. #define FSDKP_NOSE_RIGHT_WING_OUTER 46  
  120. #define FSDKP_NOSE_RIGHT_WING_LOWER 48  
  121. #define FSDKP_MOUTH_RIGHT_CORNER    3  
  122. #define FSDKP_MOUTH_LEFT_CORNER 4  
  123. #define FSDKP_MOUTH_TOP 54  
  124. #define FSDKP_MOUTH_TOP_INNER   61  
  125. #define FSDKP_MOUTH_BOTTOM  55  
  126. #define FSDKP_MOUTH_BOTTOM_INNER    64  
  127. #define FSDKP_MOUTH_LEFT_TOP    56  
  128. #define FSDKP_MOUTH_LEFT_TOP_INNER  60  
  129. #define FSDKP_MOUTH_RIGHT_TOP   57  
  130. #define FSDKP_MOUTH_RIGHT_TOP_INNER 62  
  131. #define FSDKP_MOUTH_LEFT_BOTTOM 58  
  132. #define FSDKP_MOUTH_LEFT_BOTTOM_INNER   63  
  133. #define FSDKP_MOUTH_RIGHT_BOTTOM    59  
  134. #define FSDKP_MOUTH_RIGHT_BOTTOM_INNER  65  
  135. #define FSDKP_NASOLABIAL_FOLD_LEFT_UPPER    50  
  136. #define FSDKP_NASOLABIAL_FOLD_LEFT_LOWER    52  
  137. #define FSDKP_NASOLABIAL_FOLD_RIGHT_UPPER   51  
  138. #define FSDKP_NASOLABIAL_FOLD_RIGHT_LOWER   53  
  139. #define FSDKP_CHIN_BOTTOM   11  
  140. #define FSDKP_CHIN_LEFT 9  
  141. #define FSDKP_CHIN_RIGHT    10  
  142. #define FSDKP_FACE_CONTOUR1 7  
  143. #define FSDKP_FACE_CONTOUR2 5  
  144. #define FSDKP_FACE_CONTOUR12    6  
  145. #define FSDKP_FACE_CONTOUR13    8     
  146.   
  147.   
  148. // Initialization functions  
  149. int _FSDKIMPORT_ FSDK_ActivateLibrary(char * LicenseKey);  
  150. int _FSDKIMPORT_ FSDK_GetHardware_ID(char * HardwareID);  
  151. int _FSDKIMPORT_ FSDK_GetLicenseInfo(char * LicenseInfo);  
  152. int _FSDKIMPORT_ FSDK_SetNumThreads(int Num);  
  153. int _FSDKIMPORT_ FSDK_GetNumThreads(int * Num);  
  154. int _FSDKIMPORT_ FSDK_Initialize(char * DataFilesPath);  
  155. int _FSDKIMPORT_ FSDK_Finalize();  
  156.   
  157. // Face detection functions  
  158. int _FSDKIMPORT_ FSDK_DetectEyes(HImage Image, FSDK_Features * FacialFeatures);  
  159. int _FSDKIMPORT_ FSDK_DetectEyesInRegion(HImage Image, TFacePosition * FacePosition, FSDK_Features * FacialFeatures);  
  160. int _FSDKIMPORT_ FSDK_DetectFace(HImage Image, TFacePosition* FacePosition);  
  161. int _FSDKIMPORT_ FSDK_DetectMultipleFaces(HImage Image, int * DetectedCount, TFacePosition * FaceArray, int MaxSize);  
  162. int _FSDKIMPORT_ FSDK_DetectFacialFeatures(HImage Image, FSDK_Features * FacialFeatures);  
  163. int _FSDKIMPORT_ FSDK_DetectFacialFeaturesInRegion(HImage Image, TFacePosition * FacePosition, FSDK_Features * FacialFeatures);  
  164. int _FSDKIMPORT_ FSDK_DetectFacialFeaturesEx(HImage Image, FSDK_Features * FacialFeatures, FSDK_ConfidenceLevels * ConfidenceLevels);  
  165. int _FSDKIMPORT_ FSDK_DetectFacialFeaturesInRegionEx(HImage Image, TFacePosition * FacePosition, FSDK_Features * FacialFeatures, FSDK_ConfidenceLevels * ConfidenceLevels);  
  166. int _FSDKIMPORT_ FSDK_SetFaceDetectionParameters(bool HandleArbitraryRotations, bool DetermineFaceRotationAngle, int InternalResizeWidth);  
  167. int _FSDKIMPORT_ FSDK_SetFaceDetectionThreshold(int Threshold);  
  168.   
  169. // Image manipulation functions  
  170. int _FSDKIMPORT_ FSDK_CreateEmptyImage(HImage * Image);  
  171. int _FSDKIMPORT_ FSDK_LoadImageFromFile(HImage * Image, char * FileName);  
  172. int _FSDKIMPORT_ FSDK_LoadImageFromBuffer(HImage * Image, unsigned char * Buffer, int Width, int Height, int ScanLine, FSDK_IMAGEMODE ImageMode);  
  173. int _FSDKIMPORT_ FSDK_LoadImageFromJpegBuffer(HImage * Image, unsigned char * Buffer, unsigned int BufferLength);  
  174. int _FSDKIMPORT_ FSDK_LoadImageFromPngBuffer(HImage * Image, unsigned char * Buffer, unsigned int BufferLength);  
  175. int _FSDKIMPORT_ FSDK_FreeImage(HImage Image);  
  176. int _FSDKIMPORT_ FSDK_SaveImageToFile(HImage Image, char * FileName);  
  177.   
  178. #if defined( _WIN32 ) || defined ( _WIN64 )  
  179. int _FSDKIMPORT_ FSDK_LoadImageFromFileW(HImage * Image, wchar_t * FileName);  
  180. int _FSDKIMPORT_ FSDK_SaveImageToFileW(HImage Image, wchar_t * FileName);  
  181.   
  182. int _FSDKIMPORT_ FSDK_LoadImageFromHBitmap(HImage * Image, HBITMAP BitmapHandle);  
  183. int _FSDKIMPORT_ FSDK_SaveImageToHBitmap(HImage Image, HBITMAP * BitmapHandle);  
  184. #endif  
  185.   
  186. int _FSDKIMPORT_ FSDK_GetImageBufferSize(HImage Image, int * BufSize, FSDK_IMAGEMODE ImageMode);  
  187. int _FSDKIMPORT_ FSDK_SaveImageToBuffer(HImage Image, unsigned char * Buffer, FSDK_IMAGEMODE ImageMode);  
  188. int _FSDKIMPORT_ FSDK_SetJpegCompressionQuality(int Quality);  
  189. int _FSDKIMPORT_ FSDK_CopyImage(HImage SourceImage, HImage DestImage);  
  190. int _FSDKIMPORT_ FSDK_ResizeImage(HImage SourceImage, double ratio, HImage DestImage);  
  191. int _FSDKIMPORT_ FSDK_RotateImage90(HImage SourceImage, int Multiplier, HImage DestImage);  
  192. int _FSDKIMPORT_ FSDK_RotateImage(HImage SourceImage, double angle, HImage DestImage);  
  193. int _FSDKIMPORT_ FSDK_RotateImageCenter(HImage SourceImage, double angle, double xCenter, double yCenter, HImage DestImage);  
  194. int _FSDKIMPORT_ FSDK_CopyRect(HImage SourceImage, int x1, int y1, int x2, int y2, HImage DestImage);  
  195. int _FSDKIMPORT_ FSDK_CopyRectReplicateBorder(HImage SourceImage, int x1, int y1, int x2, int y2, HImage DestImage);  
  196. int _FSDKIMPORT_ FSDK_MirrorImage(HImage Image, bool UseVerticalMirroringInsteadOfHorizontal);  
  197. int _FSDKIMPORT_ FSDK_GetImageWidth(HImage SourceImage, int * Width);  
  198. int _FSDKIMPORT_ FSDK_GetImageHeight(HImage SourceImage, int * Height);  
  199. int _FSDKIMPORT_ FSDK_ExtractFaceImage(HImage Image, FSDK_Features * FacialFeatures, int Width, int Height, HImage * ExtractedFaceImage, FSDK_Features * ResizedFeatures);  
  200. int _FSDKIMPORT_ FSDK_GetImageData(HImage Image, unsigned char ** Data, int * Width, int * Height, int * ScanLine, FSDK_IMAGEMODE * ColorMode);  
  201.   
  202.   
  203. // Matching  
  204. int _FSDKIMPORT_ FSDK_GetFaceTemplate(HImage Image, FSDK_FaceTemplate * FaceTemplate);  
  205. int _FSDKIMPORT_ FSDK_GetFaceTemplateInRegion(HImage Image, TFacePosition * FacePosition, FSDK_FaceTemplate * FaceTemplate);  
  206. int _FSDKIMPORT_ FSDK_GetFaceTemplateUsingFeatures(HImage Image, FSDK_Features * FacialFeatures, FSDK_FaceTemplate * FaceTemplate);  
  207. int _FSDKIMPORT_ FSDK_GetFaceTemplateUsingEyes(HImage Image, FSDK_Features * eyeCoords, FSDK_FaceTemplate * FaceTemplate);  
  208. int _FSDKIMPORT_ FSDK_MatchFaces(FSDK_FaceTemplate * FaceTemplate1, FSDK_FaceTemplate * FaceTemplate2, float * Similarity);  
  209. int _FSDKIMPORT_ FSDK_GetMatchingThresholdAtFAR(float FARValue, float * Threshold);  
  210. int _FSDKIMPORT_ FSDK_GetMatchingThresholdAtFRR(float FRRValue, float * Threshold);  
  211. int _FSDKIMPORT_ FSDK_GetDetectedFaceConfidence(int * Confidence);  
  212.   
  213.   
  214. // Webcam usage  
  215. int _FSDKIMPORT_  FSDK_SetHTTPProxy(char * ServerNameOrIPAddress, unsigned short Port, char * UserName, char * Password);  
  216.   
  217. int _FSDKIMPORT_  FSDK_OpenIPVideoCamera(FSDK_VIDEOCOMPRESSIONTYPE CompressionType, char * URL, char * Username, char * Password, int TimeoutSeconds, int * CameraHandle);  
  218. int _FSDKIMPORT_  FSDK_CloseVideoCamera(int CameraHandle);  
  219. int _FSDKIMPORT_  FSDK_GrabFrame(int CameraHandle, HImage * Image);  
  220.   
  221.   
  222. int _FSDKIMPORT_  FSDK_InitializeCapturing(void);  
  223. int _FSDKIMPORT_  FSDK_FinalizeCapturing(void);  
  224.   
  225. #if defined( _WIN32 ) || defined ( _WIN64 )  
  226. typedef struct {  
  227.     int Width;  
  228.     int Height;  
  229.     int BPP;  
  230. } FSDK_VideoFormatInfo;  
  231.   
  232. int _FSDKIMPORT_  FSDK_SetCameraNaming(bool UseDevicePathAsName);  
  233. int _FSDKIMPORT_  FSDK_GetCameraList(wchar_t *** CameraList, int * CameraCount);  
  234. int _FSDKIMPORT_  FSDK_GetCameraListEx(wchar_t *** CameraNameList, wchar_t *** CameraDevicePathList, int * CameraCount);  
  235. int _FSDKIMPORT_  FSDK_FreeCameraList(wchar_t ** CameraList, int CameraCount);  
  236. int _FSDKIMPORT_  FSDK_GetVideoFormatList(wchar_t * CameraName, FSDK_VideoFormatInfo ** VideoFormatList, int * VideoFormatCount);  
  237. int _FSDKIMPORT_  FSDK_FreeVideoFormatList(FSDK_VideoFormatInfo * VideoFormatList);  
  238. int _FSDKIMPORT_  FSDK_SetVideoFormat(wchar_t * CameraName, FSDK_VideoFormatInfo VideoFormat);  
  239. int _FSDKIMPORT_  FSDK_OpenVideoCamera(wchar_t * CameraName, int * CameraHandle);  
  240. #endif  
  241.   
  242.   
  243. #ifdef __cplusplus  
  244. }  
  245. #endif  
  246.   
  247.   
  248. #endif  

原创粉丝点击