6 static bool _validate_face_component_h(face_component_h face_component)
8 if ( face_component == NULL )
13 if ( face_component->magic != FACE_COMPONENT_MAGIC )
23 EXPORT_API int face_component_create(face_component_h *face_component)
25 if ( face_component == NULL )
27 LOG_ERROR("Out pointer is NULL. %s", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
28 return FACE_ERROR_INVALID_PARAMTER;
31 FaceComponent *facecomponent = NULL;
33 facecomponent = (FaceComponent *)calloc(1, sizeof(FaceComponent));
35 if ( facecomponent == NULL )
37 LOG_ERROR("Cannot allocate face component handle");
38 return FACE_ERROR_OUT_OF_MEMORY;
41 facecomponent->magic = FACE_COMPONENT_MAGIC;
43 *face_component = facecomponent;
45 return FACE_ERROR_NONE;
49 EXPORT_API int face_component_destroy(face_component_h face_component)
51 if ( _validate_face_component_h(face_component) == false )
53 LOG_ERROR("Invalid face component. %s", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
54 return FACE_ERROR_INVALID_PARAMTER;
57 face_component->magic = FACE_INVALID_MAGIC;
61 return FACE_ERROR_NONE;
65 EXPORT_API int face_component_get_face_rect(face_component_h face_component, face_rect_s *face)
67 if ( _validate_face_component_h(face_component) == false )
69 LOG_ERROR("Invalid component handle. %s", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
70 return FACE_ERROR_INVALID_PARAMTER;
75 LOG_ERROR("[%s] face is NULL", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
76 return FACE_ERROR_INVALID_PARAMTER;
79 if ( face_component->face.w <= 0 || face_component->face.h <= 0 )
81 LOG_ERROR("[%s] Face is not founded", _face_convert_error(FACE_ERROR_COMPONENT_NOT_FOUND));
82 return FACE_ERROR_COMPONENT_NOT_FOUND;
85 face->x = face_component->face.x;
86 face->y = face_component->face.y;
87 face->w = face_component->face.w;
88 face->h = face_component->face.h;
90 return FACE_ERROR_NONE;
94 EXPORT_API int face_component_get_left_eye_point(face_component_h face_component, face_point_s *leye)
96 if ( _validate_face_component_h(face_component) == false )
98 LOG_ERROR("Invalid component handle. %s", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
99 return FACE_ERROR_INVALID_PARAMTER;
104 LOG_ERROR("[%s] leye is NULL", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
105 return FACE_ERROR_INVALID_PARAMTER;
108 if ( face_component->lefteye.x <= 0 || face_component->lefteye.y <= 0 )
110 LOG_ERROR("[%s] Left eye is not founded", _face_convert_error(FACE_ERROR_COMPONENT_NOT_FOUND));
111 return FACE_ERROR_COMPONENT_NOT_FOUND;
114 leye->x = face_component->lefteye.x;
115 leye->y = face_component->lefteye.y;
118 return FACE_ERROR_NONE;
122 EXPORT_API int face_component_get_right_eye_point(face_component_h face_component, face_point_s *reye)
124 if ( _validate_face_component_h(face_component) == false )
126 LOG_ERROR("Invalid component handle. %s", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
127 return FACE_ERROR_INVALID_PARAMTER;
132 LOG_ERROR("[%s] leye is NULL", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
133 return FACE_ERROR_INVALID_PARAMTER;
136 if ( face_component->righteye.x <= 0 || face_component->righteye.y <= 0 )
138 LOG_ERROR("[%s] Right eye is not founded", _face_convert_error(FACE_ERROR_COMPONENT_NOT_FOUND));
139 return FACE_ERROR_COMPONENT_NOT_FOUND;
142 reye->x = face_component->righteye.x;
143 reye->y = face_component->righteye.y;
145 return FACE_ERROR_NONE;
149 EXPORT_API int face_component_get_mouse_rect(face_component_h face_component, face_rect_s *mouse)
151 if ( _validate_face_component_h(face_component) == false )
153 LOG_ERROR("Invalid component handle. %s", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
154 return FACE_ERROR_INVALID_PARAMTER;
159 LOG_ERROR("[%s] mouse is NULL", _face_convert_error(FACE_ERROR_INVALID_PARAMTER));
160 return FACE_ERROR_INVALID_PARAMTER;
163 if ( face_component->mouse.w <= 0 || face_component->mouse.h <= 0 )
165 LOG_ERROR("[%s] Mouse position is not founded", _face_convert_error(FACE_ERROR_COMPONENT_NOT_FOUND));
166 return FACE_ERROR_COMPONENT_NOT_FOUND;
169 mouse->x = face_component->mouse.x;
170 mouse->y = face_component->mouse.y;
171 mouse->w = face_component->mouse.w;
172 mouse->h = face_component->mouse.h;
174 return FACE_ERROR_NONE;