2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TIZEN_MEDIAVISION_FACE_DETECT_INTERNAL_H__
18 #define __TIZEN_MEDIAVISION_FACE_DETECT_INTERNAL_H__
20 #include <mv_common.h>
21 #include <mv_face_detection_type.h>
25 #endif /* __cplusplus */
28 * @file mv_face_detection.h
30 * @brief This file contains the Inference based Media Vision API.
34 * @addtogroup CAPI_MEDIA_VISION_INFERENCE_MODULE
40 * @brief Creates a inference handle for face detection object.
41 * @details Use this function to create a inference handle. After the creation
42 * the face detection task has to be prepared with
43 * mv_face_detection_prepare() function to prepare a network
48 * @remarks The @a infer should be released using mv_face_detection_destroy().
50 * @param[out] handle The handle to the inference to be created.
52 * @return @c 0 on success, otherwise a negative error value
53 * @retval #MEDIA_VISION_ERROR_NONE Successful
54 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
55 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
56 * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
58 * @see mv_face_detection_destroy()
59 * @see mv_face_detection_prepare()
61 int mv_face_detection_create(mv_face_detection_h *handle);
65 * @brief Destroys inference handle and releases all its resources.
69 * @param[in] handle The handle to the inference to be destroyed.
71 * @return @c 0 on success, otherwise a negative error value
72 * @retval #MEDIA_VISION_ERROR_NONE Successful
73 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
74 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
76 * @pre Create inference handle by using mv_face_detection_create()
78 * @see mv_face_detection_create()
80 int mv_face_detection_destroy(mv_face_detection_h handle);
84 * @brief Sets user-given model information.
85 * @details Use this function to change the model information instead of default one after calling @ref mv_face_detection_create().
89 * @param[in] handle The handle to the face detection object.
90 * @param[in] model_name Model name.
91 * @param[in] model_file Model file name.
92 * @param[in] meta_file Model meta file name.
93 * @param[in] label_file Label file name.
95 * @return @c 0 on success, otherwise a negative error value
96 * @retval #MEDIA_VISION_ERROR_NONE Successful
97 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
98 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
100 * @pre Create a face detection handle by calling @ref mv_face_detection_create()
102 int mv_face_detection_set_model(mv_face_detection_h handle, const char *model_name, const char *model_file,
103 const char *meta_file, const char *label_file);
107 * @brief Configures the backend for the face detection inference.
111 * @param [in] handle The handle to the inference
113 * @return @c 0 on success, otherwise a negative error value
114 * @retval #MEDIA_VISION_ERROR_NONE Successful
115 * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
116 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
117 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
119 int mv_face_detection_configure(mv_face_detection_h handle);
123 * @brief Prepares the face detection inference
124 * @details Use this function to prepare the face detection inference based on
125 * the configured network.
129 * @param[in] handle The handle to the inference.
131 * @return @c 0 on success, otherwise a negative error value
132 * @retval #MEDIA_VISION_ERROR_NONE Successful
133 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
134 * @retval #MEDIA_VISION_ERROR_PERMISSION_DENIED Permission denied
135 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
136 * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
137 * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
138 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
139 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format
141 int mv_face_detection_prepare(mv_face_detection_h handle);
145 * @brief Performs the face detection inference on the @a source.
148 * @remarks This function is synchronous and may take considerable time to run.
150 * @param[in] handle The handle to the inference
151 * @param[in] source The handle to the source of the media
153 * @return @c 0 on success, otherwise a negative error value
154 * @retval #MEDIA_VISION_ERROR_NONE Successful
155 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
156 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
157 * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
158 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
161 * @pre Create a source handle by calling mv_create_source()
162 * @pre Create an inference handle by calling mv_face_detect_create()
163 * @pre Prepare an inference by calling mv_face_detect_configure()
164 * @pre Prepare an inference by calling mv_face_detect_prepare()
166 int mv_face_detection_inference(mv_face_detection_h handle, mv_source_h source);
170 * @brief Performs asynchronously the face detection inference on the @a source.
173 * @remarks This function operates asynchronously, so it returns immediately upon invocation.
174 * Therefore, user needs to receive the result though a given callback function.
176 * @param[in] handle The handle to the inference
177 * @param[in] source The handle to the source of the media
178 * @param[in] completion_cb A callback which is called internally by the framework
179 * once the given inference request is completed.
180 * @param[in] user_data A pointer to user data object.
182 * @return @c 0 on success, otherwise a negative error value
183 * @retval #MEDIA_VISION_ERROR_NONE Successful
184 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
185 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
186 * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
187 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
190 * @pre Create a source handle by calling mv_create_source()
191 * @pre Create an inference handle by calling mv_face_detect_create()
192 * @pre Prepare an inference by calling mv_face_detect_configure()
193 * @pre Prepare an inference by calling mv_face_detect_prepare()
195 int mv_face_detection_inference_async(mv_face_detection_h handle, mv_source_h source, mv_completion_cb completion_cb,
200 * @brief Gets the face detection inference result on the @a source.
204 * @param[in] handle The handle to the inference
205 * @param[out] number_of_objects A number of objects detected.
206 * @param[out] indices Label indices to detected objects.
207 * @param[out] confidences Probability to detected objects.
208 * @param[out] left An left position array to bound boxes.
209 * @param[out] top An top position array to bound boxes.
210 * @param[out] right An right position array to bound boxes.
211 * @param[out] bottom An bottom position array to bound boxes.
213 * @return @c 0 on success, otherwise a negative error value
214 * @retval #MEDIA_VISION_ERROR_NONE Successful
215 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
216 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
217 * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
219 * @pre Create a source handle by calling mv_create_source()
220 * @pre Create an inference handle by calling mv_face_detect_create()
221 * @pre Prepare an inference by calling mv_face_detect_configure()
222 * @pre Prepare an inference by calling mv_face_detect_prepare()
223 * @pre Prepare an inference by calling mv_face_detect_inference()
225 int mv_face_detection_get_result(mv_face_detection_h handle, unsigned int *number_of_objects,
226 const unsigned int **indices, const float **confidences, const int **left,
227 const int **top, const int **right, const int **bottom);
231 * @brief Gets the label string to a given index.
235 * @param[in] handle The handle to the inference
236 * @param[in] index Label index to get the label string.
237 * @param[out] label Label string to a given index.
239 * @return @c 0 on success, otherwise a negative error value
240 * @retval #MEDIA_VISION_ERROR_NONE Successful
241 * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
242 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
243 * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
245 * @pre Create a source handle by calling mv_create_source()
246 * @pre Create an inference handle by calling mv_face_detect_create()
247 * @pre Prepare an inference by calling mv_face_detect_configure()
248 * @pre Prepare an inference by calling mv_face_detect_prepare()
249 * @pre Prepare an inference by calling mv_face_detect_inference()
251 int mv_face_detection_get_label(mv_face_detection_h handle, const unsigned int index, const char **label);
255 * @brief Sets user-given inference engine and device types for inference.
256 * @details Use this function to change the inference engine and device types for inference instead of default ones after calling @ref mv_face_detection_create().
260 * @param[in] handle The handle to the face detection object.
261 * @param[in] engine_type A string of inference engine type.
262 * @param[in] device_type A string of device type.
264 * @return @c 0 on success, otherwise a negative error value
265 * @retval #MEDIA_VISION_ERROR_NONE Successful
266 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
267 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
269 * @pre Create a face detection handle by calling @ref mv_face_detection_create()
271 int mv_face_detection_set_engine(mv_face_detection_h handle, const char *engine_type, const char *device_type);
275 * @brief Gets a number of inference engines available for face detection task API.
276 * @details Use this function to get how many inference engines are supported for face detection after calling @ref mv_face_detection_create().
280 * @param[in] handle The handle to the face detection object.
281 * @param[out] engine_count A number of inference engines available for face detection API.
283 * @return @c 0 on success, otherwise a negative error value
284 * @retval #MEDIA_VISION_ERROR_NONE Successful
285 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
286 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
288 * @pre Create a face detection handle by calling @ref mv_face_detection_create()
290 int mv_face_detection_get_engine_count(mv_face_detection_h handle, unsigned int *engine_count);
294 * @brief Gets engine type to a given inference engine index.
295 * @details Use this function to get inference engine type with a given engine index after calling @ref mv_face_detection_get_engine_count().
299 * @param[in] handle The handle to the face detection object.
300 * @param[in] engine_index A inference engine index for getting the inference engine type.
301 * @param[out] engine_type A string to inference engine.
303 * @return @c 0 on success, otherwise a negative error value
304 * @retval #MEDIA_VISION_ERROR_NONE Successful
305 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
306 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
308 * @pre Get a number of inference engines available for face detection task API by calling @ref mv_face_detection_get_engine_count()
310 int mv_face_detection_get_engine_type(mv_face_detection_h handle, const unsigned int engine_index, char **engine_type);
314 * @brief Gets a number of device types available to a given inference engine.
315 * @details Use this function to get how many device types are supported for a given inference engine after calling @ref mv_face_detection_create().
319 * @param[in] handle The handle to the face detection object.
320 * @param[in] engine_type A inference engine string.
321 * @param[out] device_count A number of device types available for a given inference engine.
323 * @return @c 0 on success, otherwise a negative error value
324 * @retval #MEDIA_VISION_ERROR_NONE Successful
325 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
326 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
328 * @pre Create a face detection handle by calling @ref mv_face_detection_create()
330 int mv_face_detection_get_device_count(mv_face_detection_h handle, const char *engine_type, unsigned int *device_count);
334 * @brief Gets device type list available.
335 * @details Use this function to get what device types are supported for current inference engine type after calling @ref mv_face_detection_configure().
339 * @param[in] handle The handle to the face detection object.
340 * @param[in] engine_type A inference engine string.
341 * @param[in] device_index A device index for getting the device type.
342 * @param[out] device_type A string to device type.
344 * @return @c 0 on success, otherwise a negative error value
345 * @retval #MEDIA_VISION_ERROR_NONE Successful
346 * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
347 * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
349 * @pre Create a face detection handle by calling @ref mv_face_detection_create()
350 * @pre Configure face detection task by calling @ref mv_face_detection_configure()
352 int mv_face_detection_get_device_type(mv_face_detection_h handle, const char *engine_type,
353 const unsigned int device_index, char **device_type);
359 #endif /* __cplusplus */
361 #endif /* __TIZEN_MEDIAVISION_FACE_DETECT_INTERNAL_H__ */