add base code
[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 union {
112         struct {
113                 int nMaxFaceNum; /**< */
114                 int nScale;             /**< */
115                 int nInterval; /**< */
116                 int nDetectionOption;           /* 0 for FAST, 1 for ROBUST */
117         };
118
119         char Reserved[32];
120 } face_engine_param_t;
121
122 typedef struct {
123         unsigned char *data;    /**< result data of face information */
124         unsigned int len;               /**< size of result data */// in byte unit
125 } face_engine_feature_t;
126
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 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 *count);
140
141 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);
142
143 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);
144 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);
145
146 face_engine_error_e face_engine_compare_face_feature(const face_engine_feature_t *A, const face_engine_feature_t *B, int *similarity);
147
148 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);
149
150 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);
151
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157
158 #endif          // __TIZEN_UIX_FACE_ENGINE_H__
159