diff options
author | Vibhav Aggarwal <v.aggarwal@samsung.com> | 2024-06-12 18:09:43 +0900 |
---|---|---|
committer | Vibhav Aggarwal <v.aggarwal@samsung.com> | 2024-06-12 18:09:43 +0900 |
commit | 5ee3a4ba41c4de5241f4fed867a60e575d7fc09b (patch) | |
tree | 3140d074673a093509080e04cac3a8ebde3e5d08 | |
parent | 73632120a834f87d020841985eff7f307a3abf28 (diff) | |
download | mediavision-5ee3a4ba41c4de5241f4fed867a60e575d7fc09b.tar.gz mediavision-5ee3a4ba41c4de5241f4fed867a60e575d7fc09b.tar.bz2 mediavision-5ee3a4ba41c4de5241f4fed867a60e575d7fc09b.zip |
[ACR-1848] Publish machine learning APIsaccepted/tizen/unified/x/asan/20240625.092955accepted/tizen/unified/x/20240619.013513accepted/tizen/unified/toolchain/20240624.121719accepted/tizen/unified/dev/20240620.004157accepted/tizen/unified/20240618.060058accepted/tizen_unified_x_asanaccepted/tizen_unified_toolchainaccepted/tizen_unified_dev
Please refer to the following ACR:
https://jira.sec.samsung.net/browse/ACR-1848
Change-Id: I92c053b3cb1d872735ccd548a091ba9e6b29861f
Signed-off-by: Vibhav Aggarwal <v.aggarwal@samsung.com>
40 files changed, 2825 insertions, 960 deletions
diff --git a/doc/examples/face_detection_async.c b/doc/examples/face_detection_async.c new file mode 100644 index 00000000..cf8db583 --- /dev/null +++ b/doc/examples/face_detection_async.c @@ -0,0 +1,153 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <pthread.h> +#include <stdbool.h> +#include <string.h> + +#include <image_util.h> +#include <mv_face_detection.h> + +#undef LOG_TAG +#define LOG_TAG "FACE_DETECTION_ASYNC_EXAMPLE" + +#define MAX_INFERENCE_ITERATION 50 + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [FD async] +void face_detection_callback(void *user_data) +{ + mv_face_detection_h handle = (mv_face_detection_h) user_data; + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_face_detection_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + int left, top, right, bottom; + + int ret = mv_face_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, + "frame = %lu, idx = %u, left = %d, top = %d, " + "right = %d, bottom = %d", + frame_number, idx, left, top, right, bottom); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } +} + +int main() +{ + int error_code = 0; + mv_face_detection_h handle; + + error_code = mv_face_detection_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_face_detection_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_face_detection_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + pthread_t thread_id; + + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_face_detection_inference_async(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + if (iter == 0) + pthread_create(&thread_id, NULL, face_detection_callback, handle); + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + } + + /* This thread will be exited after inference is performed MAX_INFERENCE_ITERATION times. */ + pthread_join(thread_id, NULL); + + error_code = mv_face_detection_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [FD async]
\ No newline at end of file diff --git a/doc/examples/face_detection_sync.c b/doc/examples/face_detection_sync.c new file mode 100644 index 00000000..ccc899da --- /dev/null +++ b/doc/examples/face_detection_sync.c @@ -0,0 +1,127 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <string.h> + +#include <image_util.h> +#include <mv_face_detection.h> + +#undef LOG_TAG +#define LOG_TAG "FACE_DETECTION_SYNC_EXAMPLE" + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [FD sync] +int main() +{ + int error_code = 0; + mv_face_detection_h handle; + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_face_detection_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_face_detection_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_face_detection_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_face_detection_inference(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_face_detection_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + int left, top, right, bottom; + + int ret = mv_face_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, + "frame = %lu, idx = %u, left = %d, top = %d, " + "right = %d, bottom = %d", + frame_number, idx, left, top, right, bottom); + } + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_face_detection_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [FD sync]
\ No newline at end of file diff --git a/doc/examples/facial_landmark_async.c b/doc/examples/facial_landmark_async.c new file mode 100644 index 00000000..b2e5aae4 --- /dev/null +++ b/doc/examples/facial_landmark_async.c @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <pthread.h> +#include <stdbool.h> +#include <string.h> + +#include <image_util.h> +#include <mv_facial_landmark.h> + +#undef LOG_TAG +#define LOG_TAG "FACIAL_LANDMARK_ASYNC_EXAMPLE" + +#define MAX_INFERENCE_ITERATION 50 + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [FLD async] +void facial_landmark_callback(void *user_data) +{ + mv_facial_landmark_h handle = (mv_facial_landmark_h) user_data; + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_facial_landmark_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + error_code = mv_facial_landmark_get_position(handle, idx, &pos_x, &pos_y); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, "frame = %lu, idx = %u, x = %u, y = %u", frame_number, idx, pos_x, pos_y); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } +} + +int main() +{ + int error_code = 0; + mv_facial_landmark_h handle; + + error_code = mv_facial_landmark_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_facial_landmark_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_facial_landmark_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + pthread_t thread_id; + + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_facial_landmark_inference_async(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + if (iter == 0) + pthread_create(&thread_id, NULL, facial_landmark_callback, handle); + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + } + + /* This thread will be exited after inference is performed MAX_INFERENCE_ITERATION times. */ + pthread_join(thread_id, NULL); + + error_code = mv_facial_landmark_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [FLD async]
\ No newline at end of file diff --git a/doc/examples/facial_landmark_sync.c b/doc/examples/facial_landmark_sync.c new file mode 100644 index 00000000..ef2d3baf --- /dev/null +++ b/doc/examples/facial_landmark_sync.c @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <string.h> + +#include <image_util.h> +#include <mv_facial_landmark.h> + +#undef LOG_TAG +#define LOG_TAG "FACIAL_LANDMARK_SYNC_EXAMPLE" + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [FLD sync] +int main() +{ + int error_code = 0; + mv_facial_landmark_h handle; + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_facial_landmark_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_facial_landmark_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_facial_landmark_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_facial_landmark_inference(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_facial_landmark_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + error_code = mv_facial_landmark_get_position(handle, idx, &pos_x, &pos_y); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, "frame = %lu, idx = %u, x = %u, y = %u", frame_number, idx, pos_x, pos_y); + } + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_facial_landmark_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [FLD sync]
\ No newline at end of file diff --git a/doc/examples/image_classification_async.c b/doc/examples/image_classification_async.c new file mode 100644 index 00000000..c02cdf9e --- /dev/null +++ b/doc/examples/image_classification_async.c @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <pthread.h> +#include <stdbool.h> +#include <string.h> + +#include <image_util.h> +#include <mv_image_classification.h> + +#undef LOG_TAG +#define LOG_TAG "IMAGE_CLASSIFICATION_ASYNC_EXAMPLE" + +#define MAX_INFERENCE_ITERATION 50 + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [IC async] +void image_classification_callback(void *user_data) +{ + mv_image_classification_h handle = (mv_image_classification_h) user_data; + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_image_classification_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + const char *label = NULL; + + error_code = mv_image_classification_get_label(handle, idx, &label); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, "frame = %lu, idx = %u, label = %s", frame_number, idx, label); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } +} + +int main() +{ + int error_code = 0; + mv_image_classification_h handle; + + error_code = mv_image_classification_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_image_classification_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_image_classification_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + pthread_t thread_id; + + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_image_classification_inference_async(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + if (iter == 0) + pthread_create(&thread_id, NULL, image_classification_callback, handle); + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + } + + /* This thread will be exited after inference is performed MAX_INFERENCE_ITERATION times. */ + pthread_join(thread_id, NULL); + + error_code = mv_image_classification_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [IC async]
\ No newline at end of file diff --git a/doc/examples/image_classification_sync.c b/doc/examples/image_classification_sync.c new file mode 100644 index 00000000..51117b16 --- /dev/null +++ b/doc/examples/image_classification_sync.c @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <string.h> + +#include <image_util.h> +#include <mv_image_classification.h> + +#undef LOG_TAG +#define LOG_TAG "IMAGE_CLASSIFICATION_SYNC_EXAMPLE" + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [IC sync] +int main() +{ + int error_code = 0; + mv_image_classification_h handle; + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_image_classification_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_image_classification_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_image_classification_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_image_classification_inference(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_image_classification_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + const char *label = NULL; + + error_code = mv_image_classification_get_label(handle, idx, &label); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, "frame = %lu, idx = %u, label = %s", frame_number, idx, label); + } + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_image_classification_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [IC sync]
\ No newline at end of file diff --git a/doc/examples/object_detection_async.c b/doc/examples/object_detection_async.c new file mode 100644 index 00000000..990288d1 --- /dev/null +++ b/doc/examples/object_detection_async.c @@ -0,0 +1,153 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <pthread.h> +#include <stdbool.h> +#include <string.h> + +#include <image_util.h> +#include <mv_object_detection.h> + +#undef LOG_TAG +#define LOG_TAG "OBJECT_DETECTION_ASYNC_EXAMPLE" + +#define MAX_INFERENCE_ITERATION 50 + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [OD async] +void object_detection_callback(void *user_data) +{ + mv_object_detection_h handle = (mv_object_detection_h) user_data; + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_object_detection_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + int left, top, right, bottom; + + int ret = mv_object_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, + "frame = %lu, idx = %u, left = %d, top = %d, " + "right = %d, bottom = %d", + frame_number, idx, left, top, right, bottom); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } +} + +int main() +{ + int error_code = 0; + mv_object_detection_h handle; + + error_code = mv_object_detection_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_object_detection_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_object_detection_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + pthread_t thread_id; + + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_object_detection_inference_async(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + if (iter == 0) + pthread_create(&thread_id, NULL, object_detection_callback, handle); + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + } + + /* This thread will be exited after inference is performed MAX_INFERENCE_ITERATION times. */ + pthread_join(thread_id, NULL); + + error_code = mv_object_detection_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [OD async]
\ No newline at end of file diff --git a/doc/examples/object_detection_sync.c b/doc/examples/object_detection_sync.c new file mode 100644 index 00000000..e5d9d2c6 --- /dev/null +++ b/doc/examples/object_detection_sync.c @@ -0,0 +1,127 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <string.h> + +#include <image_util.h> +#include <mv_object_detection.h> + +#undef LOG_TAG +#define LOG_TAG "OBJECT_DETECTION_SYNC_EXAMPLE" + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [OD sync] +int main() +{ + int error_code = 0; + mv_object_detection_h handle; + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_object_detection_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_object_detection_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_object_detection_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_object_detection_inference(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_object_detection_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + int left, top, right, bottom; + + int ret = mv_object_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, + "frame = %lu, idx = %u, left = %d, top = %d, " + "right = %d, bottom = %d", + frame_number, idx, left, top, right, bottom); + } + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_object_detection_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [OD sync]
\ No newline at end of file diff --git a/doc/examples/pose_landmark_async.c b/doc/examples/pose_landmark_async.c new file mode 100644 index 00000000..ffb71f1a --- /dev/null +++ b/doc/examples/pose_landmark_async.c @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <pthread.h> +#include <stdbool.h> +#include <string.h> + +#include <image_util.h> +#include <mv_pose_landmark.h> + +#undef LOG_TAG +#define LOG_TAG "POSE_LANDMARK_ASYNC_EXAMPLE" + +#define MAX_INFERENCE_ITERATION 50 + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [PLD async] +void pose_landmark_callback(void *user_data) +{ + mv_pose_landmark_h handle = (mv_pose_landmark_h) user_data; + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_pose_landmark_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + error_code = mv_pose_landmark_get_position(handle, idx, &pos_x, &pos_y); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, "frame = %lu, idx = %u, x = %u, y = %u", frame_number, idx, pos_x, pos_y); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } +} + +int main() +{ + int error_code = 0; + mv_pose_landmark_h handle; + + error_code = mv_pose_landmark_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_pose_landmark_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_pose_landmark_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + pthread_t thread_id; + + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_pose_landmark_inference_async(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + if (iter == 0) + pthread_create(&thread_id, NULL, pose_landmark_callback, handle); + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + } + + /* This thread will be exited after inference is performed MAX_INFERENCE_ITERATION times. */ + pthread_join(thread_id, NULL); + + error_code = mv_pose_landmark_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [PLD async]
\ No newline at end of file diff --git a/doc/examples/pose_landmark_sync.c b/doc/examples/pose_landmark_sync.c new file mode 100644 index 00000000..4ce13c0e --- /dev/null +++ b/doc/examples/pose_landmark_sync.c @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> +#include <string.h> + +#include <image_util.h> +#include <mv_pose_landmark.h> + +#undef LOG_TAG +#define LOG_TAG "POSE_LANDMARK_SYNC_EXAMPLE" + +void load_image_to_source(const char *path, mv_source_h mv_source) +{ + unsigned char *dataBuffer = NULL; + size_t long bufferSize = 0; + unsigned int width = 0; + unsigned int height = 0; + image_util_decode_h imageDecoder = NULL; + image_util_image_h decodedImage = NULL; + + int error_code = image_util_decode_create(&imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_input_path(imageDecoder, path); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_set_colorspace(imageDecoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_run2(imageDecoder, &decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_get_image(decodedImage, &width, &height, NULL, &dataBuffer, &bufferSize); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_decode_destroy(imageDecoder); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + /* Fill the dataBuffer to mv_source */ + error_code = mv_source_fill_by_buffer(mv_source, dataBuffer, (unsigned int) bufferSize, width, height, + MEDIA_VISION_COLORSPACE_RGB888); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = image_util_destroy_image(decodedImage); + if (error_code != IMAGE_UTIL_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} + +//! [PLD sync] +int main() +{ + int error_code = 0; + mv_pose_landmark_h handle; + mv_source_h mv_source = NULL; + + error_code = mv_create_source(&mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + load_image_to_source("/path/to/image", mv_source); + + error_code = mv_pose_landmark_create(&handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_pose_landmark_configure(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_pose_landmark_prepare(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_pose_landmark_inference(handle, mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + unsigned long frame_number; + unsigned int cnt; + + int error_code = mv_pose_landmark_get_result_count(handle, &frame_number, &cnt); + if (error_code == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + error_code = mv_pose_landmark_get_position(handle, idx, &pos_x, &pos_y); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + dlog_print(DLOG_INFO, LOG_TAG, "frame = %lu, idx = %u, x = %u, y = %u", frame_number, idx, pos_x, pos_y); + } + + error_code = mv_destroy_source(mv_source); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); + + error_code = mv_pose_landmark_destroy(handle); + if (error_code != MEDIA_VISION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "error code = %d", error_code); +} +//! [PLD sync]
\ No newline at end of file diff --git a/doc/mediavision_doc.h b/doc/mediavision_doc.h index d48548e4..02906a32 100644 --- a/doc/mediavision_doc.h +++ b/doc/mediavision_doc.h @@ -542,5 +542,179 @@ * After preparation, mv_3d_run() has to be called to process synchronously depth or pointcloud from #mv_source_h, * and callback functions will be invoked with processed depth or pointcloud. * Module also contains mv_3d_run_async() functions to process depth or pointcloud asynchronously. + * + * @defgroup CAPI_MEDIA_VISION_FACE_DETECTION_MODULE Media Vision Face Detection + * @ingroup CAPI_MEDIA_VISION_MODULE + * @brief Face detection. + * @section CAPI_MEDIA_VISION_FACE_DETECTION_MODULE_HEADER Required Header + * \#include <mv_face_detection.h> + * + * @section CAPI_MEDIA_VISION_FACE_DETECTION_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - %http://tizen.org/feature/vision.inference.image\n + * - %http://tizen.org/feature/vision.inference.face\n + * + * It is recommended to design feature related codes in your application for + * reliability.\n + * You can check if a device supports the related features for this API by using + * @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of + * your application.\n + * To ensure your application is only running on the device with specific + * features, please define the features in your manifest file using the manifest + * editor in the SDK.\n + * More details on featuring your application can be found from + * <a href="https://docs.tizen.org/application/tizen-studio/native-tools/manifest-text-editor#feature-element"> + * <b>Feature Element</b>. + * </a> + * + * @section CAPI_MEDIA_VISION_FACE_DETECTION_MODULE_OVERVIEW Overview + * @ref CAPI_MEDIA_VISION_FACE_DETECTION_MODULE contains #mv_face_detection_h handle to perform + * face detection. Face detection handle should be created with mv_face_detection_create() and destroyed with + * mv_face_detection_destroy(). #mv_face_detection_h should be configured by calling + * mv_face_detection_configure(). After configuration, #mv_face_detection_h should be prepared by + * calling mv_face_detection_prepare() which loads models and set required parameters. + * After preparation, mv_face_detection_inference() or mv_face_detection_inference_async() + * can be called to detect faces in images on #mv_source_h. + * Use mv_face_detection_get_result_count() to get the number of results and mv_face_detection_get_bound_box() + * to get the bounding box of each result. + * + * @defgroup CAPI_MEDIA_VISION_OBJECT_DETECTION_MODULE Media Vision Object Detection + * @ingroup CAPI_MEDIA_VISION_MODULE + * @brief Object detection. + * @section CAPI_MEDIA_VISION_OBJECT_DETECTION_MODULE_HEADER Required Header + * \#include <mv_object_detection.h> + * + * @section CAPI_MEDIA_VISION_OBJECT_DETECTION_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - %http://tizen.org/feature/vision.inference.image\n + * - %http://tizen.org/feature/vision.inference.face\n + * + * It is recommended to design feature related codes in your application for + * reliability.\n + * You can check if a device supports the related features for this API by using + * @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of + * your application.\n + * To ensure your application is only running on the device with specific + * features, please define the features in your manifest file using the manifest + * editor in the SDK.\n + * More details on featuring your application can be found from + * <a href="https://docs.tizen.org/application/tizen-studio/native-tools/manifest-text-editor#feature-element"> + * <b>Feature Element</b>. + * </a> + * + * @section CAPI_MEDIA_VISION_OBJECT_DETECTION_MODULE_OVERVIEW Overview + * @ref CAPI_MEDIA_VISION_OBJECT_DETECTION_MODULE contains #mv_object_detection_h handle to perform + * object detection. Object detection handle should be created with mv_object_detection_create() and destroyed with + * mv_object_detection_destroy(). #mv_object_detection_h should be configured by calling + * mv_object_detection_configure(). After configuration, #mv_object_detection_h should be prepared by + * calling mv_object_detection_prepare() which loads models and set required parameters. + * After preparation, mv_object_detection_inference() or mv_object_detection_inference_async() + * can be called to detect objects in images on #mv_source_h. + * Use mv_object_detection_get_result_count() to get the number of results and mv_object_detection_get_bound_box() + * to get the bounding box of each result. + * + * @defgroup CAPI_MEDIA_VISION_IMAGE_CLASSIFICATION_MODULE Media Vision Image Classification + * @ingroup CAPI_MEDIA_VISION_MODULE + * @brief Image classification. + * @section CAPI_MEDIA_VISION_IMAGE_CLASSIFICATION_MODULE_HEADER Required Header + * \#include <mv_image_classification.h> + * + * @section CAPI_MEDIA_VISION_IMAGE_CLASSIFICATION_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - %http://tizen.org/feature/vision.inference.image\n + * + * It is recommended to design feature related codes in your application for + * reliability.\n + * You can check if a device supports the related features for this API by using + * @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of + * your application.\n + * To ensure your application is only running on the device with specific + * features, please define the features in your manifest file using the manifest + * editor in the SDK.\n + * More details on featuring your application can be found from + * <a href="https://docs.tizen.org/application/tizen-studio/native-tools/manifest-text-editor#feature-element"> + * <b>Feature Element</b>. + * </a> + * + * @section CAPI_MEDIA_VISION_IMAGE_CLASSIFICATION_MODULE_OVERVIEW Overview + * @ref CAPI_MEDIA_VISION_IMAGE_CLASSIFICATION_MODULE contains #mv_image_classification_h handle to perform + * image classification. Image classification handle should be created with mv_image_classification_create() and destroyed with + * mv_image_classification_destroy(). #mv_image_classification_h should be configured by calling + * mv_image_classification_configure(). After configuration, #mv_image_classification_h should be prepared by + * calling mv_image_classification_prepare() which loads models and set required parameters. + * After preparation, mv_image_classification_inference() or mv_image_classification_inference_async() + * can be called to classify images on #mv_source_h. + * Use mv_image_classification_get_result_count() to get the number of results and mv_image_classification_get_label() + * to get the label of each result. + * + * @defgroup CAPI_MEDIA_VISION_FACIAL_LANDMARK_MODULE Media Vision Facial Landmark Detection + * @ingroup CAPI_MEDIA_VISION_MODULE + * @brief Facial landmark detection. + * @section CAPI_MEDIA_VISION_FACIAL_LANDMARK_MODULE_HEADER Required Header + * \#include <mv_facial_landmark.h> + * + * @section CAPI_MEDIA_VISION_FACIAL_LANDMARK_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - %http://tizen.org/feature/vision.inference.image\n + * - %http://tizen.org/feature/vision.inference.face\n + * + * It is recommended to design feature related codes in your application for + * reliability.\n + * You can check if a device supports the related features for this API by using + * @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of + * your application.\n + * To ensure your application is only running on the device with specific + * features, please define the features in your manifest file using the manifest + * editor in the SDK.\n + * More details on featuring your application can be found from + * <a href="https://docs.tizen.org/application/tizen-studio/native-tools/manifest-text-editor#feature-element"> + * <b>Feature Element</b>. + * </a> + * + * @section CAPI_MEDIA_VISION_FACIAL_LANDMARK_MODULE_OVERVIEW Overview + * @ref CAPI_MEDIA_VISION_FACIAL_LANDMARK_MODULE contains #mv_facial_landmark_h handle to perform + * facial landmark detection. Facial landmark handle should be created with mv_facial_landmark_create() and destroyed with + * mv_facial_landmark_destroy(). #mv_facial_landmark_h should be configured by calling + * mv_facial_landmark_configure(). After configuration, #mv_facial_landmark_h should be prepared by + * calling mv_facial_landmark_prepare() which loads models and set required parameters. + * After preparation, mv_facial_landmark_inference() or mv_facial_landmark_inference_async() + * can be called to detect facial landmarks in images on #mv_source_h. + * Use mv_facial_landmark_get_result_count() to get the number of results and mv_facial_landmark_get_position() + * to get the position of each landmark. + * + * @defgroup CAPI_MEDIA_VISION_POSE_LANDMARK_MODULE Media Vision Pose Landmark Detection + * @ingroup CAPI_MEDIA_VISION_MODULE + * @brief Pose landmark detection. + * @section CAPI_MEDIA_VISION_POSE_LANDMARK_MODULE_HEADER Required Header + * \#include <mv_pose_landmark.h> + * + * @section CAPI_MEDIA_VISION_POSE_LANDMARK_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - %http://tizen.org/feature/vision.inference.image\n + * - %http://tizen.org/feature/vision.inference.face\n + * + * It is recommended to design feature related codes in your application for + * reliability.\n + * You can check if a device supports the related features for this API by using + * @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of + * your application.\n + * To ensure your application is only running on the device with specific + * features, please define the features in your manifest file using the manifest + * editor in the SDK.\n + * More details on featuring your application can be found from + * <a href="https://docs.tizen.org/application/tizen-studio/native-tools/manifest-text-editor#feature-element"> + * <b>Feature Element</b>. + * </a> + * + * @section CAPI_MEDIA_VISION_POSE_LANDMARK_MODULE_OVERVIEW Overview + * @ref CAPI_MEDIA_VISION_POSE_LANDMARK_MODULE contains #mv_pose_landmark_h handle to perform + * pose landmark detection. Pose landmark handle should be created with mv_pose_landmark_create() and destroyed with + * mv_pose_landmark_destroy(). #mv_pose_landmark_h should be configured by calling + * mv_pose_landmark_configure(). After configuration, #mv_pose_landmark_h should be prepared by + * calling mv_pose_landmark_prepare() which loads models and set required parameters. + * After preparation, mv_pose_landmark_inference() or mv_pose_landmark_inference_async() + * can be called to detect pose landmarks in images on #mv_source_h. + * Use mv_pose_landmark_get_result_count() to get the number of results and mv_pose_landmark_get_position() + * to get the position of each landmark. */ #endif /* __TIZEN_MEDIAVISION_DOC_H__ */ diff --git a/include/mv_face_detection.h b/include/mv_face_detection.h new file mode 100644 index 00000000..3a7a8763 --- /dev/null +++ b/include/mv_face_detection.h @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_MEDIAVISION_MV_FACE_DETECTION_H__ +#define __TIZEN_MEDIAVISION_MV_FACE_DETECTION_H__ + +#include <mv_common.h> +#include <mv_face_detection_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file mv_face_detection.h + * @brief This file contains the Inference based Media Vision API. + */ + +/** + * @addtogroup CAPI_MEDIA_VISION_FACE_DETECTION_MODULE + * @{ + */ + +/** + * @brief Creates a inference handle for face detection object. + * @details Use this function to create a inference handle. After the creation + * the face detection task has to be prepared with + * mv_face_detection_prepare() function to prepare a network + * for the inference. + * + * @since_tizen 9.0 + * + * @remarks The @a handle should be released using mv_face_detection_destroy(). + * + * @param[out] handle The handle to the inference to be created. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * + * @code + * #include <mv_face_detection.h> + * ... + * mv_face_detection_h handle = NULL; + * mv_face_detection_create(&handle); + * ... + * mv_face_detection_destroy(handle); + * @endcode + * + * @see mv_face_detection_destroy() + * @see mv_face_detection_prepare() + */ +int mv_face_detection_create(mv_face_detection_h *handle); + +/** + * @brief Destroys inference handle and releases all its resources. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference to be destroyed. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre Create inference handle by using mv_face_detection_create() + * + * @see mv_face_detection_create() + */ +int mv_face_detection_destroy(mv_face_detection_h handle); + +/** + * @brief Configures the backend for the face detection inference. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + */ +int mv_face_detection_configure(mv_face_detection_h handle); + +/** + * @brief Prepares the face detection inference. + * @details Use this function to prepare the face detection inference based on + * the configured network. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format + */ +int mv_face_detection_prepare(mv_face_detection_h handle); + +/** + * @brief Performs the face detection inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function is synchronous and may take considerable time to run. + * + * @param[in] handle The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_face_detection_create() + * @pre Prepare an inference by calling mv_face_detection_configure() + * @pre Prepare an inference by calling mv_face_detection_prepare() + * + * @par Inference Example + * @snippet face_detection_sync.c FD sync + */ +int mv_face_detection_inference(mv_face_detection_h handle, mv_source_h source); + +/** + * @brief Performs asynchronously the face detection inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function operates asynchronously, so it returns immediately upon invocation. + * The inference results are inserted into the outgoing queue within the framework + * in the order of processing, and the results can be obtained through mv_face_detection_get_result_count() + * and mv_face_detection_get_bound_box(). + * + * @param[in] handle The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_face_detection_create() + * @pre Prepare an inference by calling mv_face_detection_configure() + * @pre Prepare an inference by calling mv_face_detection_prepare() + * + * @par Async Inference Example + * @snippet face_detection_async.c FD async + */ +int mv_face_detection_inference_async(mv_face_detection_h handle, mv_source_h source); + +/** + * @brief Gets the face detection inference result on the @a handle. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * @param[out] frame_number A frame number inferenced. + * @param[out] result_cnt A number of results. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_face_detection_create() + * @pre Prepare an inference by calling mv_face_detection_configure() + * @pre Prepare an inference by calling mv_face_detection_prepare() + * @pre Request an inference by calling mv_face_detection_inference() + */ +int mv_face_detection_get_result_count(mv_face_detection_h handle, unsigned long *frame_number, + unsigned int *result_cnt); + +/** + * @brief Gets a bound box to detected face region. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * @param[in] index A result index. + * @param[out] left An left position of bound box. + * @param[out] top An top position of bound box. + * @param[out] right An right position of bound box. + * @param[out] bottom An bottom position of bound box. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_face_detection_create() + * @pre Prepare an inference by calling mv_face_detection_configure() + * @pre Prepare an inference by calling mv_face_detection_prepare() + * @pre Request an inference by calling mv_face_detection_inference() + * @pre Get result count by calling mv_face_detection_get_result_count() + */ +int mv_face_detection_get_bound_box(mv_face_detection_h handle, unsigned int index, int *left, int *top, int *right, + int *bottom); +/** + * @} + */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIAVISION_MV_FACE_DETECTION_H__ */ diff --git a/include/mv_face_detection_internal.h b/include/mv_face_detection_internal.h index 80c6f1a4..be137327 100644 --- a/include/mv_face_detection_internal.h +++ b/include/mv_face_detection_internal.h @@ -37,50 +37,6 @@ extern "C" { /** * @internal - * @brief Creates a inference handle for face detection object. - * @details Use this function to create a inference handle. After the creation - * the face detection task has to be prepared with - * mv_face_detection_prepare() function to prepare a network - * for the inference. - * - * @since_tizen 9.0 - * - * @remarks The @a infer should be released using mv_face_detection_destroy(). - * - * @param[out] handle The handle to the inference to be created. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @see mv_face_detection_destroy() - * @see mv_face_detection_prepare() - */ -int mv_face_detection_create(mv_face_detection_h *handle); - -/** - * @internal - * @brief Destroys inference handle and releases all its resources. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference to be destroyed. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create inference handle by using mv_face_detection_create() - * - * @see mv_face_detection_create() - */ -int mv_face_detection_destroy(mv_face_detection_h handle); - -/** - * @internal * @brief Sets user-given model information. * @details Use this function to change the model information instead of default one after calling @ref mv_face_detection_create(). * @@ -104,151 +60,6 @@ int mv_face_detection_set_model(mv_face_detection_h handle, const char *model_na /** * @internal - * @brief Configures the backend for the face detection inference. - * - * @since_tizen 9.0 - * - * @param [in] handle The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - */ -int mv_face_detection_configure(mv_face_detection_h handle); - -/** - * @internal - * @brief Prepares the face detection inference - * @details Use this function to prepare the face detection inference based on - * the configured network. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_PERMISSION_DENIED Permission denied - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format - */ -int mv_face_detection_prepare(mv_face_detection_h handle); - -/** - * @internal - * @brief Performs the face detection inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function is synchronous and may take considerable time to run. - * - * @param[in] handle The handle to the inference - * @param[in] source The handle to the source of the media - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_face_detect_create() - * @pre Prepare an inference by calling mv_face_detect_configure() - * @pre Prepare an inference by calling mv_face_detect_prepare() - */ -int mv_face_detection_inference(mv_face_detection_h handle, mv_source_h source); - -/** - * @internal - * @brief Performs asynchronously the face detection inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function operates asynchronously, so it returns immediately upon invocation. - * The inference results are inserted into the outgoing queue within the framework - * in the order of processing, and the results can be obtained through mv_face_detection_get_result() - * and mv_face_detection_get_label(). - * - * @param[in] handle The handle to the inference - * @param[in] source The handle to the source of the media - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_face_detect_create() - * @pre Prepare an inference by calling mv_face_detect_configure() - * @pre Prepare an inference by calling mv_face_detect_prepare() - */ -int mv_face_detection_inference_async(mv_face_detection_h handle, mv_source_h source); - -/** - * @internal - * @brief Gets the face detection inference result on the @a source. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[out] frame_number A frame number inferenced. - * @param[out] result_cnt A number of results. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_face_detect_create() - * @pre Prepare an inference by calling mv_face_detect_configure() - * @pre Prepare an inference by calling mv_face_detect_prepare() - * @pre Request an inference by calling mv_face_detect_inference() - */ -int mv_face_detection_get_result_count(mv_face_detection_h handle, unsigned long *frame_number, - unsigned int *result_cnt); - -/** - * @internal - * @brief Gets a bound box to detected face region - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[in] index A result index. - * @param[out] left An left position of bound box. - * @param[out] top An top position of bound box. - * @param[out] right An right position of bound box. - * @param[out] bottom An bottom position of bound box. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_face_detect_create() - * @pre Prepare an inference by calling mv_face_detect_configure() - * @pre Prepare an inference by calling mv_face_detect_prepare() - * @pre Request an inference by calling mv_face_detect_inference() - * @pre Get result count by calling mv_face_detection_get_result_cnt() - */ -int mv_face_detection_get_bbox(mv_face_detection_h handle, unsigned int index, int *left, int *top, int *right, - int *bottom); - -/** - * @internal * @brief Sets user-given inference engine and device types for inference. * @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(). * diff --git a/include/mv_face_detection_type.h b/include/mv_face_detection_type.h index be681321..7e442cbc 100644 --- a/include/mv_face_detection_type.h +++ b/include/mv_face_detection_type.h @@ -25,23 +25,21 @@ extern "C" { /** * @file mv_face_detection_type.h - * @brief This file contains the face recognition handle for Mediavision. + * @brief This file contains the face detection handle for Mediavision. */ /** - * @addtogroup CAPI_MEDIA_VISION_FACE_DETECT_MODULE + * @addtogroup CAPI_MEDIA_VISION_FACE_DETECTION_MODULE * @{ */ /** * @brief The face detection object handle. * - * @since_tizen 8.0 + * @since_tizen 9.0 */ typedef void *mv_face_detection_h; -typedef void (*mv_completion_cb)(mv_face_detection_h handle, void *user_data); - /** * @} */ diff --git a/include/mv_facial_landmark.h b/include/mv_facial_landmark.h new file mode 100644 index 00000000..9c7b81fa --- /dev/null +++ b/include/mv_facial_landmark.h @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_MEDIAVISION_MV_FACIAL_LANDMARK_H__ +#define __TIZEN_MEDIAVISION_MV_FACIAL_LANDMARK_H__ + +#include <mv_common.h> +#include <mv_facial_landmark_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file mv_facial_landmark.h + * @brief This file contains the Inference based Media Vision API. + */ + +/** + * @addtogroup CAPI_MEDIA_VISION_FACIAL_LANDMARK_MODULE + * @{ + */ + +/** + * @brief Creates a inference handle for facial landmark object. + * @details Use this function to create a inference handle. After the creation + * the facial landmark task has to be prepared with + * mv_facial_landmark_prepare() function to prepare a network + * for the inference. + * + * @since_tizen 9.0 + * + * @remarks The @a handle should be released using mv_facial_landmark_destroy(). + * + * @param[out] handle The handle to the inference to be created. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * + * @code + * #include <mv_facial_landmark.h> + * ... + * mv_facial_landmark_h handle = NULL; + * mv_facial_landmark_create(&handle); + * ... + * mv_facial_landmark_destroy(handle); + * @endcode + * + * @see mv_facial_landmark_destroy() + * @see mv_facial_landmark_prepare() + */ +int mv_facial_landmark_create(mv_facial_landmark_h *handle); + +/** + * @brief Destroys inference handle and releases all its resources. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference to be destroyed. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre Create inference handle by using mv_facial_landmark_create() + * + * @see mv_facial_landmark_create() + */ +int mv_facial_landmark_destroy(mv_facial_landmark_h handle); + +/** + * @brief Configures the backend for the facial landmark inference. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + */ +int mv_facial_landmark_configure(mv_facial_landmark_h handle); + +/** + * @brief Prepares the facial landmark inference. + * @details Use this function to prepare the facial landmark inference based on + * the configured network. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format + */ +int mv_facial_landmark_prepare(mv_facial_landmark_h handle); + +/** + * @brief Performs the facial landmark inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function is synchronous and may take considerable time to run. + * + * @param[in] handle The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_facial_landmark_create() + * @pre Prepare an inference by calling mv_facial_landmark_configure() + * @pre Prepare an inference by calling mv_facial_landmark_prepare() + * + * @par Inference Example + * @snippet facial_landmark_sync.c FLD sync + */ +int mv_facial_landmark_inference(mv_facial_landmark_h handle, mv_source_h source); + +/** + * @brief Performs asynchronously the facial landmark inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function operates asynchronously, so it returns immediately upon invocation. + * The inference results are inserted into the outgoing queue within the framework + * in the order of processing, and the results can be obtained through mv_facial_landmark_get_position(). + * + * @param[in] handle The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_facial_landmark_create() + * @pre Prepare an inference by calling mv_facial_landmark_configure() + * @pre Prepare an inference by calling mv_facial_landmark_prepare() + * + * @par Async Inference Example + * @snippet facial_landmark_async.c FLD async + */ +int mv_facial_landmark_inference_async(mv_facial_landmark_h handle, mv_source_h source); + +/** + * @brief Gets the result count to objects. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * @param[out] frame_number A frame number inferenced. + * @param[out] result_cnt A number of results. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_facial_landmark_create() + * @pre Prepare an inference by calling mv_facial_landmark_configure() + * @pre Prepare an inference by calling mv_facial_landmark_prepare() + * @pre Request an inference by calling mv_facial_landmark_inference() + */ +int mv_facial_landmark_get_result_count(mv_facial_landmark_h handle, unsigned long *frame_number, + unsigned int *result_cnt); + +/** + * @brief Gets the facial landmark position values to a given index. + * + * @since_tizen 9.0 + * @remarks pos_x and pos_y arrays are allocated internally by the framework and will remain valid + * until the handle is released. + * Please do not deallocate them directly, and if you want to use them after the handle is released, + * please copy them to user memory and use the copy. + * + * This function operates differently depending on the inference request method. + * - After mv_facial_landmark_inference() calls, this function returns facial landmark positions immediately. + * - After mv_facial_landmark_inference_async() calls, this function can be blocked until the asynchronous inference request is completed + * or the timeout occurs if no result within 3 seconds. + * + * Additionally, after calling the mv_facial_landmark_inference_async() function, the function operates + * in asynchronous mode until the handle is released. + * + * @param[in] handle The handle to the inference + * @param[in] index A result index. + * @param[out] pos_x An array containing x-coordinate values. + * @param[out] pos_y An array containing y-coordinate values. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_facial_landmark_create() + * @pre Prepare an inference by calling mv_facial_landmark_configure() + * @pre Prepare an inference by calling mv_facial_landmark_prepare() + * @pre Prepare an inference by calling mv_facial_landmark_inference() + * @pre Get result count by calling mv_facial_landmark_get_result_count() + */ +int mv_facial_landmark_get_position(mv_facial_landmark_h handle, unsigned int index, unsigned int *pos_x, + unsigned int *pos_y); +/** + * @} + */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIAVISION_MV_FACIAL_LANDMARK_H__ */ diff --git a/include/mv_facial_landmark_internal.h b/include/mv_facial_landmark_internal.h index 411e983c..cbf9651a 100644 --- a/include/mv_facial_landmark_internal.h +++ b/include/mv_facial_landmark_internal.h @@ -37,50 +37,6 @@ extern "C" { /** * @internal - * @brief Creates a inference handle for facial landmark object. - * @details Use this function to create a inference handle. After the creation - * the facial landmark task has to be prepared with - * mv_facial_landmark_prepare() function to prepare a network - * for the inference. - * - * @since_tizen 9.0 - * - * @remarks The @a infer should be released using mv_facial_landmark_destroy(). - * - * @param[out] handle The handle to the inference to be created. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @see mv_facial_landmark_destroy() - * @see mv_facial_landmark_prepare() - */ -int mv_facial_landmark_create(mv_facial_landmark_h *handle); - -/** - * @internal - * @brief Destroys inference handle and releases all its resources. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference to be destroyed. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create inference handle by using mv_facial_landmark_create() - * - * @see mv_facial_landmark_create() - */ -int mv_facial_landmark_destroy(mv_facial_landmark_h handle); - -/** - * @internal * @brief Sets user-given model information. * @details Use this function to change the model information instead of default one after calling @ref mv_facial_landmark_create(). * @@ -104,160 +60,6 @@ int mv_facial_landmark_set_model(mv_facial_landmark_h handle, const char *model_ /** * @internal - * @brief Configures the backend for the facial landmark inference. - * - * @since_tizen 9.0 - * - * @param [in] handle The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - */ -int mv_facial_landmark_configure(mv_facial_landmark_h handle); - -/** - * @internal - * @brief Prepares the facial landmark inference - * @details Use this function to prepare the facial landmark inference based on - * the configured network. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_PERMISSION_DENIED Permission denied - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format - */ -int mv_facial_landmark_prepare(mv_facial_landmark_h handle); - -/** - * @internal - * @brief Performs the facial landmark inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function is synchronous and may take considerable time to run. - * - * @param[in] handle The handle to the inference - * @param[in] source The handle to the source of the media - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_facial_landmark_create() - * @pre Prepare an inference by calling mv_facial_landmark_configure() - * @pre Prepare an inference by calling mv_facial_landmark_prepare() - */ -int mv_facial_landmark_inference(mv_facial_landmark_h handle, mv_source_h source); - -/** - * @internal - * @brief Performs asynchronously the facial landmark inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function operates asynchronously, so it returns immediately upon invocation. - * The inference results are inserted into the outgoing queue within the framework - * in the order of processing, and the results can be obtained through mv_facial_landmark_get_positions(). - * - * @param[in] handle The handle to the inference - * @param[in] source The handle to the source of the media - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_facial_landmark_create() - * @pre Prepare an inference by calling mv_facial_landmark_configure() - * @pre Prepare an inference by calling mv_facial_landmark_prepare() - */ -int mv_facial_landmark_inference_async(mv_facial_landmark_h handle, mv_source_h source); - -/** - * @internal - * @brief Gets the result count to objects. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[out] frame_number A frame number inferenced. - * @param[out] result_cnt A number of results. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_facial_landmark_create() - * @pre Prepare an inference by calling mv_facial_landmark_configure() - * @pre Prepare an inference by calling mv_facial_landmark_prepare() - * @pre Request an inference by calling mv_facial_landmark_inference() - */ -int mv_facial_landmark_get_result_count(mv_facial_landmark_h handle, unsigned long *frame_number, - unsigned int *result_cnt); - -/** - * @internal - * @brief Gets the facial landmark position values to a given index. - * - * @since_tizen 9.0 - * @remarks pos_x and pos_y arrays are allocated internally by the framework and will remain valid - * until the handle is released. - * Please do not deallocate them directly, and if you want to use them after the handle is released, - * please copy them to user memory and use the copy. - * - * This function operates differently depending on the inference request method. - * - After mv_facial_landmark_inference() calls, this function returns facial landmark positions immediately. - * - After mv_facial_landmark_inference_async() calls, this function can be blocked until the asynchronous inference request is completed - * or the timeout occurs if no result within 3 seconds. - * - * Additionally, after calling the mv_facial_landmark_inference_async function, the function operates - * in asynchronous mode until the handle is released. - * - * @param[in] handle The handle to the inference - * @param[in] index A result index. - * @param[out] pos_x An array containing x-coordinate values. - * @param[out] pos_y An array containing y-coordinate values. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_facial_landmark_create() - * @pre Prepare an inference by calling mv_facial_landmark_configure() - * @pre Prepare an inference by calling mv_facial_landmark_prepare() - * @pre Prepare an inference by calling mv_facial_landmark_inference() - * @pre Get result count by calling mv_facial_landmark_get_result_count() - */ -int mv_facial_landmark_get_position(mv_facial_landmark_h handle, unsigned int index, unsigned int *pos_x, - unsigned int *pos_y); - -/** - * @internal * @brief Sets user-given inference engine and device types for inference. * @details Use this function to change the inference engine and device types for inference instead of default ones after calling @ref mv_facial_landmark_create(). * diff --git a/include/mv_facial_landmark_type.h b/include/mv_facial_landmark_type.h index f978c136..e7354082 100644 --- a/include/mv_facial_landmark_type.h +++ b/include/mv_facial_landmark_type.h @@ -29,7 +29,7 @@ extern "C" { */ /** - * @addtogroup CAPI_MEDIA_VISION_FACE_LANDMARK_MODULE + * @addtogroup CAPI_MEDIA_VISION_FACIAL_LANDMARK_MODULE * @{ */ diff --git a/include/mv_image_classification.h b/include/mv_image_classification.h new file mode 100644 index 00000000..6c590780 --- /dev/null +++ b/include/mv_image_classification.h @@ -0,0 +1,251 @@ +/** + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_MEDIAVISION_MV_IMAGE_CLASSIFICATION_H__ +#define __TIZEN_MEDIAVISION_MV_IMAGE_CLASSIFICATION_H__ + +#include <mv_common.h> +#include <mv_image_classification_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file mv_image_classification.h + * @brief This file contains the Inference based Media Vision API. + */ + +/** + * @addtogroup CAPI_MEDIA_VISION_IMAGE_CLASSIFICATION_MODULE + * @{ + */ + +/** + * @brief Creates image classification object handle. + * @details Use this function to create an image classification object handle. + * After creation the handle has to be prepared with + * mv_image_classification_prepare() function to prepare + * an image classification object. + * + * @since_tizen 9.0 + * + * @param[out] handle The handle to the image classification object to be created + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * + * @post Release @a handle by using mv_image_classification_destroy() function when + * it is not needed anymore. + * + * @code + * #include <mv_image_classification.h> + * ... + * mv_image_classification_h handle = NULL; + * mv_image_classification_create(&handle); + * ... + * mv_image_classification_destroy(handle); + * @endcode + * + * @see mv_image_classification_destroy() + */ +int mv_image_classification_create(mv_image_classification_h *handle); + +/** + * @brief Destroys image classification handle and releases all its resources. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the image classification object to be destroyed. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre Create an image classification handle by using mv_image_classification_create() + * + * @see mv_image_classification_create() + */ +int mv_image_classification_destroy(mv_image_classification_h handle); + +/** + * @brief Configures the backend to the inference handle. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + */ +int mv_image_classification_configure(mv_image_classification_h handle); + +/** + * @brief Prepares inference. + * @details Use this function to prepare inference based on + * the configured network. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + */ +int mv_image_classification_prepare(mv_image_classification_h handle); + +/** + * + * @brief Performs inference with a given face on the @a source. + * @details Use this function to inference with a given source. + * + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the image classification object. + * @param[in] source The handle to the source of the media. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an image classification handle by calling mv_image_classification_create() + * @pre Prepare an image classification by calling mv_image_classification_prepare() + * + * @par Inference Example + * @snippet image_classification_sync.c IC sync + */ +int mv_image_classification_inference(mv_image_classification_h handle, mv_source_h source); + +/** + * @brief Performs asynchronously the image classification inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function operates asynchronously, so it returns immediately upon invocation. + * The inference results are inserted into the outgoing queue within the framework + * in the order of processing, and the results can be obtained through mv_image_classification_get_label(). + * + * @param[in] handle The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_image_classification_create() + * @pre Prepare an inference by calling mv_image_classification_configure() + * @pre Prepare an inference by calling mv_image_classification_prepare() + * + * @par Async Inference Example + * @snippet image_classification_async.c IC async + */ +int mv_image_classification_inference_async(mv_image_classification_h handle, mv_source_h source); + +/** + * @brief Gets the image classification inference result count on the @a handle. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * @param[out] frame_number A frame number inferenced. + * @param[out] result_cnt A number of results. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_image_classification_create() + * @pre Prepare an inference by calling mv_image_classification_configure() + * @pre Prepare an inference by calling mv_image_classification_prepare() + * @pre Request an inference by calling mv_image_classification_inference() + */ +int mv_image_classification_get_result_count(mv_image_classification_h handle, unsigned long *frame_number, + unsigned int *result_cnt); + +/** + * @brief Gets the image classification inference result to a given index. + * + * @since_tizen 9.0 + * + * @remarks The @a label should not be released. + * @remarks The @a label is available until new inference is performed or @a handle is released. + * + * @param[in] handle The handle to the inference + * @param[in] index A result index. + * @param[out] label A label name to a detected object. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_image_classification_create() + * @pre Prepare an inference by calling mv_image_classification_configure() + * @pre Prepare an inference by calling mv_image_classification_prepare() + * @pre Request an inference by calling mv_image_classification_inference() + * @pre Get result count by calling mv_image_classification_get_result_count() + * + * @code + * #include <mv_image_classification.h> + * #include <stdio.h> + * ... + * mv_image_classification_h handle = NULL; + * mv_image_classification_create(&handle); + * ... + * // perform inference + * ... + * unsigned long frame_number; + * unsigned int cnt; + * mv_image_classification_get_result_count(handle, &frame_number, &cnt); + * for (unsigned long idx = 0; idx < cnt; ++idx) { + * const char *label = NULL; + * mv_image_classification_get_label(handle, idx, &label); + * printf("frame number = %ld, label = %s\n", frame_number, label); + * } + * mv_image_classification_destroy(handle); + * @endcode + */ +int mv_image_classification_get_label(mv_image_classification_h handle, unsigned int index, const char **label); +/** + * @} + */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIAVISION_MV_IMAGE_CLASSIFICATION_H__ */ diff --git a/include/mv_image_classification_internal.h b/include/mv_image_classification_internal.h index b4f526bd..442b3f86 100644 --- a/include/mv_image_classification_internal.h +++ b/include/mv_image_classification_internal.h @@ -25,178 +25,6 @@ extern "C" { #endif /* __cplusplus */ /** - * @brief Create image classification object handle. - * @details Use this function to create an image classification object handle. - * After creation the handle has to be prepared with - * @ref mv_image_classification_prepare() function to prepare - * an image classification object. - * - * @since_tizen 9.0 - * - * @param[out] out_handle The handle to the image classification object to be created - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @post Release @a handle by using - * @ref mv_image_classification_destroy() function when it is not needed - * anymore - * - * @see mv_image_classification_destroy() - */ -int mv_image_classification_create(mv_image_classification_h *out_handle); - -/** - * @brief Destroy image classification handle and releases all its resources. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the image classification object to be destroyed. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create an image classification handle by using @ref mv_image_classification_create() - * - * @see mv_image_classification_create() - */ -int mv_image_classification_destroy(mv_image_classification_h handle); - -/** - * @brief Configure the backend to the inference handle - * - * @since_tizen 9.0 - * - * @param [in] handle The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - */ -int mv_image_classification_configure(mv_image_classification_h handle); - -/** - * @brief Prepare inference. - * @details Use this function to prepare inference based on - * the configured network. - * - * @since_tizen 9.0 - * - * @param [in] handle The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - */ -int mv_image_classification_prepare(mv_image_classification_h handle); - -/** - * - * @brief Inference with a given face on the @a source - * @details Use this function to inference with a given source. - * - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the image classification object. - * @param[in] source The handle to the source of the media. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @pre Create a source handle by calling @ref mv_create_source() - * @pre Create an image classification handle by calling @ref mv_image_classification_create() - * @pre Prepare an image classification by calling @ref mv_image_classification_prepare() - */ -int mv_image_classification_inference(mv_image_classification_h handle, mv_source_h source); - -/** - * @internal - * @brief Performs asynchronously the image classification inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function operates asynchronously, so it returns immediately upon invocation. - * The inference results are inserted into the outgoing queue within the framework - * in the order of processing, and the results can be obtained through mv_image_classification_get_label(). - * - * @param[in] handle The handle to the inference - * @param[in] source The handle to the source of the media - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_image_classification_create() - * @pre Prepare an inference by calling mv_image_classification_configure() - * @pre Prepare an inference by calling mv_image_classification_prepare() - */ -int mv_image_classification_inference_async(mv_image_classification_h handle, mv_source_h source); - -/** - * @internal - * @brief Gets the image classification inference result count on the @a source. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[out] frame_number A frame number inferenced. - * @param[out] result_cnt A number of results. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_image_classification_create() - * @pre Prepare an inference by calling mv_image_classification_configure() - * @pre Prepare an inference by calling mv_image_classification_prepare() - * @pre Request an inference by calling mv_image_classification_inference() - */ -int mv_image_classification_get_result_count(mv_image_classification_h handle, unsigned long *frame_number, - unsigned int *result_cnt); - -/** - * @internal - * @brief Gets the image classification inference result to a given index. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[in] index A result index. - * @param[out] label A label name to a detected object. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_image_classification_create() - * @pre Prepare an inference by calling mv_image_classification_configure() - * @pre Prepare an inference by calling mv_image_classification_prepare() - * @pre Request an inference by calling mv_image_classification_inference() - * @pre Get result count by calling mv_image_classification_get_result_count() - */ -int mv_image_classification_get_label(mv_image_classification_h handle, unsigned int index, const char **label); - -/** * @brief Set user-given model information. * @details Use this function to change the model information instead of default one after calling @ref mv_image_classification_create(). * diff --git a/include/mv_image_classification_type.h b/include/mv_image_classification_type.h index a17d3959..2ecee02d 100644 --- a/include/mv_image_classification_type.h +++ b/include/mv_image_classification_type.h @@ -34,7 +34,7 @@ extern "C" { */ /** - * @brief The object detection 3d object handle. + * @brief The image classification object handle. * * @since_tizen 9.0 */ diff --git a/include/mv_object_detection.h b/include/mv_object_detection.h new file mode 100644 index 00000000..94e05aa9 --- /dev/null +++ b/include/mv_object_detection.h @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_MEDIAVISION_MV_OBJECT_DETECTION_H__ +#define __TIZEN_MEDIAVISION_MV_OBJECT_DETECTION_H__ + +#include <mv_common.h> +#include <mv_object_detection_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file mv_object_detection.h + * @brief This file contains the Inference based Media Vision API. + */ + +/** + * @addtogroup CAPI_MEDIA_VISION_OBJECT_DETECTION_MODULE + * @{ + */ + +/** + * @brief Creates a inference handle for object detection object. + * @details Use this function to create a inference handle. After the creation + * the object detection 3d task has to be prepared with + * mv_object_detection_prepare() function to prepare a network + * for the inference. + * + * @since_tizen 9.0 + * + * @remarks The @a infer should be released using mv_object_detection_destroy(). + * + * @param[out] infer The handle to the inference to be created. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * + * @code + * #include <mv_object_detection.h> + * ... + * mv_object_detection_h handle = NULL; + * mv_object_detection_create(&handle); + * ... + * mv_object_detection_destroy(handle); + * @endcode + * + * @see mv_object_detection_destroy() + * @see mv_object_detection_prepare() + */ +int mv_object_detection_create(mv_object_detection_h *infer); + +/** + * @brief Destroys inference handle and releases all its resources. + * + * @since_tizen 9.0 + * + * @param[in] infer The handle to the inference to be destroyed. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre Create inference handle by using mv_object_detection_create() + * + * @see mv_object_detection_create() + */ +int mv_object_detection_destroy(mv_object_detection_h infer); + +/** + * @brief Configures the backend for the object detection inference. + * + * @since_tizen 9.0 + * + * @param[in] infer The handle to the inference + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + */ +int mv_object_detection_configure(mv_object_detection_h infer); + +/** + * @brief Prepares the object detection inference. + * @details Use this function to prepare the object detection inference based on + * the configured network. + * + * @since_tizen 9.0 + * + * @param[in] infer The handle to the inference. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format + */ +int mv_object_detection_prepare(mv_object_detection_h infer); + +/** + * @brief Performs the object detection inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function is synchronous and may take considerable time to run. + * + * @param[in] infer The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_object_detection_create() + * @pre Prepare an inference by calling mv_object_detection_configure() + * @pre Prepare an inference by calling mv_object_detection_prepare() + * + * @par Inference Example + * @snippet object_detection_sync.c OD sync + */ +int mv_object_detection_inference(mv_object_detection_h infer, mv_source_h source); + +/** + * @brief Performs asynchronously the object detection inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function operates asynchronously, so it returns immediately upon invocation. + * The inference results are inserted into the outgoing queue within the framework + * in the order of processing, and the results can be obtained through + * mv_object_detection_get_result_count() and mv_object_detection_get_label(). + * + * @param[in] handle The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_object_detection_create() + * @pre Prepare an inference by calling mv_object_detection_configure() + * @pre Prepare an inference by calling mv_object_detection_prepare() + * + * @par Async Inference Example + * @snippet object_detection_async.c OD async + */ +int mv_object_detection_inference_async(mv_object_detection_h handle, mv_source_h source); + +/** + * @brief Gets the object detection inference result on the @a handle. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * @param[out] frame_number A frame number inferenced. + * @param[out] result_cnt A number of results. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_object_detection_create() + * @pre Prepare an inference by calling mv_object_detection_configure() + * @pre Prepare an inference by calling mv_object_detection_prepare() + * @pre Request an inference by calling mv_object_detection_inference() + */ +int mv_object_detection_get_result_count(mv_object_detection_h handle, unsigned long *frame_number, + unsigned int *result_cnt); + +/** + * @brief Gets a bound box to detected object region. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * @param[in] index A result index. + * @param[out] left An left position array to bound boxes. + * @param[out] top An top position array to bound boxes. + * @param[out] right An right position array to bound boxes. + * @param[out] bottom An bottom position array to bound boxes. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_object_detection_create() + * @pre Prepare an inference by calling mv_object_detection_configure() + * @pre Prepare an inference by calling mv_object_detection_prepare() + * @pre Prepare an inference by calling mv_object_detection_inference() + */ +int mv_object_detection_get_bound_box(mv_object_detection_h handle, unsigned int index, int *left, int *top, int *right, + int *bottom); +/** + * @} + */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIAVISION_MV_OBJECT_DETECTION_H__ */ diff --git a/include/mv_object_detection_internal.h b/include/mv_object_detection_internal.h index 54cfa8d5..80d83f22 100644 --- a/include/mv_object_detection_internal.h +++ b/include/mv_object_detection_internal.h @@ -37,50 +37,6 @@ extern "C" { /** * @internal - * @brief Creates a inference handle for object detection object. - * @details Use this function to create a inference handle. After the creation - * the object detection 3d task has to be prepared with - * mv_object_detection_prepare() function to prepare a network - * for the inference. - * - * @since_tizen 9.0 - * - * @remarks The @a infer should be released using mv_object_detection_destroy(). - * - * @param[out] infer The handle to the inference to be created. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @see mv_object_detection_destroy() - * @see mv_object_detection_prepare() - */ -int mv_object_detection_create(mv_object_detection_h *infer); - -/** - * @internal - * @brief Destroys inference handle and releases all its resources. - * - * @since_tizen 9.0 - * - * @param[in] infer The handle to the inference to be destroyed. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create inference handle by using mv_object_detection_create() - * - * @see mv_object_detection_create() - */ -int mv_object_detection_destroy(mv_object_detection_h infer); - -/** - * @internal * @brief Set user-given model information. * @details Use this function to change the model information instead of default one after calling @ref mv_object_detection_create(). * @@ -104,150 +60,6 @@ int mv_object_detection_set_model(mv_object_detection_h handle, const char *mode /** * @internal - * @brief Configures the backend for the object detection inference. - * - * @since_tizen 9.0 - * - * @param [in] infer The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - */ -int mv_object_detection_configure(mv_object_detection_h infer); - -/** - * @internal - * @brief Prepares the object detection inference - * @details Use this function to prepare the object detection inference based on - * the configured network. - * - * @since_tizen 9.0 - * - * @param[in] infer The handle to the inference. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_PERMISSION_DENIED Permission denied - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format - */ -int mv_object_detection_prepare(mv_object_detection_h infer); - -/** - * @internal - * @brief Performs the object detection inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function is synchronous and may take considerable time to run. - * - * @param[in] source The handle to the source of the media - * @param[in] infer The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_object_detect_create() - * @pre Prepare an inference by calling mv_object_detect_configure() - * @pre Prepare an inference by calling mv_object_detect_prepare() - */ -int mv_object_detection_inference(mv_object_detection_h infer, mv_source_h source); - -/** - * @internal - * @brief Performs asynchronously the object detection inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function operates asynchronously, so it returns immediately upon invocation. - * The inference results are inserted into the outgoing queue within the framework - * in the order of processing, and the results can be obtained through mv_object_detection_get_result() - * and mv_object_detection_get_label(). - * - * @param[in] handle The handle to the inference - * @param[in] source The handle to the source of the media - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_object_detect_create() - * @pre Prepare an inference by calling mv_object_detect_configure() - * @pre Prepare an inference by calling mv_object_detect_prepare() - */ -int mv_object_detection_inference_async(mv_object_detection_h handle, mv_source_h source); - -/** - * @internal - * @brief Gets the object detection inference result on the @a source. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[out] frame_number A frame number inferenced. - * @param[out] result_cnt A number of results. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_object_detect_create() - * @pre Prepare an inference by calling mv_object_detect_configure() - * @pre Prepare an inference by calling mv_object_detect_prepare() - * @pre Request an inference by calling mv_object_detect_inference() - */ -int mv_object_detection_get_result_count(mv_object_detection_h handle, unsigned long *frame_number, - unsigned int *result_cnt); - -/** - * @internal - * @brief Gets a bound box to detected object region - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[in] index A result index. - * @param[out] left An left position array to bound boxes. - * @param[out] top An top position array to bound boxes. - * @param[out] right An right position array to bound boxes. - * @param[out] bottom An bottom position array to bound boxes. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_object_detect_create() - * @pre Prepare an inference by calling mv_object_detect_configure() - * @pre Prepare an inference by calling mv_object_detect_prepare() - * @pre Prepare an inference by calling mv_object_detect_inference() - */ -int mv_object_detection_get_bbox(mv_object_detection_h handle, unsigned int index, int *left, int *top, int *right, - int *bottom); - -/** - * @internal * @brief Set user-given inference engine and device types for inference. * @details Use this function to change the inference engine and device types for inference instead of default ones after calling @ref mv_object_detection_create(). * diff --git a/include/mv_object_detection_type.h b/include/mv_object_detection_type.h index a9490a5c..0e7b921f 100644 --- a/include/mv_object_detection_type.h +++ b/include/mv_object_detection_type.h @@ -25,11 +25,11 @@ extern "C" { /** * @file mv_object_detection_type.h - * @brief This file contains the face recognition handle for Mediavision. + * @brief This file contains the object detection handle for Mediavision. */ /** - * @addtogroup CAPI_MEDIA_VISION_OBJECT_DETECT_MODULE + * @addtogroup CAPI_MEDIA_VISION_OBJECT_DETECTION_MODULE * @{ */ @@ -40,8 +40,6 @@ extern "C" { */ typedef void *mv_object_detection_h; -typedef void (*mv_completion_cb)(mv_object_detection_h handle, void *user_data); - /** * @} */ diff --git a/include/mv_pose_landmark.h b/include/mv_pose_landmark.h new file mode 100644 index 00000000..588fb880 --- /dev/null +++ b/include/mv_pose_landmark.h @@ -0,0 +1,244 @@ +/** + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_MEDIAVISION_MV_POSE_LANDMARK_H__ +#define __TIZEN_MEDIAVISION_MV_POSE_LANDMARK_H__ + +#include <mv_common.h> +#include <mv_pose_landmark_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file mv_object_detection.h + * @brief This file contains the Inference based Media Vision API. + */ + +/** + * @addtogroup CAPI_MEDIA_VISION_POSE_LANDMARK_MODULE + * @{ + */ + +/** + * @brief Creates pose landmark object handle. + * @details Use this function to create an pose landmark object handle. + * After creation the handle has to be prepared with + * mv_pose_landmark_prepare() function to prepare + * a pose landmark object. + * + * @since_tizen 9.0 + * + * @param[out] handle The handle to the pose landmark object to be created + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * + * @post Release @a handle by using + * mv_pose_landmark_destroy() function when it is not needed + * anymore + * + * @code + * #include <mv_pose_landmark.h> + * ... + * mv_pose_landmark_h handle = NULL; + * mv_pose_landmark_create(&handle); + * ... + * mv_pose_landmark_destroy(handle); + * @endcode + * + * @see mv_pose_landmark_destroy() + */ +int mv_pose_landmark_create(mv_pose_landmark_h *handle); + +/** + * @brief Destroys pose landmark handle and releases all its resources. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the pose landmark object to be destroyed. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre Create an pose landmark handle by using mv_pose_landmark_create() + * + * @see mv_pose_landmark_create() + */ +int mv_pose_landmark_destroy(mv_pose_landmark_h handle); + +/** + * @brief Configures the backend to the inference handle. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + */ +int mv_pose_landmark_configure(mv_pose_landmark_h handle); + +/** + * @brief Prepares inference. + * @details Use this function to prepare inference based on + * the configured network. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + */ +int mv_pose_landmark_prepare(mv_pose_landmark_h handle); + +/** + * + * @brief Inferences with a given facial on the @a source. + * @details Use this function to inference with a given source. + * + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the pose landmark object. + * @param[in] source The handle to the source of the media. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an pose landmark handle by calling mv_pose_landmark_create() + * @pre Prepare an inference by calling mv_object_detect_configure() + * @pre Prepare an pose landmark by calling mv_pose_landmark_prepare() + * + * @par Inference Example + * @snippet pose_landmark_sync.c PLD sync + */ +int mv_pose_landmark_inference(mv_pose_landmark_h handle, mv_source_h source); + +/** + * @brief Performs asynchronously the pose landmark inference on the @a source. + * + * @since_tizen 9.0 + * @remarks This function operates asynchronously, so it returns immediately upon invocation. + * The inference results are inserted into the outgoing queue within the framework + * in the order of processing, and the results can be obtained through mv_pose_landmark_get_result_count() + * and mv_pose_landmark_get_position(). + * + * @param[in] handle The handle to the inference + * @param[in] source The handle to the source of the media + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace + * isn't supported + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_pose_landmark_create() + * @pre Prepare an inference by calling mv_pose_landmark_configure() + * @pre Prepare an inference by calling mv_pose_landmark_prepare() + * + * @par Async Inference Example + * @snippet pose_landmark_async.c PLD async + */ +int mv_pose_landmark_inference_async(mv_pose_landmark_h handle, mv_source_h source); + +/** + * @brief Gets the result count to objects. + * + * @since_tizen 9.0 + * + * @param[in] handle The handle to the inference + * @param[out] frame_number A frame number inferenced. + * @param[out] result_cnt A number of results. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_pose_landmark_create() + * @pre Prepare an inference by calling mv_pose_landmark_configure() + * @pre Prepare an inference by calling mv_pose_landmark_prepare() + * @pre Request an inference by calling mv_pose_landmark_inference() + */ +int mv_pose_landmark_get_result_count(mv_pose_landmark_h handle, unsigned long *frame_number, unsigned int *result_cnt); + +/** + * @brief Gets the pose landmark position values to a given index. + * + * @since_tizen 9.0 + * @remarks pos_x and pos_y arrays are allocated internally by the framework and will remain valid + * until the handle is released. + * Please do not deallocate them directly, and if you want to use them after the handle is released, + * please copy them to user memory and use the copy. + * + * This function operates differently depending on the inference request method. + * - After mv_facial_landmark_inference() calls, this function returns facial landmark positions immediately. + * - After mv_facial_landmark_inference_async() calls, this function can be blocked until the asynchronous inference request is completed + * or the timeout occurs if no result within 3 seconds. + * + * Additionally, after calling the mv_facial_landmark_inference_async function, the function operates + * in asynchronous mode until the handle is released. + * + * @param[in] handle The handle to the inference + * @param[in] index A result index. + * @param[out] pos_x An array containing x-coordinate values. + * @param[out] pos_y An array containing y-coordinate values. + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MEDIA_VISION_ERROR_NONE Successful + * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported + * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error + * + * @pre Create a source handle by calling mv_create_source() + * @pre Create an inference handle by calling mv_pose_landmark_create() + * @pre Prepare an inference by calling mv_pose_landmark_configure() + * @pre Prepare an inference by calling mv_pose_landmark_prepare() + * @pre Prepare an inference by calling mv_pose_landmark_inference() + * @pre Get result count by calling mv_pose_landmark_get_result_count() + */ +int mv_pose_landmark_get_position(mv_pose_landmark_h handle, unsigned int index, unsigned int *pos_x, + unsigned int *pos_y); +/** + * @} + */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIAVISION_MV_POSE_LANDMARK_H__ */ diff --git a/include/mv_pose_landmark_internal.h b/include/mv_pose_landmark_internal.h index 29438922..9d17dc94 100644 --- a/include/mv_pose_landmark_internal.h +++ b/include/mv_pose_landmark_internal.h @@ -25,47 +25,6 @@ extern "C" { #endif /* __cplusplus */ /** - * @brief Creates pose landmark object handle. - * @details Use this function to create an pose landmark object handle. - * After creation the handle has to be prepared with - * @ref mv_pose_landmark_prepare() function to prepare - * an pose landmark object. - * - * @since_tizen 9.0 - * - * @param[out] out_handle The handle to the pose landmark object to be created - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @post Release @a handle by using - * @ref mv_pose_landmark_destroy() function when it is not needed - * anymore - * - * @see mv_pose_landmark_destroy() - */ -int mv_pose_landmark_create(mv_pose_landmark_h *out_handle); - -/** - * @brief Destroys pose landmark handle and releases all its resources. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the pose landmark object to be destroyed. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * - * @pre Create an pose landmark handle by using @ref mv_pose_landmark_create() - * - * @see mv_pose_landmark_create() - */ -int mv_pose_landmark_destroy(mv_pose_landmark_h handle); - -/** * @brief Set user-given model information. * @details Use this function to change the model information instead of default one after calling @ref mv_pose_landmark_create(). * @@ -88,151 +47,6 @@ int mv_pose_landmark_set_model(mv_pose_landmark_h handle, const char *model_name const char *meta_file, const char *label_file); /** - * @brief Configures the backend to the inference handle - * - * @since_tizen 9.0 - * - * @param [in] handle The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - */ -int mv_pose_landmark_configure(mv_pose_landmark_h handle); - -/** - * @brief Prepares inference. - * @details Use this function to prepare inference based on - * the configured network. - * - * @since_tizen 9.0 - * - * @param [in] handle The handle to the inference - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - */ -int mv_pose_landmark_prepare(mv_pose_landmark_h handle); - -/** - * - * @brief Inferences with a given facial on the @a source - * @details Use this function to inference with a given source. - * - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the pose landmark object. - * @param[in] source The handle to the source of the media. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory - * - * @pre Create a source handle by calling @ref mv_create_source() - * @pre Create an pose landmark handle by calling @ref mv_pose_landmark_create() - * @pre Prepare an inference by calling mv_object_detect_configure() - * @pre Prepare an pose landmark by calling @ref mv_pose_landmark_prepare() - */ -int mv_pose_landmark_inference(mv_pose_landmark_h handle, mv_source_h source); - -/** - * @internal - * @brief Performs asynchronously the pose landmark inference on the @a source. - * - * @since_tizen 9.0 - * @remarks This function operates asynchronously, so it returns immediately upon invocation. - * The inference results are inserted into the outgoing queue within the framework - * in the order of processing, and the results can be obtained through mv_pose_landmark_get_pos(). - * - * @param[in] handle The handle to the inference - * @param[in] source The handle to the source of the media - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace - * isn't supported - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_pose_landmark_create() - * @pre Prepare an inference by calling mv_pose_landmark_configure() - * @pre Prepare an inference by calling mv_pose_landmark_prepare() - */ -int mv_pose_landmark_inference_async(mv_pose_landmark_h handle, mv_source_h source); - -/** - * @internal - * @brief Gets the result count to objects. - * - * @since_tizen 9.0 - * - * @param[in] handle The handle to the inference - * @param[out] frame_number A frame number inferenced. - * @param[out] result_cnt A number of results. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_pose_landmark_create() - * @pre Prepare an inference by calling mv_pose_landmark_configure() - * @pre Prepare an inference by calling mv_pose_landmark_prepare() - * @pre Request an inference by calling mv_pose_landmark_inference() - */ -int mv_pose_landmark_get_result_count(mv_pose_landmark_h handle, unsigned long *frame_number, unsigned int *result_cnt); - -/** - * @internal - * @brief Gets the pose landmark position values to a given index. - * - * @since_tizen 9.0 - * @remarks pos_x and pos_y arrays are allocated internally by the framework and will remain valid - * until the handle is released. - * Please do not deallocate them directly, and if you want to use them after the handle is released, - * please copy them to user memory and use the copy. - * - * This function operates differently depending on the inference request method. - * - After mv_facial_landmark_inference() calls, this function returns facial landmark positions immediately. - * - After mv_facial_landmark_inference_async() calls, this function can be blocked until the asynchronous inference request is completed - * or the timeout occurs if no result within 3 seconds. - * - * Additionally, after calling the mv_facial_landmark_inference_async function, the function operates - * in asynchronous mode until the handle is released. - * - * @param[in] handle The handle to the inference - * @param[in] index A result index. - * @param[out] pos_x An array containing x-coordinate values. - * @param[out] pos_y An array containing y-coordinate values. - * - * @return @c 0 on success, otherwise a negative error value - * @retval #MEDIA_VISION_ERROR_NONE Successful - * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported - * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error - * - * @pre Create a source handle by calling mv_create_source() - * @pre Create an inference handle by calling mv_pose_landmark_create() - * @pre Prepare an inference by calling mv_pose_landmark_configure() - * @pre Prepare an inference by calling mv_pose_landmark_prepare() - * @pre Prepare an inference by calling mv_pose_landmark_inference() - * @pre Get result count by calling mv_pose_landmark_get_result_count() - */ -int mv_pose_landmark_get_position(mv_pose_landmark_h handle, unsigned int index, unsigned int *pos_x, - unsigned int *pos_y); - -/** * @brief Set user-given backend and device types for inference. * @details Use this function to change the backend and device types for inference instead of default ones after calling @ref mv_pose_landmark_create(). * diff --git a/mv_machine_learning/image_classification/CMakeLists.txt b/mv_machine_learning/image_classification/CMakeLists.txt index b9f29b4f..81ccfca9 100644 --- a/mv_machine_learning/image_classification/CMakeLists.txt +++ b/mv_machine_learning/image_classification/CMakeLists.txt @@ -18,5 +18,6 @@ install( DIRECTORY ${PROJECT_SOURCE_DIR}/../../include/ DESTINATION include/media FILES_MATCHING PATTERN "mv_image_classification_internal.h" + PATTERN "mv_image_classification.h" PATTERN "mv_image_classification_type.h" )
\ No newline at end of file diff --git a/mv_machine_learning/image_classification/src/mv_image_classification.cpp b/mv_machine_learning/image_classification/src/mv_image_classification.cpp index 104a9e26..18e2583a 100644 --- a/mv_machine_learning/image_classification/src/mv_image_classification.cpp +++ b/mv_machine_learning/image_classification/src/mv_image_classification.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "mv_image_classification.h" #include "Context.h" #include "ITask.h" #include "ImageClassificationAdapter.h" @@ -38,7 +39,8 @@ using namespace mediavision::machine_learning; using namespace MediaVision::Common; using namespace mediavision::machine_learning::exception; -static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference.image" }; +static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference", + "http://tizen.org/feature/vision.inference.image" }; static const size_t num_keys = sizeof(feature_keys) / sizeof(char *); int mv_image_classification_create(mv_image_classification_h *out_handle) diff --git a/mv_machine_learning/landmark_detection/CMakeLists.txt b/mv_machine_learning/landmark_detection/CMakeLists.txt index 35ad9c3e..104e4661 100644 --- a/mv_machine_learning/landmark_detection/CMakeLists.txt +++ b/mv_machine_learning/landmark_detection/CMakeLists.txt @@ -18,7 +18,9 @@ install( DIRECTORY ${PROJECT_SOURCE_DIR}/../../include/ DESTINATION include/media FILES_MATCHING PATTERN "mv_facial_landmark_internal.h" + PATTERN "mv_facial_landmark.h" PATTERN "mv_facial_landmark_type.h" PATTERN "mv_pose_landmark_internal.h" + PATTERN "mv_pose_landmark.h" PATTERN "mv_pose_landmark_type.h" ) diff --git a/mv_machine_learning/landmark_detection/src/mv_facial_landmark.cpp b/mv_machine_learning/landmark_detection/src/mv_facial_landmark.cpp index 8020ab03..3149688f 100644 --- a/mv_machine_learning/landmark_detection/src/mv_facial_landmark.cpp +++ b/mv_machine_learning/landmark_detection/src/mv_facial_landmark.cpp @@ -14,12 +14,13 @@ * limitations under the License. */ +#include "mv_facial_landmark_internal.h" +#include "mv_facial_landmark.h" #include "Context.h" #include "FacialLandmarkAdapter.h" #include "ITask.h" #include "MvMlException.h" #include "landmark_detection_type.h" -#include "mv_facial_landmark_internal.h" #include "mv_feature_key.h" #include "mv_private.h" #include "native_capi.h" @@ -38,7 +39,7 @@ using namespace mediavision::machine_learning; using namespace MediaVision::Common; using namespace mediavision::machine_learning::exception; -static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference.image", +static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference", "http://tizen.org/feature/vision.inference.face" }; static const size_t num_keys = sizeof(feature_keys) / sizeof(char *); diff --git a/mv_machine_learning/landmark_detection/src/mv_pose_landmark.cpp b/mv_machine_learning/landmark_detection/src/mv_pose_landmark.cpp index e7fe6d9e..d78498cc 100644 --- a/mv_machine_learning/landmark_detection/src/mv_pose_landmark.cpp +++ b/mv_machine_learning/landmark_detection/src/mv_pose_landmark.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ +#include "mv_pose_landmark_internal.h" +#include "mv_pose_landmark.h" #include "Context.h" #include "ITask.h" #include "MvMlException.h" #include "PoseLandmarkAdapter.h" #include "landmark_detection_type.h" #include "mv_feature_key.h" -#include "mv_pose_landmark_internal.h" #include "mv_private.h" #include "native_capi.h" @@ -38,7 +39,7 @@ using namespace mediavision::machine_learning; using namespace MediaVision::Common; using namespace mediavision::machine_learning::exception; -static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference.image", +static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference", "http://tizen.org/feature/vision.inference.face" }; static const size_t num_keys = sizeof(feature_keys) / sizeof(char *); diff --git a/mv_machine_learning/object_detection/CMakeLists.txt b/mv_machine_learning/object_detection/CMakeLists.txt index 121791ca..588813a8 100644 --- a/mv_machine_learning/object_detection/CMakeLists.txt +++ b/mv_machine_learning/object_detection/CMakeLists.txt @@ -18,8 +18,10 @@ install( DIRECTORY ${PROJECT_SOURCE_DIR}/../../include/ DESTINATION include/media FILES_MATCHING PATTERN "mv_object_detection_internal.h" + PATTERN "mv_object_detection.h" PATTERN "mv_object_detection_type.h" PATTERN "mv_face_detection_internal.h" + PATTERN "mv_face_detection.h" PATTERN "mv_face_detection_type.h" ) install( diff --git a/mv_machine_learning/object_detection/src/mv_face_detection.cpp b/mv_machine_learning/object_detection/src/mv_face_detection.cpp index e07cd527..41d22373 100644 --- a/mv_machine_learning/object_detection/src/mv_face_detection.cpp +++ b/mv_machine_learning/object_detection/src/mv_face_detection.cpp @@ -14,11 +14,12 @@ * limitations under the License. */ +#include "mv_face_detection_internal.h" +#include "mv_face_detection.h" #include "Context.h" #include "FaceDetectionAdapter.h" #include "ITask.h" #include "MvMlException.h" -#include "mv_face_detection_internal.h" #include "mv_feature_key.h" #include "mv_private.h" #include "native_capi.h" @@ -40,7 +41,7 @@ using namespace mediavision::machine_learning; using namespace MediaVision::Common; using namespace mediavision::machine_learning::exception; -static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference.image", +static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference", "http://tizen.org/feature/vision.inference.face" }; static const size_t num_keys = sizeof(feature_keys) / sizeof(char *); @@ -320,7 +321,7 @@ int mv_face_detection_get_result_count(mv_face_detection_h handle, unsigned long return MEDIA_VISION_ERROR_NONE; } -int mv_face_detection_get_bbox(mv_face_detection_h handle, unsigned int index, int *left, int *top, int *right, +int mv_face_detection_get_bound_box(mv_face_detection_h handle, unsigned int index, int *left, int *top, int *right, int *bottom) { MEDIA_VISION_SUPPORT_CHECK(mv_check_feature_key(feature_keys, num_keys, true)); diff --git a/mv_machine_learning/object_detection/src/mv_object_detection.cpp b/mv_machine_learning/object_detection/src/mv_object_detection.cpp index 3e2be8ae..5ce06a45 100644 --- a/mv_machine_learning/object_detection/src/mv_object_detection.cpp +++ b/mv_machine_learning/object_detection/src/mv_object_detection.cpp @@ -14,12 +14,13 @@ * limitations under the License. */ +#include "mv_object_detection_internal.h" +#include "mv_object_detection.h" #include "Context.h" #include "ITask.h" #include "MvMlException.h" #include "ObjectDetectionAdapter.h" #include "mv_feature_key.h" -#include "mv_object_detection_internal.h" #include "mv_private.h" #include "native_capi.h" #include "object_detection_type.h" @@ -40,8 +41,8 @@ using namespace mediavision::machine_learning; using namespace MediaVision::Common; using namespace mediavision::machine_learning::exception; -static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference.image", - "http://tizen.org/feature/vision.inference.face" }; +static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference", + "http://tizen.org/feature/vision.inference.image" }; static const size_t num_keys = sizeof(feature_keys) / sizeof(char *); int mv_object_detection_create(mv_object_detection_h *handle) @@ -318,7 +319,7 @@ int mv_object_detection_get_result_count(mv_object_detection_h handle, unsigned return MEDIA_VISION_ERROR_NONE; } -int mv_object_detection_get_bbox(mv_object_detection_h handle, unsigned int index, int *left, int *top, int *right, +int mv_object_detection_get_bound_box(mv_object_detection_h handle, unsigned int index, int *left, int *top, int *right, int *bottom) { MEDIA_VISION_SUPPORT_CHECK(mv_check_feature_key(feature_keys, num_keys, true)); diff --git a/packaging/capi-media-vision.spec b/packaging/capi-media-vision.spec index bccb40e7..f4f98406 100644 --- a/packaging/capi-media-vision.spec +++ b/packaging/capi-media-vision.spec @@ -423,13 +423,16 @@ find . -name '*.gcno' -not -path "./test/*" -not -path "./mv_machine_learning/*" %endif %if "%{enable_ml_image_classification}" == "1" %{_includedir}/media/mv_image_classification_internal.h +%{_includedir}/media/mv_image_classification.h %{_includedir}/media/mv_image_classification_type.h %{_libdir}/pkgconfig/*image-classification.pc %endif %if "%{enable_ml_object_detection}" == "1" %{_includedir}/media/mv_object_detection_internal.h +%{_includedir}/media/mv_object_detection.h %{_includedir}/media/mv_object_detection_type.h %{_includedir}/media/mv_face_detection_internal.h +%{_includedir}/media/mv_face_detection.h %{_includedir}/media/mv_face_detection_type.h %{_includedir}/media/IObjectDetection.h %{_includedir}/media/object_detection_type.h @@ -442,8 +445,10 @@ find . -name '*.gcno' -not -path "./test/*" -not -path "./mv_machine_learning/*" %endif %if "%{enable_ml_landmark_detection}" == "1" %{_includedir}/media/mv_facial_landmark_internal.h +%{_includedir}/media/mv_facial_landmark.h %{_includedir}/media/mv_facial_landmark_type.h %{_includedir}/media/mv_pose_landmark_internal.h +%{_includedir}/media/mv_pose_landmark.h %{_includedir}/media/mv_pose_landmark_type.h %{_libdir}/pkgconfig/*landmark-detection.pc %endif diff --git a/test/testsuites/machine_learning/image_classification/test_image_classification.cpp b/test/testsuites/machine_learning/image_classification/test_image_classification.cpp index ba3037bc..7b297b02 100644 --- a/test/testsuites/machine_learning/image_classification/test_image_classification.cpp +++ b/test/testsuites/machine_learning/image_classification/test_image_classification.cpp @@ -23,6 +23,7 @@ #include "ImageHelper.h" #include "mv_image_classification_internal.h" +#include "mv_image_classification.h" #define IMAGE_PATH TEST_RES_PATH "/res/inference/images/banana.jpg" diff --git a/test/testsuites/machine_learning/image_classification/test_image_classification_async.cpp b/test/testsuites/machine_learning/image_classification/test_image_classification_async.cpp index e292a53f..7f0ef277 100644 --- a/test/testsuites/machine_learning/image_classification/test_image_classification_async.cpp +++ b/test/testsuites/machine_learning/image_classification/test_image_classification_async.cpp @@ -23,6 +23,7 @@ #include "ImageHelper.h" #include "mv_image_classification_internal.h" +#include "mv_image_classification.h" #define IMAGE_PATH TEST_RES_PATH "/res/inference/images/banana.jpg" #define MAX_INFERENCE_ITERATION 50 diff --git a/test/testsuites/machine_learning/landmark_detection/test_landmark_detection.cpp b/test/testsuites/machine_learning/landmark_detection/test_landmark_detection.cpp index 752553c0..134a1cf4 100644 --- a/test/testsuites/machine_learning/landmark_detection/test_landmark_detection.cpp +++ b/test/testsuites/machine_learning/landmark_detection/test_landmark_detection.cpp @@ -22,7 +22,9 @@ #include "ImageHelper.h" #include "mv_facial_landmark_internal.h" +#include "mv_facial_landmark.h" #include "mv_pose_landmark_internal.h" +#include "mv_pose_landmark.h" #define IMG_FACE TEST_RES_PATH "/res/inference/images/faceLandmark.jpg" #define IMG_POSE TEST_RES_PATH "/res/inference/images/poseLandmark.jpg" diff --git a/test/testsuites/machine_learning/landmark_detection/test_landmark_detection_async.cpp b/test/testsuites/machine_learning/landmark_detection/test_landmark_detection_async.cpp index 93e7f3fc..caa4437b 100644 --- a/test/testsuites/machine_learning/landmark_detection/test_landmark_detection_async.cpp +++ b/test/testsuites/machine_learning/landmark_detection/test_landmark_detection_async.cpp @@ -23,7 +23,9 @@ #include "ImageHelper.h" #include "mv_facial_landmark_internal.h" +#include "mv_facial_landmark.h" #include "mv_pose_landmark_internal.h" +#include "mv_pose_landmark.h" #define IMG_FACE TEST_RES_PATH "/res/inference/images/faceLandmark.jpg" #define IMG_POSE TEST_RES_PATH "/res/inference/images/poseLandmark.jpg" diff --git a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp index aaee147b..b9432d62 100644 --- a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp +++ b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp @@ -22,7 +22,9 @@ #include "ImageHelper.h" #include "mv_face_detection_internal.h" +#include "mv_face_detection.h" #include "mv_object_detection_internal.h" +#include "mv_object_detection.h" #define IMG_DOG TEST_RES_PATH "/res/inference/images/dog2.jpg" #define IMG_FACE TEST_RES_PATH "/res/inference/images/faceDetection.jpg" @@ -184,7 +186,7 @@ TEST(ObjectDetectionTest, InferenceShouldBeOk) for (unsigned int idx = 0; idx < number_of_objects; ++idx) { int left, top, right, bottom; - int ret = mv_object_detection_get_bbox(handle, idx, &left, &top, &right, &bottom); + int ret = mv_object_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); ASSERT_EQ(coordinate_answers[answer_idx][idx][0], left); @@ -252,7 +254,7 @@ TEST(FaceDetectionTest, InferenceShouldBeOk) for (unsigned int idx = 0; idx < number_of_objects; ++idx) { int left, top, right, bottom; - int ret = mv_face_detection_get_bbox(handle, idx, &left, &top, &right, &bottom); + int ret = mv_face_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); ASSERT_EQ(coordinate_answers[idx][0], left); diff --git a/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp b/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp index 5084b276..4a7cdd81 100644 --- a/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp +++ b/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp @@ -23,7 +23,9 @@ #include "ImageHelper.h" #include "mv_face_detection_internal.h" +#include "mv_face_detection.h" #include "mv_object_detection_internal.h" +#include "mv_object_detection.h" #define IMG_DOG TEST_RES_PATH "/res/inference/images/dog2.jpg" #define IMG_FACE TEST_RES_PATH "/res/inference/images/faceDetection.jpg" @@ -62,7 +64,7 @@ void object_detection_callback(void *user_data) for (unsigned int idx = 0; idx < number_of_objects; ++idx) { int left, top, right, bottom; - int ret = mv_object_detection_get_bbox(handle, idx, &left, &top, &right, &bottom); + int ret = mv_object_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); ASSERT_EQ(coordinate_answers[idx][0], left); @@ -202,7 +204,7 @@ void face_detection_callback(void *user_data) for (unsigned int idx = 0; idx < number_of_objects; ++idx) { int left, top, right, bottom; - int ret = mv_face_detection_get_bbox(handle, idx, &left, &top, &right, &bottom); + int ret = mv_face_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); ASSERT_EQ(coordinate_answers[idx][0], left); |