Initialize Tizen 2.3
[adaptation/face-engine.git] / include / face-engine.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *        http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __FACE_ENGINE_H__
18 #define __FACE_ENGINE_H__
19
20 #include <stdbool.h>
21
22 /**
23  * @brief Facial engine handle type.
24  */
25 typedef void* face_engine_h;
26
27 /**
28  * @brief Enumerations of error codes for the FacialEngine API.
29  */
30 typedef enum {
31         FACE_ENGINE_ERROR_NONE = 0,                     /**< Successful */
32         FACE_ENGINE_ERROR_INVALID_PARAMTER = -1,        /**< A specified input parameter is invalid. */
33         FACE_ENGINE_ERROR_OUT_OF_MEMORY = -2,           /**< The memory is insufficient. */
34         FACE_ENGINE_ERROR_OPERATION_FAILED = -3,                /**< Does not support this property. À߸øµÈ state */
35         FACE_ENGINE_ERROR_FAILURE = -4,                         /**< A system error has occurred. ³»ºÎ error */
36         FACE_ENGINE_ERROR_ENGINE_NOT_FOUND = -5,
37 } face_engine_error_e;
38
39 /**
40  * @brief Enumerations of input image format for the FacialEngine API.
41  */
42 typedef enum {
43         FACE_ENGINE_IMAGE_FORMAT_Y,                     /**< luminance only image*/
44 } face_engine_image_colorspace_e;
45
46 /**
47  * @brief Enumerations of facial expression that recognized for the FacialEngine API.
48  */
49 typedef enum {
50         FACE_ENGINE_EXPRESSION_UNKNOWN,
51         FACE_ENGINE_EXPRESSION_NUETRAL,         /**< Normal expression */
52         FACE_ENGINE_EXPRESSION_ANGRY,                   /**< Angry expression */
53         FACE_ENGINE_EXPRESSION_SMILE,                   /**< Cheerful expression */
54         FACE_ENGINE_EXPRESSION_SURPRISE,                /**< Suprised expression */
55 } face_engine_expression_e;
56
57 /**
58  * @brief Enumerations of the eye state for the FacialEngine API.
59  */
60 typedef enum {
61         FACE_ENGINE_EYE_UNKNOWN,                /**< The no eye state, when the eye detect fails */
62         FACE_ENGINE_EYE_OPENED,         /**< The state when eye is opened */
63         FACE_ENGINE_EYE_CLOSED,         /**< The state when eye is closed */
64 } face_engine_eye_e;
65
66 typedef enum {
67         FACE_ENGINE_IMAGE_TYPE_SINGLE,  /**< */
68         FACE_ENGINE_IMAGE_TYPE_CONTINUOUS,
69 } face_engine_image_type_e;
70
71 typedef struct {
72         int x;          /**< x-coordinate */
73         int y;          /**< y-coordinate */
74 } face_engine_point_t;
75
76 typedef struct {
77         int x;          /**< most left coordinate of detected face region  */
78         int y;          /**< most top coordinate of detected face region  */
79         int w;          /**< width of detected face region  */
80         int h;          /**<  height of detected face region */
81 } face_engine_rect_t;
82
83 typedef struct {
84         unsigned char *pixel;            /**< pixel data */
85
86         int width;                                       /**< image data's width */
87         int height;                                      /**< image data's height */
88
89         face_engine_image_colorspace_e colorspace;      /**< color space */
90 } face_engine_image_t;
91
92 typedef union {
93         struct {
94                 face_engine_rect_t face;        // 16
95
96                 face_engine_point_t lefteye;    // 8
97                 face_engine_point_t righteye;   // 8
98
99                 face_engine_rect_t mouth;       // 16
100         };
101
102         char Reserved[128];
103 } face_engine_component_t;
104
105 typedef enum {
106         FACE_ENGINE_DETECTION_MODE_FAST,
107         FACE_ENGINE_DETECTION_MODE_ROBUST,
108 } face_engine_detection_mode_e;
109
110
111 typedef union {
112         struct {
113                 int nMaxFaceNum; /**< */
114                 int nScale;             /**< */
115                 int nInterval; /**< */
116
117                 face_engine_detection_mode_e eMode; /**< Default is fast*/
118         };
119
120         char Reserved[32];
121 } face_engine_param_t;
122
123 typedef struct {
124         unsigned char *data;    /**< result data of face information */
125         unsigned int len;               /**< size of result data */// in byte unit
126 } face_engine_feature_t;
127
128 #ifdef __cplusplus
129 extern "C" {
130 #endif
131
132
133 face_engine_error_e face_engine_create(face_engine_h *handle);
134 face_engine_error_e face_engine_destroy(face_engine_h handle);
135
136 face_engine_error_e face_engine_get_param(face_engine_h handle, face_engine_param_t *param);
137 face_engine_error_e face_engine_set_param(face_engine_h handle, const face_engine_param_t *param);
138
139 /*
140         face & orientation should be freed using free() by user.
141
142         orientation indicates degree and it's range is 0~359.
143 */
144 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);
145
146 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);
147
148 face_engine_error_e face_engine_track_faces1(face_engine_h handle, const unsigned char *prev_image, const unsigned char *cur_image, int width, int height, face_engine_rect_t *prev_rect, face_engine_rect_t *cur_rect);
149
150 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);
151 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);
152
153 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);
154
155 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);
156
157 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);
158
159
160 #ifdef __cplusplus
161 }
162 #endif
163
164
165 #endif          // __TIZEN_UIX_FACE_ENGINE_H__
166