Upgrade face-engine
[adaptation/face-engine.git] / include / face-engine.h
1 /*
2  Copyright (c) 2000-2012 Samsung Electronics Co., Ltd All Rights Reserved
3
4  This file is part of face-engine
5  Written by Hyunwoo Kim <hw4444.kim@samsung.com>
6
7  PROPRIETARY/CONFIDENTIAL
8
9  This software is the confidential and proprietary information of
10  SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
11  disclose such Confidential Information and shall use it only in
12  accordance with the terms of the license agreement you entered
13  into with SAMSUNG ELECTRONICS.
14  SAMSUNG make no representations or warranties about the suitability
15  of the software, either express or implied, including but not limited
16  to the implied warranties of merchantability, fitness for a particular
17  purpose, or non-infringement. SAMSUNG shall not be liable for any
18  damages suffered by licensee as a result of using, modifying or
19  distributing this software or its derivatives.
20  */
21
22
23 #ifndef __FACE_ENGINE_H__
24 #define __FACE_ENGINE_H__
25
26 #include <stdbool.h>
27
28 /**
29  * @brief Facial engine handle type.
30  */
31 typedef void* face_engine_h;
32
33 /**
34  * @brief Enumerations of error codes for the FacialEngine API.
35  */
36 typedef enum {
37         FACE_ENGINE_ERROR_NONE = 0,                     /**< Successful */
38         FACE_ENGINE_ERROR_INVALID_PARAMTER = -1,        /**< A specified input parameter is invalid. */
39         FACE_ENGINE_ERROR_OUT_OF_MEMORY = -2,           /**< The memory is insufficient. */
40         FACE_ENGINE_ERROR_OPERATION_FAILED = -3,                /**< Does not support this property. À߸øµÈ state */
41         FACE_ENGINE_ERROR_FAILURE = -4,                         /**< A system error has occurred. ³»ºÎ error */
42         FACE_ENGINE_ERROR_ENGINE_NOT_FOUND = -5,
43 } face_engine_error_e;
44
45 /**
46  * @brief Enumerations of input image format for the FacialEngine API.
47  */
48 typedef enum {
49         FACE_ENGINE_IMAGE_FORMAT_Y,                     /**< luminance only image*/
50 } face_engine_image_colorspace_e;
51
52 /**
53  * @brief Enumerations of facial expression that recognized for the FacialEngine API.
54  */
55 typedef enum {
56         FACE_ENGINE_EXPRESSION_UNKNOWN,
57         FACE_ENGINE_EXPRESSION_NUETRAL,         /**< Normal expression */
58         FACE_ENGINE_EXPRESSION_ANGRY,                   /**< Angry expression */
59         FACE_ENGINE_EXPRESSION_SMILE,                   /**< Cheerful expression */
60         FACE_ENGINE_EXPRESSION_SURPRISE,                /**< Suprised expression */
61 } face_engine_expression_e;
62
63 /**
64  * @brief Enumerations of the eye state for the FacialEngine API.
65  */
66 typedef enum {
67         FACE_ENGINE_EYE_UNKNOWN,                /**< The no eye state, when the eye detect fails */
68         FACE_ENGINE_EYE_OPENED,         /**< The state when eye is opened */
69         FACE_ENGINE_EYE_CLOSED,         /**< The state when eye is closed */
70 } face_engine_eye_e;
71
72 typedef enum {
73         FACE_ENGINE_IMAGE_TYPE_SINGLE,  /**< */
74         FACE_ENGINE_IMAGE_TYPE_CONTINIOUS,
75 } face_engine_image_type_e;
76
77 typedef struct {
78         int x;          /**< x-coordinate */
79         int y;          /**< y-coordinate */
80 } face_engine_point_t;
81
82 typedef struct {
83         int x;          /**< most left coordinate of detected face region  */
84         int y;          /**< most top coordinate of detected face region  */
85         int w;          /**< width of detected face region  */
86         int h;          /**<  height of detected face region */
87 } face_engine_rect_t;
88
89 typedef struct {
90         unsigned char *pixel;            /**< pixel data */
91
92         int width;                                       /**< image data's width */
93         int height;                                      /**< image data's height */
94
95         face_engine_image_colorspace_e colorspace;      /**< color space */
96 } face_engine_image_t;
97
98 typedef union {
99         struct {
100                 face_engine_rect_t face;        // 16
101
102                 face_engine_point_t lefteye;    // 8
103                 face_engine_point_t righteye;   // 8
104
105                 face_engine_rect_t mouse;       // 16
106         };
107
108         char Reserved[128];
109 } face_engine_component_t;
110
111 typedef enum {
112         FACE_ENGINE_DETECTION_MODE_FAST,
113         FACE_ENGINE_DETECTION_MODE_ROBUST,
114 } face_engine_detection_mode_e;
115
116
117 typedef union {
118         struct {
119                 int nMaxFaceNum; /**< */
120                 int nScale;             /**< */
121                 int nInterval; /**< */
122
123                 face_engine_detection_mode_e eMode; /**< Default is fast*/
124         };
125
126         char Reserved[32];
127 } face_engine_param_t;
128
129 typedef struct {
130         unsigned char *data;    /**< result data of face information */
131         unsigned int len;               /**< size of result data */// in byte unit
132 } face_engine_feature_t;
133
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137
138
139 face_engine_error_e face_engine_create(face_engine_h *handle);
140 face_engine_error_e face_engine_destroy(face_engine_h handle);
141
142 face_engine_error_e face_engine_get_param(face_engine_h handle, face_engine_param_t *param);
143 face_engine_error_e face_engine_set_param(face_engine_h handle, const face_engine_param_t *param);
144
145 /*
146         face & orientation should be freed using free() by user.
147
148         orientation indicates degree and it's range is 0~359.
149 */
150 face_engine_error_e face_engine_detect_faces(face_engine_h handle, face_engine_image_type_e image_type, const face_engine_image_t *image, face_engine_rect_t *face[], int *orientation[], int *count);
151
152 face_engine_error_e face_engine_track_faces(face_engine_h handle, const face_engine_rect_t *prev_rect, face_engine_rect_t *cur_rect);
153
154 face_engine_error_e face_engine_extract_face_component(face_engine_h handle, const face_engine_image_t *image, const face_engine_rect_t *rect, face_engine_component_t *component);
155 face_engine_error_e face_engine_extract_face_feature(face_engine_h handle, const face_engine_image_t *image, const face_engine_component_t *component, face_engine_feature_t *feature);
156
157 face_engine_error_e face_engine_compare_face_feature( face_engine_h handle, const face_engine_feature_t *A, const face_engine_feature_t *B, int *similarity);
158
159 face_engine_error_e face_engine_recognize_face_expression(face_engine_h handle, const face_engine_image_t *image , const face_engine_component_t *component, face_engine_expression_e *expression);
160
161 face_engine_error_e face_engine_recognize_blink(face_engine_h handle,  const face_engine_image_t *image, const face_engine_component_t *component, face_engine_eye_e *lefteye,  face_engine_eye_e *righteye);
162
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168
169 #endif          // __TIZEN_UIX_FACE_ENGINE_H__
170