From: Vibhav Aggarwal Date: Mon, 26 Aug 2024 06:54:21 +0000 (+0900) Subject: [UTC][mediavision][ACR-1848] Add new test cases X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0d2b53a07987217f26879e18737b3d86e764c1c;p=test%2Ftct%2Fnative%2Fapi.git [UTC][mediavision][ACR-1848] Add new test cases Change-Id: I8cc1d725022b5b139275e51fcda7835b22e24cbe Signed-off-by: Vibhav Aggarwal --- diff --git a/scripts_tpk/spec.sh b/scripts_tpk/spec.sh index b01ee78b9..9c4e70c94 100644 --- a/scripts_tpk/spec.sh +++ b/scripts_tpk/spec.sh @@ -809,9 +809,6 @@ case "$1" in "org.tizen.capi-media-vision-dl-native-utc") echo "Installing pre-requisites for the package $1" - RPK_DIR="/opt/usr/globalapps/mediavision.face.recognition" - DL_MODEL_DIR="$RPK_DIR/models/tflite" - mkdir -p $DEVICE_PHYSICAL_STORAGE_30/res/inference/models mkdir -p $DEVICE_PHYSICAL_STORAGE_30/res/inference/images cp res/inference/models/* $DEVICE_PHYSICAL_STORAGE_30/res/inference/models/ @@ -823,11 +820,19 @@ case "$1" in cp res/face_recognition/images/P1/* $DEVICE_PHYSICAL_STORAGE_30/res/face_recognition/images/P1/ cp res/face_recognition/images/P2/* $DEVICE_PHYSICAL_STORAGE_30/res/face_recognition/images/P2/ - mkdir -p $DL_MODEL_DIR - cp res/face_recognition/models/* $DL_MODEL_DIR + TASK_NAMES=("face_recognition" "image_classification" "landmark_detection" "object_detection") - chsmack -a "User::App::Shared" -r $RPK_DIR - chsmack -e "User::App::Shared" -r $RPK_DIR + for TASK in "${TASK_NAMES[@]}"; do + TASK_PATH=$(echo $TASK | tr '_' '.') # replace underscore with dot for path + RPK_DIR="/opt/usr/globalapps/mediavision.$TASK_PATH" + DL_MODEL_DIR="$RPK_DIR/models/tflite" + + mkdir -p $DL_MODEL_DIR + cp res/$TASK/models/* $DL_MODEL_DIR + + chsmack -a "User::App::Shared" -r $RPK_DIR + chsmack -e "User::App::Shared" -r $RPK_DIR + done ;; "org.tizen.capi-message-port-native-utc") echo "Installing pre-requisites for the package $1" diff --git a/src/utc/capi-media-vision-dl/CMakeLists.txt b/src/utc/capi-media-vision-dl/CMakeLists.txt index 19b1f6f72..ea407e959 100644 --- a/src/utc/capi-media-vision-dl/CMakeLists.txt +++ b/src/utc/capi-media-vision-dl/CMakeLists.txt @@ -7,8 +7,15 @@ SET(CAPI_LIB "capi-media-vision") SET(TC_SOURCES utc-mv_common.c utc-mv_inference.c + utc-mv_image_classification.c + utc-mv_object_detection.c + utc-mv_face_detection.c + utc-mv_facial_landmark.c + utc-mv_pose_landmark.c ) +MESSAGE(WARNING "[DEBUG] here") + IF( DEFINED TIZENIOT || DEFINED MOBILE || DEFINED WEARABLE) SET(TC_SOURCES utc-mv_face_recognition.c @@ -23,10 +30,13 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED bundle storage dlog + mv_common + mv_image_classification + mv_landmark_detection + mv_object_detection json-glib-1.0 libtbm glib-2.0 - dlog ) INCLUDE_DIRECTORIES( diff --git a/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-001.json b/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-001.json new file mode 100644 index 000000000..a22c54425 --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-001.json @@ -0,0 +1,34 @@ +{ + "input": [ + { + "tensor1": { + "name": "input_2", + "shape_type": "NHWC", + "shape_dims": [ 1, 224, 224, 3 ], + "data_type": "FLOAT32", + "color_space": "RGB888", + "preprocess": { + "normalization": { + "mean": [ 127.5, 127.5, 127.5 ], + "std": [ 127.5, 127.5, 127.5 ] + } + } + } + } + ], + "output": [ + { + "tensor1": { + "name": "dense_3/Softmax", + "postprocess": { + "score": { + "index": [ -1, 1 ], + "top_number": 5, + "threshold": 0.3, + "score_type": "NORMAL" + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-001.tflite b/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-001.tflite new file mode 100644 index 000000000..db266303a Binary files /dev/null and b/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-001.tflite differ diff --git a/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-label.txt b/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-label.txt new file mode 100644 index 000000000..1ee8e6928 --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/image_classification/models/image-classification-label.txt @@ -0,0 +1,74 @@ +Apple +Backpack +Balloon +Banana +Barrel +Baseball_bat +Beer +Bench +Bicycle +Book +Bookcase +Boot +Camel +Camera +Cannon +Canoe +Car +Castle +Coat +Computer_keyboard +Cosmetics +Couch +Cowboy_hat +Crab +Cucumber +Desk +Dog +Doll +Door +Dragonfly +Drum +Earrings +Football +Fountain +Frog +Guitar +Ice_cream +Jacket +Jellyfish +Kite +Lamp +Lemon +Lipstick +Mushroom +Necklace +Orange +Parachute +Pillow +Pizza +Rabbit +Sandal +Saxophone +Scarf +Shirt +Shorts +Snake +Sock +Spoon +Strawberry +Suit +Sunglasses +Surfboard +Tank +Taxi +Television +Tent +Tie +Tiger +Traffic_light +Train +Umbrella +Whale +Wheel +Wine diff --git a/src/utc/capi-media-vision-dl/res/landmark_detection/models/fld_tweakcnn_128x128.json b/src/utc/capi-media-vision-dl/res/landmark_detection/models/fld_tweakcnn_128x128.json new file mode 100644 index 000000000..3ae252345 --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/landmark_detection/models/fld_tweakcnn_128x128.json @@ -0,0 +1,41 @@ +{ + "input": [ + { + "tensor1": { + "name": "Placeholder", + "shape_type": "NHWC", + "shape_dims": [ 1, 128, 128, 3 ], + "data_type": "FLOAT32", + "color_space": "RGB888", + "preprocess": { + "normalization": { + "mean": [ 0.0, 0.0, 0.0 ], + "std": [ 1.0, 1.0, 1.0 ] + } + } + } + } + ], + "output": [ + { + "tensor1": { + "name": "fanet8ss_inference/fully_connected_1/Sigmoid", + "postprocess": { + "score": { + "index": [ -1, -1, -1, -1 ], + "top_number": 1, + "threshold": 0.0, + "score_type": "NORMAL" + }, + "landmark": { + "index": [ -1, 1 ], + "landmark_type": "2D_SINGLE", + "landmark_coordinate": "RATIO", + "landmark_offset": 2, + "decoding_type": "BYPASS" + } + } + } + } + ] +} diff --git a/src/utc/capi-media-vision-dl/res/landmark_detection/models/fld_tweakcnn_128x128.tflite b/src/utc/capi-media-vision-dl/res/landmark_detection/models/fld_tweakcnn_128x128.tflite new file mode 100644 index 000000000..2449c5e67 Binary files /dev/null and b/src/utc/capi-media-vision-dl/res/landmark_detection/models/fld_tweakcnn_128x128.tflite differ diff --git a/src/utc/capi-media-vision-dl/res/landmark_detection/models/pld_cpm_192x192.json b/src/utc/capi-media-vision-dl/res/landmark_detection/models/pld_cpm_192x192.json new file mode 100644 index 000000000..a9e5d7607 --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/landmark_detection/models/pld_cpm_192x192.json @@ -0,0 +1,48 @@ +{ + "input": [ + { + "tensor1": { + "name": "image", + "shape_type": "NHWC", + "shape_dims": [ 1, 192, 192, 3 ], + "data_type": "FLOAT32", + "color_space": "RGB888", + "preprocess": { + "normalization": { + "mean": [ 0.0, 0.0, 0.0 ], + "std": [ 1.0, 1.0, 1.0 ] + } + } + } + } + ], + "output": [ + { + "tensor1": { + "name": "Convolutional_Pose_Machine/stage_5_out", + "shape_type": "NHWC", + "shape_dims": [ 1, 96, 96, 14 ], + "data_type": "FLOAT32", + "postprocess": { + "score": { + "index": [ -1, 1, 1, 1 ], + "top_number": 1, + "threshold": 0.3, + "score_type": "NORMAL" + }, + "landmark": { + "index": [ -1, 1, 1, 1 ], + "landmark_type": "2D_SINGLE", + "landmark_coordinate": "PIXEL", + "decoding_type": "HEATMAP", + "decoding_info": { + "heatmap": { + "shape_type": "NHWC" + } + } + } + } + } + } + ] +} diff --git a/src/utc/capi-media-vision-dl/res/landmark_detection/models/pld_cpm_192x192.tflite b/src/utc/capi-media-vision-dl/res/landmark_detection/models/pld_cpm_192x192.tflite new file mode 100644 index 000000000..ff6044d71 Binary files /dev/null and b/src/utc/capi-media-vision-dl/res/landmark_detection/models/pld_cpm_192x192.tflite differ diff --git a/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_300x300.json b/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_300x300.json new file mode 100644 index 000000000..40bf54fba --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_300x300.json @@ -0,0 +1,68 @@ +{ + "input": [ + { + "tensor1": { + "name": "normalized_input_image_tensor", + "shape_type": "NHWC", + "shape_dims": [ 1, 300, 300, 3 ], + "data_type": "FLOAT32", + "color_space": "RGB888", + "preprocess": { + "normalization": { + "mean": [ 127.5, 127.5, 127.5 ], + "std": [ 127.5, 127.5, 127.5 ] + } + } + } + } + ], + "output": [ + { + "tensor1": { + "name": "TFLite_Detection_PostProcess:2", + "postprocess": { + "score": { + "index": [ -1, 1 ], + "top_number": 5, + "threshold": 0.3, + "score_type": "NORMAL" + } + } + } + }, + { + "tensor2": { + "name": "TFLite_Detection_PostProcess", + "postprocess": { + "box": { + "index": [ -1, -1, 1 ], + "box_type": "ORIGIN_LEFTTOP", + "box_order": [ 1, 0, 3, 2 ], + "box_coordinate": "RATIO", + "decoding_type": "BYPASS" + } + } + } + }, + { + "tensor3": { + "name": "TFLite_Detection_PostProcess:1", + "postprocess": { + "label": { + "index": [ -1, 1 ] + } + } + } + }, + { + "tensor4": { + "name": "TFLite_Detection_PostProcess:3", + "postprocess": { + "number": { + "index": [ 1 ] + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_300x300.tflite b/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_300x300.tflite new file mode 100644 index 000000000..5425fcf66 Binary files /dev/null and b/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_300x300.tflite differ diff --git a/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_label.txt b/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_label.txt new file mode 100644 index 000000000..fd770b6d1 --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/object_detection/models/fd_mobilenet_v1_ssd_postop_label.txt @@ -0,0 +1 @@ +Face diff --git a/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_300x300.json b/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_300x300.json new file mode 100644 index 000000000..0d7837326 --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_300x300.json @@ -0,0 +1,69 @@ +{ + "input": [ + { + "tensor1": { + "name": "normalized_input_image_tensor", + "shape_type": "NHWC", + "shape_dims": [ 1, 300, 300, 3 ], + "data_type": "FLOAT32", + "color_space": "RGB888", + "preprocess": { + "normalization": { + "mean": [ 127.5, 127.5, 127.5 ], + "std": [ 127.5, 127.5, 127.5 ] + } + } + } + } + ], + + "output": [ + { + "tensor1": { + "name": "TFLite_Detection_PostProcess:2", + "postprocess": { + "score": { + "index": [ -1, 1 ], + "top_number": 5, + "threshold": 0.3, + "score_type": "NORMAL" + } + } + } + }, + { + "tensor2": { + "name": "TFLite_Detection_PostProcess", + "postprocess": { + "box": { + "index": [ -1, -1, 1 ], + "box_type": "ORIGIN_LEFTTOP", + "box_order": [ 1, 0, 3, 2 ], + "box_coordinate": "RATIO", + "decoding_type": "BYPASS" + } + } + } + }, + { + "tensor3": { + "name": "TFLite_Detection_PostProcess:1", + "postprocess": { + "label": { + "index": [ -1, 1 ] + } + } + } + }, + { + "tensor4": { + "name": "TFLite_Detection_PostProcess:3", + "postprocess": { + "number": { + "index": [ 1 ] + } + } + } + } + ] +} diff --git a/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_300x300.tflite b/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_300x300.tflite new file mode 100644 index 000000000..aee1d318e Binary files /dev/null and b/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_300x300.tflite differ diff --git a/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_label.txt b/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_label.txt new file mode 100644 index 000000000..0338a6168 --- /dev/null +++ b/src/utc/capi-media-vision-dl/res/object_detection/models/od_mobilenet_v1_ssd_postop_label.txt @@ -0,0 +1,72 @@ +Car +Wheel +Suit +Dog +Guitar +Bicycle +Sunglasses +Door +Jacket +Train +Desk +Drum +Book +Tie +Shorts +Shirt +Camera +Wine +Beer +Football +Castle +Bench +Coat +Tent +Bookcase +Doll +Umbrella +Computer_keyboard +Couch +Balloon +Fountain +Television +Necklace +Canoe +Scarf +Cowboy_hat +Mushroom +Traffic_light +Surfboard +Lamp +Ice_cream +Taxi +Boot +Frog +Dragonfly +Sandal +Strawberry +Pizza +Pillow +Snake +Rabbit +Baseball_bat +Lipstick +Apple +Tank +Parachute +Spoon +Tiger +Orange +Saxophone +Cosmetics +Cannon +Camel +Miniskirt +Crab +Jellyfish +Banana +Backpack +Whale +Sock +Lemon +Earrings diff --git a/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_mobile.h b/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_mobile.h index 7c1517dfa..e0f7bb503 100644 --- a/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_mobile.h +++ b/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_mobile.h @@ -93,6 +93,141 @@ extern int utc_mediavision_mv_face_recognition_unregister_p(void); extern int utc_mediavision_mv_face_recognition_unregister_n1(void); extern int utc_mediavision_mv_face_recognition_unregister_n2(void); +extern void utc_capi_mv_image_classification_startup1(void); +extern void utc_capi_mv_image_classification_cleanup1(void); +extern void utc_capi_mv_image_classification_startup2(void); +extern void utc_capi_mv_image_classification_cleanup2(void); +extern int utc_mediavision_mv_image_classification_create_p(void); +extern int utc_mediavision_mv_image_classification_create_n(void); +extern int utc_mediavision_mv_image_classification_destroy_p(void); +extern int utc_mediavision_mv_image_classification_destroy_n(void); +extern int utc_mediavision_mv_image_classification_configure_p(void); +extern int utc_mediavision_mv_image_classification_configure_n(void); +extern int utc_mediavision_mv_image_classification_prepare_p(void); +extern int utc_mediavision_mv_image_classification_prepare_n1(void); +extern int utc_mediavision_mv_image_classification_prepare_n2(void); +extern int utc_mediavision_mv_image_classification_inference_p(void); +extern int utc_mediavision_mv_image_classification_inference_n1(void); +extern int utc_mediavision_mv_image_classification_inference_n2(void); +extern int utc_mediavision_mv_image_classification_inference_async_p(void); +extern int utc_mediavision_mv_image_classification_inference_async_n1(void); +extern int utc_mediavision_mv_image_classification_inference_async_n2(void); +extern int utc_mediavision_mv_image_classification_get_result_count_p(void); +extern int utc_mediavision_mv_image_classification_get_result_count_n1(void); +extern int utc_mediavision_mv_image_classification_get_result_count_n2(void); +extern int utc_mediavision_mv_image_classification_get_label_p(void); +extern int utc_mediavision_mv_image_classification_get_label_n1(void); +extern int utc_mediavision_mv_image_classification_get_label_n2(void); +extern int utc_mediavision_mv_image_classification_get_label_n3(void); + +extern void utc_capi_mv_object_detection_startup1(void); +extern void utc_capi_mv_object_detection_cleanup1(void); +extern void utc_capi_mv_object_detection_startup2(void); +extern void utc_capi_mv_object_detection_cleanup2(void); +extern int utc_mediavision_mv_object_detection_create_p(void); +extern int utc_mediavision_mv_object_detection_create_n(void); +extern int utc_mediavision_mv_object_detection_destroy_p(void); +extern int utc_mediavision_mv_object_detection_destroy_n(void); +extern int utc_mediavision_mv_object_detection_configure_p(void); +extern int utc_mediavision_mv_object_detection_configure_n(void); +extern int utc_mediavision_mv_object_detection_prepare_p(void); +extern int utc_mediavision_mv_object_detection_prepare_n1(void); +extern int utc_mediavision_mv_object_detection_prepare_n2(void); +extern int utc_mediavision_mv_object_detection_inference_p(void); +extern int utc_mediavision_mv_object_detection_inference_n1(void); +extern int utc_mediavision_mv_object_detection_inference_n2(void); +extern int utc_mediavision_mv_object_detection_inference_async_p(void); +extern int utc_mediavision_mv_object_detection_inference_async_n1(void); +extern int utc_mediavision_mv_object_detection_inference_async_n2(void); +extern int utc_mediavision_mv_object_detection_get_result_count_p(void); +extern int utc_mediavision_mv_object_detection_get_result_count_n1(void); +extern int utc_mediavision_mv_object_detection_get_result_count_n2(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_p(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_n1(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_n2(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_n3(void); + +extern void utc_capi_mv_face_detection_startup1(void); +extern void utc_capi_mv_face_detection_cleanup1(void); +extern void utc_capi_mv_face_detection_startup2(void); +extern void utc_capi_mv_face_detection_cleanup2(void); +extern int utc_mediavision_mv_face_detection_create_p(void); +extern int utc_mediavision_mv_face_detection_create_n(void); +extern int utc_mediavision_mv_face_detection_destroy_p(void); +extern int utc_mediavision_mv_face_detection_destroy_n(void); +extern int utc_mediavision_mv_face_detection_configure_p(void); +extern int utc_mediavision_mv_face_detection_configure_n(void); +extern int utc_mediavision_mv_face_detection_prepare_p(void); +extern int utc_mediavision_mv_face_detection_prepare_n1(void); +extern int utc_mediavision_mv_face_detection_prepare_n2(void); +extern int utc_mediavision_mv_face_detection_inference_p(void); +extern int utc_mediavision_mv_face_detection_inference_n1(void); +extern int utc_mediavision_mv_face_detection_inference_n2(void); +extern int utc_mediavision_mv_face_detection_inference_async_p(void); +extern int utc_mediavision_mv_face_detection_inference_async_n1(void); +extern int utc_mediavision_mv_face_detection_inference_async_n2(void); +extern int utc_mediavision_mv_face_detection_get_result_count_p(void); +extern int utc_mediavision_mv_face_detection_get_result_count_n1(void); +extern int utc_mediavision_mv_face_detection_get_result_count_n2(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_p(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_n1(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_n2(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_n3(void); + +extern void utc_capi_mv_facial_landmark_startup1(void); +extern void utc_capi_mv_facial_landmark_cleanup1(void); +extern void utc_capi_mv_facial_landmark_startup2(void); +extern void utc_capi_mv_facial_landmark_cleanup2(void); +extern int utc_mediavision_mv_facial_landmark_create_p(void); +extern int utc_mediavision_mv_facial_landmark_create_n(void); +extern int utc_mediavision_mv_facial_landmark_destroy_p(void); +extern int utc_mediavision_mv_facial_landmark_destroy_n(void); +extern int utc_mediavision_mv_facial_landmark_configure_p(void); +extern int utc_mediavision_mv_facial_landmark_configure_n(void); +extern int utc_mediavision_mv_facial_landmark_prepare_p(void); +extern int utc_mediavision_mv_facial_landmark_prepare_n1(void); +extern int utc_mediavision_mv_facial_landmark_prepare_n2(void); +extern int utc_mediavision_mv_facial_landmark_inference_p(void); +extern int utc_mediavision_mv_facial_landmark_inference_n1(void); +extern int utc_mediavision_mv_facial_landmark_inference_n2(void); +extern int utc_mediavision_mv_facial_landmark_inference_async_p(void); +extern int utc_mediavision_mv_facial_landmark_inference_async_n1(void); +extern int utc_mediavision_mv_facial_landmark_inference_async_n2(void); +extern int utc_mediavision_mv_facial_landmark_get_result_count_p(void); +extern int utc_mediavision_mv_facial_landmark_get_result_count_n1(void); +extern int utc_mediavision_mv_facial_landmark_get_result_count_n2(void); +extern int utc_mediavision_mv_facial_landmark_get_position_p(void); +extern int utc_mediavision_mv_facial_landmark_get_position_n1(void); +extern int utc_mediavision_mv_facial_landmark_get_position_n2(void); +extern int utc_mediavision_mv_facial_landmark_get_position_n3(void); + +extern void utc_capi_mv_pose_landmark_startup1(void); +extern void utc_capi_mv_pose_landmark_cleanup1(void); +extern void utc_capi_mv_pose_landmark_startup2(void); +extern void utc_capi_mv_pose_landmark_cleanup2(void); +extern int utc_mediavision_mv_pose_landmark_create_p(void); +extern int utc_mediavision_mv_pose_landmark_create_n(void); +extern int utc_mediavision_mv_pose_landmark_destroy_p(void); +extern int utc_mediavision_mv_pose_landmark_destroy_n(void); +extern int utc_mediavision_mv_pose_landmark_configure_p(void); +extern int utc_mediavision_mv_pose_landmark_configure_n(void); +extern int utc_mediavision_mv_pose_landmark_prepare_p(void); +extern int utc_mediavision_mv_pose_landmark_prepare_n1(void); +extern int utc_mediavision_mv_pose_landmark_prepare_n2(void); +extern int utc_mediavision_mv_pose_landmark_inference_p(void); +extern int utc_mediavision_mv_pose_landmark_inference_n1(void); +extern int utc_mediavision_mv_pose_landmark_inference_n2(void); +extern int utc_mediavision_mv_pose_landmark_inference_async_p(void); +extern int utc_mediavision_mv_pose_landmark_inference_async_n1(void); +extern int utc_mediavision_mv_pose_landmark_inference_async_n2(void); +extern int utc_mediavision_mv_pose_landmark_get_result_count_p(void); +extern int utc_mediavision_mv_pose_landmark_get_result_count_n1(void); +extern int utc_mediavision_mv_pose_landmark_get_result_count_n2(void); +extern int utc_mediavision_mv_pose_landmark_get_position_p(void); +extern int utc_mediavision_mv_pose_landmark_get_position_n1(void); +extern int utc_mediavision_mv_pose_landmark_get_position_n2(void); +extern int utc_mediavision_mv_pose_landmark_get_position_n3(void); + testcase tc_array[] = { { "utc_mediavision_mv_inference_foreach_supported_engine", utc_mediavision_mv_inference_foreach_supported_engine, utc_capi_media_vision_inference_startup2, utc_capi_media_vision_inference_cleanup2 }, @@ -216,6 +351,234 @@ testcase tc_array[] = { utc_capi_media_vision_face_recognition_startup, utc_capi_media_vision_face_recognition_cleanup }, { "utc_mediavision_mv_face_recognition_unregister_n2", utc_mediavision_mv_face_recognition_unregister_n2, utc_capi_media_vision_face_recognition_startup, utc_capi_media_vision_face_recognition_cleanup }, + { "utc_mediavision_mv_image_classification_create_p", utc_mediavision_mv_image_classification_create_p, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_create_n", utc_mediavision_mv_image_classification_create_n, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_destroy_p", utc_mediavision_mv_image_classification_destroy_p, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_destroy_n", utc_mediavision_mv_image_classification_destroy_n, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_configure_p", utc_mediavision_mv_image_classification_configure_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_configure_n", utc_mediavision_mv_image_classification_configure_n, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_prepare_p", utc_mediavision_mv_image_classification_prepare_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_prepare_n1", utc_mediavision_mv_image_classification_prepare_n1, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_prepare_n2", utc_mediavision_mv_image_classification_prepare_n2, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_p", utc_mediavision_mv_image_classification_inference_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_n1", utc_mediavision_mv_image_classification_inference_n1, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_n2", utc_mediavision_mv_image_classification_inference_n2, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_async_p", + utc_mediavision_mv_image_classification_inference_async_p, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_async_n1", + utc_mediavision_mv_image_classification_inference_async_n1, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_async_n2", + utc_mediavision_mv_image_classification_inference_async_n2, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_result_count_p", + utc_mediavision_mv_image_classification_get_result_count_p, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_result_count_n1", + utc_mediavision_mv_image_classification_get_result_count_n1, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_result_count_n2", + utc_mediavision_mv_image_classification_get_result_count_n2, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_p", utc_mediavision_mv_image_classification_get_label_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_n1", utc_mediavision_mv_image_classification_get_label_n1, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_n2", utc_mediavision_mv_image_classification_get_label_n2, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_n3", utc_mediavision_mv_image_classification_get_label_n3, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_object_detection_create_p", utc_mediavision_mv_object_detection_create_p, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_create_n", utc_mediavision_mv_object_detection_create_n, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_destroy_p", utc_mediavision_mv_object_detection_destroy_p, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_destroy_n", utc_mediavision_mv_object_detection_destroy_n, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_configure_p", utc_mediavision_mv_object_detection_configure_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_configure_n", utc_mediavision_mv_object_detection_configure_n, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_prepare_p", utc_mediavision_mv_object_detection_prepare_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_prepare_n1", utc_mediavision_mv_object_detection_prepare_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_prepare_n2", utc_mediavision_mv_object_detection_prepare_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_p", utc_mediavision_mv_object_detection_inference_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_n1", utc_mediavision_mv_object_detection_inference_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_n2", utc_mediavision_mv_object_detection_inference_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_async_p", utc_mediavision_mv_object_detection_inference_async_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_async_n1", utc_mediavision_mv_object_detection_inference_async_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_async_n2", utc_mediavision_mv_object_detection_inference_async_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_result_count_p", utc_mediavision_mv_object_detection_get_result_count_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_result_count_n1", + utc_mediavision_mv_object_detection_get_result_count_n1, utc_capi_mv_object_detection_startup2, + utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_result_count_n2", + utc_mediavision_mv_object_detection_get_result_count_n2, utc_capi_mv_object_detection_startup2, + utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_p", utc_mediavision_mv_object_detection_get_bound_box_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_n1", utc_mediavision_mv_object_detection_get_bound_box_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_n2", utc_mediavision_mv_object_detection_get_bound_box_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_n3", utc_mediavision_mv_object_detection_get_bound_box_n3, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_create_p", utc_mediavision_mv_face_detection_create_p, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_create_n", utc_mediavision_mv_face_detection_create_n, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_destroy_p", utc_mediavision_mv_face_detection_destroy_p, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_destroy_n", utc_mediavision_mv_face_detection_destroy_n, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_configure_p", utc_mediavision_mv_face_detection_configure_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_configure_n", utc_mediavision_mv_face_detection_configure_n, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_prepare_p", utc_mediavision_mv_face_detection_prepare_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_prepare_n1", utc_mediavision_mv_face_detection_prepare_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_prepare_n2", utc_mediavision_mv_face_detection_prepare_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_p", utc_mediavision_mv_face_detection_inference_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_n1", utc_mediavision_mv_face_detection_inference_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_n2", utc_mediavision_mv_face_detection_inference_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_async_p", utc_mediavision_mv_face_detection_inference_async_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_async_n1", utc_mediavision_mv_face_detection_inference_async_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_async_n2", utc_mediavision_mv_face_detection_inference_async_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_result_count_p", utc_mediavision_mv_face_detection_get_result_count_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_result_count_n1", utc_mediavision_mv_face_detection_get_result_count_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_result_count_n2", utc_mediavision_mv_face_detection_get_result_count_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_p", utc_mediavision_mv_face_detection_get_bound_box_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_n1", utc_mediavision_mv_face_detection_get_bound_box_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_n2", utc_mediavision_mv_face_detection_get_bound_box_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_n3", utc_mediavision_mv_face_detection_get_bound_box_n3, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_create_p", utc_mediavision_mv_facial_landmark_create_p, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_create_n", utc_mediavision_mv_facial_landmark_create_n, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_destroy_p", utc_mediavision_mv_facial_landmark_destroy_p, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_destroy_n", utc_mediavision_mv_facial_landmark_destroy_n, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_configure_p", utc_mediavision_mv_facial_landmark_configure_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_configure_n", utc_mediavision_mv_facial_landmark_configure_n, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_prepare_p", utc_mediavision_mv_facial_landmark_prepare_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_prepare_n1", utc_mediavision_mv_facial_landmark_prepare_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_prepare_n2", utc_mediavision_mv_facial_landmark_prepare_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_p", utc_mediavision_mv_facial_landmark_inference_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_n1", utc_mediavision_mv_facial_landmark_inference_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_n2", utc_mediavision_mv_facial_landmark_inference_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_async_p", utc_mediavision_mv_facial_landmark_inference_async_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_async_n1", utc_mediavision_mv_facial_landmark_inference_async_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_async_n2", utc_mediavision_mv_facial_landmark_inference_async_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_result_count_p", utc_mediavision_mv_facial_landmark_get_result_count_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_result_count_n1", utc_mediavision_mv_facial_landmark_get_result_count_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_result_count_n2", utc_mediavision_mv_facial_landmark_get_result_count_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_p", utc_mediavision_mv_facial_landmark_get_position_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_n1", utc_mediavision_mv_facial_landmark_get_position_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_n2", utc_mediavision_mv_facial_landmark_get_position_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_n3", utc_mediavision_mv_facial_landmark_get_position_n3, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_create_p", utc_mediavision_mv_pose_landmark_create_p, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_create_n", utc_mediavision_mv_pose_landmark_create_n, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_destroy_p", utc_mediavision_mv_pose_landmark_destroy_p, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_destroy_n", utc_mediavision_mv_pose_landmark_destroy_n, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_configure_p", utc_mediavision_mv_pose_landmark_configure_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_configure_n", utc_mediavision_mv_pose_landmark_configure_n, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_prepare_p", utc_mediavision_mv_pose_landmark_prepare_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_prepare_n1", utc_mediavision_mv_pose_landmark_prepare_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_prepare_n2", utc_mediavision_mv_pose_landmark_prepare_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_p", utc_mediavision_mv_pose_landmark_inference_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_n1", utc_mediavision_mv_pose_landmark_inference_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_n2", utc_mediavision_mv_pose_landmark_inference_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_async_p", utc_mediavision_mv_pose_landmark_inference_async_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_async_n1", utc_mediavision_mv_pose_landmark_inference_async_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_async_n2", utc_mediavision_mv_pose_landmark_inference_async_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_result_count_p", utc_mediavision_mv_pose_landmark_get_result_count_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_result_count_n1", utc_mediavision_mv_pose_landmark_get_result_count_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_result_count_n2", utc_mediavision_mv_pose_landmark_get_result_count_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_p", utc_mediavision_mv_pose_landmark_get_position_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_n1", utc_mediavision_mv_pose_landmark_get_position_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_n2", utc_mediavision_mv_pose_landmark_get_position_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_n3", utc_mediavision_mv_pose_landmark_get_position_n3, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, { NULL, NULL } }; diff --git a/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_tizeniot.h b/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_tizeniot.h index 7c1517dfa..e0f7bb503 100644 --- a/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_tizeniot.h +++ b/src/utc/capi-media-vision-dl/tct-capi-media-vision-dl-core_tizeniot.h @@ -93,6 +93,141 @@ extern int utc_mediavision_mv_face_recognition_unregister_p(void); extern int utc_mediavision_mv_face_recognition_unregister_n1(void); extern int utc_mediavision_mv_face_recognition_unregister_n2(void); +extern void utc_capi_mv_image_classification_startup1(void); +extern void utc_capi_mv_image_classification_cleanup1(void); +extern void utc_capi_mv_image_classification_startup2(void); +extern void utc_capi_mv_image_classification_cleanup2(void); +extern int utc_mediavision_mv_image_classification_create_p(void); +extern int utc_mediavision_mv_image_classification_create_n(void); +extern int utc_mediavision_mv_image_classification_destroy_p(void); +extern int utc_mediavision_mv_image_classification_destroy_n(void); +extern int utc_mediavision_mv_image_classification_configure_p(void); +extern int utc_mediavision_mv_image_classification_configure_n(void); +extern int utc_mediavision_mv_image_classification_prepare_p(void); +extern int utc_mediavision_mv_image_classification_prepare_n1(void); +extern int utc_mediavision_mv_image_classification_prepare_n2(void); +extern int utc_mediavision_mv_image_classification_inference_p(void); +extern int utc_mediavision_mv_image_classification_inference_n1(void); +extern int utc_mediavision_mv_image_classification_inference_n2(void); +extern int utc_mediavision_mv_image_classification_inference_async_p(void); +extern int utc_mediavision_mv_image_classification_inference_async_n1(void); +extern int utc_mediavision_mv_image_classification_inference_async_n2(void); +extern int utc_mediavision_mv_image_classification_get_result_count_p(void); +extern int utc_mediavision_mv_image_classification_get_result_count_n1(void); +extern int utc_mediavision_mv_image_classification_get_result_count_n2(void); +extern int utc_mediavision_mv_image_classification_get_label_p(void); +extern int utc_mediavision_mv_image_classification_get_label_n1(void); +extern int utc_mediavision_mv_image_classification_get_label_n2(void); +extern int utc_mediavision_mv_image_classification_get_label_n3(void); + +extern void utc_capi_mv_object_detection_startup1(void); +extern void utc_capi_mv_object_detection_cleanup1(void); +extern void utc_capi_mv_object_detection_startup2(void); +extern void utc_capi_mv_object_detection_cleanup2(void); +extern int utc_mediavision_mv_object_detection_create_p(void); +extern int utc_mediavision_mv_object_detection_create_n(void); +extern int utc_mediavision_mv_object_detection_destroy_p(void); +extern int utc_mediavision_mv_object_detection_destroy_n(void); +extern int utc_mediavision_mv_object_detection_configure_p(void); +extern int utc_mediavision_mv_object_detection_configure_n(void); +extern int utc_mediavision_mv_object_detection_prepare_p(void); +extern int utc_mediavision_mv_object_detection_prepare_n1(void); +extern int utc_mediavision_mv_object_detection_prepare_n2(void); +extern int utc_mediavision_mv_object_detection_inference_p(void); +extern int utc_mediavision_mv_object_detection_inference_n1(void); +extern int utc_mediavision_mv_object_detection_inference_n2(void); +extern int utc_mediavision_mv_object_detection_inference_async_p(void); +extern int utc_mediavision_mv_object_detection_inference_async_n1(void); +extern int utc_mediavision_mv_object_detection_inference_async_n2(void); +extern int utc_mediavision_mv_object_detection_get_result_count_p(void); +extern int utc_mediavision_mv_object_detection_get_result_count_n1(void); +extern int utc_mediavision_mv_object_detection_get_result_count_n2(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_p(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_n1(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_n2(void); +extern int utc_mediavision_mv_object_detection_get_bound_box_n3(void); + +extern void utc_capi_mv_face_detection_startup1(void); +extern void utc_capi_mv_face_detection_cleanup1(void); +extern void utc_capi_mv_face_detection_startup2(void); +extern void utc_capi_mv_face_detection_cleanup2(void); +extern int utc_mediavision_mv_face_detection_create_p(void); +extern int utc_mediavision_mv_face_detection_create_n(void); +extern int utc_mediavision_mv_face_detection_destroy_p(void); +extern int utc_mediavision_mv_face_detection_destroy_n(void); +extern int utc_mediavision_mv_face_detection_configure_p(void); +extern int utc_mediavision_mv_face_detection_configure_n(void); +extern int utc_mediavision_mv_face_detection_prepare_p(void); +extern int utc_mediavision_mv_face_detection_prepare_n1(void); +extern int utc_mediavision_mv_face_detection_prepare_n2(void); +extern int utc_mediavision_mv_face_detection_inference_p(void); +extern int utc_mediavision_mv_face_detection_inference_n1(void); +extern int utc_mediavision_mv_face_detection_inference_n2(void); +extern int utc_mediavision_mv_face_detection_inference_async_p(void); +extern int utc_mediavision_mv_face_detection_inference_async_n1(void); +extern int utc_mediavision_mv_face_detection_inference_async_n2(void); +extern int utc_mediavision_mv_face_detection_get_result_count_p(void); +extern int utc_mediavision_mv_face_detection_get_result_count_n1(void); +extern int utc_mediavision_mv_face_detection_get_result_count_n2(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_p(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_n1(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_n2(void); +extern int utc_mediavision_mv_face_detection_get_bound_box_n3(void); + +extern void utc_capi_mv_facial_landmark_startup1(void); +extern void utc_capi_mv_facial_landmark_cleanup1(void); +extern void utc_capi_mv_facial_landmark_startup2(void); +extern void utc_capi_mv_facial_landmark_cleanup2(void); +extern int utc_mediavision_mv_facial_landmark_create_p(void); +extern int utc_mediavision_mv_facial_landmark_create_n(void); +extern int utc_mediavision_mv_facial_landmark_destroy_p(void); +extern int utc_mediavision_mv_facial_landmark_destroy_n(void); +extern int utc_mediavision_mv_facial_landmark_configure_p(void); +extern int utc_mediavision_mv_facial_landmark_configure_n(void); +extern int utc_mediavision_mv_facial_landmark_prepare_p(void); +extern int utc_mediavision_mv_facial_landmark_prepare_n1(void); +extern int utc_mediavision_mv_facial_landmark_prepare_n2(void); +extern int utc_mediavision_mv_facial_landmark_inference_p(void); +extern int utc_mediavision_mv_facial_landmark_inference_n1(void); +extern int utc_mediavision_mv_facial_landmark_inference_n2(void); +extern int utc_mediavision_mv_facial_landmark_inference_async_p(void); +extern int utc_mediavision_mv_facial_landmark_inference_async_n1(void); +extern int utc_mediavision_mv_facial_landmark_inference_async_n2(void); +extern int utc_mediavision_mv_facial_landmark_get_result_count_p(void); +extern int utc_mediavision_mv_facial_landmark_get_result_count_n1(void); +extern int utc_mediavision_mv_facial_landmark_get_result_count_n2(void); +extern int utc_mediavision_mv_facial_landmark_get_position_p(void); +extern int utc_mediavision_mv_facial_landmark_get_position_n1(void); +extern int utc_mediavision_mv_facial_landmark_get_position_n2(void); +extern int utc_mediavision_mv_facial_landmark_get_position_n3(void); + +extern void utc_capi_mv_pose_landmark_startup1(void); +extern void utc_capi_mv_pose_landmark_cleanup1(void); +extern void utc_capi_mv_pose_landmark_startup2(void); +extern void utc_capi_mv_pose_landmark_cleanup2(void); +extern int utc_mediavision_mv_pose_landmark_create_p(void); +extern int utc_mediavision_mv_pose_landmark_create_n(void); +extern int utc_mediavision_mv_pose_landmark_destroy_p(void); +extern int utc_mediavision_mv_pose_landmark_destroy_n(void); +extern int utc_mediavision_mv_pose_landmark_configure_p(void); +extern int utc_mediavision_mv_pose_landmark_configure_n(void); +extern int utc_mediavision_mv_pose_landmark_prepare_p(void); +extern int utc_mediavision_mv_pose_landmark_prepare_n1(void); +extern int utc_mediavision_mv_pose_landmark_prepare_n2(void); +extern int utc_mediavision_mv_pose_landmark_inference_p(void); +extern int utc_mediavision_mv_pose_landmark_inference_n1(void); +extern int utc_mediavision_mv_pose_landmark_inference_n2(void); +extern int utc_mediavision_mv_pose_landmark_inference_async_p(void); +extern int utc_mediavision_mv_pose_landmark_inference_async_n1(void); +extern int utc_mediavision_mv_pose_landmark_inference_async_n2(void); +extern int utc_mediavision_mv_pose_landmark_get_result_count_p(void); +extern int utc_mediavision_mv_pose_landmark_get_result_count_n1(void); +extern int utc_mediavision_mv_pose_landmark_get_result_count_n2(void); +extern int utc_mediavision_mv_pose_landmark_get_position_p(void); +extern int utc_mediavision_mv_pose_landmark_get_position_n1(void); +extern int utc_mediavision_mv_pose_landmark_get_position_n2(void); +extern int utc_mediavision_mv_pose_landmark_get_position_n3(void); + testcase tc_array[] = { { "utc_mediavision_mv_inference_foreach_supported_engine", utc_mediavision_mv_inference_foreach_supported_engine, utc_capi_media_vision_inference_startup2, utc_capi_media_vision_inference_cleanup2 }, @@ -216,6 +351,234 @@ testcase tc_array[] = { utc_capi_media_vision_face_recognition_startup, utc_capi_media_vision_face_recognition_cleanup }, { "utc_mediavision_mv_face_recognition_unregister_n2", utc_mediavision_mv_face_recognition_unregister_n2, utc_capi_media_vision_face_recognition_startup, utc_capi_media_vision_face_recognition_cleanup }, + { "utc_mediavision_mv_image_classification_create_p", utc_mediavision_mv_image_classification_create_p, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_create_n", utc_mediavision_mv_image_classification_create_n, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_destroy_p", utc_mediavision_mv_image_classification_destroy_p, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_destroy_n", utc_mediavision_mv_image_classification_destroy_n, + utc_capi_mv_image_classification_startup1, utc_capi_mv_image_classification_cleanup1 }, + { "utc_mediavision_mv_image_classification_configure_p", utc_mediavision_mv_image_classification_configure_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_configure_n", utc_mediavision_mv_image_classification_configure_n, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_prepare_p", utc_mediavision_mv_image_classification_prepare_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_prepare_n1", utc_mediavision_mv_image_classification_prepare_n1, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_prepare_n2", utc_mediavision_mv_image_classification_prepare_n2, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_p", utc_mediavision_mv_image_classification_inference_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_n1", utc_mediavision_mv_image_classification_inference_n1, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_n2", utc_mediavision_mv_image_classification_inference_n2, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_async_p", + utc_mediavision_mv_image_classification_inference_async_p, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_async_n1", + utc_mediavision_mv_image_classification_inference_async_n1, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_inference_async_n2", + utc_mediavision_mv_image_classification_inference_async_n2, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_result_count_p", + utc_mediavision_mv_image_classification_get_result_count_p, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_result_count_n1", + utc_mediavision_mv_image_classification_get_result_count_n1, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_result_count_n2", + utc_mediavision_mv_image_classification_get_result_count_n2, utc_capi_mv_image_classification_startup2, + utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_p", utc_mediavision_mv_image_classification_get_label_p, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_n1", utc_mediavision_mv_image_classification_get_label_n1, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_n2", utc_mediavision_mv_image_classification_get_label_n2, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_image_classification_get_label_n3", utc_mediavision_mv_image_classification_get_label_n3, + utc_capi_mv_image_classification_startup2, utc_capi_mv_image_classification_cleanup2 }, + { "utc_mediavision_mv_object_detection_create_p", utc_mediavision_mv_object_detection_create_p, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_create_n", utc_mediavision_mv_object_detection_create_n, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_destroy_p", utc_mediavision_mv_object_detection_destroy_p, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_destroy_n", utc_mediavision_mv_object_detection_destroy_n, + utc_capi_mv_object_detection_startup1, utc_capi_mv_object_detection_cleanup1 }, + { "utc_mediavision_mv_object_detection_configure_p", utc_mediavision_mv_object_detection_configure_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_configure_n", utc_mediavision_mv_object_detection_configure_n, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_prepare_p", utc_mediavision_mv_object_detection_prepare_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_prepare_n1", utc_mediavision_mv_object_detection_prepare_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_prepare_n2", utc_mediavision_mv_object_detection_prepare_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_p", utc_mediavision_mv_object_detection_inference_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_n1", utc_mediavision_mv_object_detection_inference_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_n2", utc_mediavision_mv_object_detection_inference_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_async_p", utc_mediavision_mv_object_detection_inference_async_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_async_n1", utc_mediavision_mv_object_detection_inference_async_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_inference_async_n2", utc_mediavision_mv_object_detection_inference_async_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_result_count_p", utc_mediavision_mv_object_detection_get_result_count_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_result_count_n1", + utc_mediavision_mv_object_detection_get_result_count_n1, utc_capi_mv_object_detection_startup2, + utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_result_count_n2", + utc_mediavision_mv_object_detection_get_result_count_n2, utc_capi_mv_object_detection_startup2, + utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_p", utc_mediavision_mv_object_detection_get_bound_box_p, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_n1", utc_mediavision_mv_object_detection_get_bound_box_n1, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_n2", utc_mediavision_mv_object_detection_get_bound_box_n2, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_object_detection_get_bound_box_n3", utc_mediavision_mv_object_detection_get_bound_box_n3, + utc_capi_mv_object_detection_startup2, utc_capi_mv_object_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_create_p", utc_mediavision_mv_face_detection_create_p, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_create_n", utc_mediavision_mv_face_detection_create_n, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_destroy_p", utc_mediavision_mv_face_detection_destroy_p, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_destroy_n", utc_mediavision_mv_face_detection_destroy_n, + utc_capi_mv_face_detection_startup1, utc_capi_mv_face_detection_cleanup1 }, + { "utc_mediavision_mv_face_detection_configure_p", utc_mediavision_mv_face_detection_configure_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_configure_n", utc_mediavision_mv_face_detection_configure_n, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_prepare_p", utc_mediavision_mv_face_detection_prepare_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_prepare_n1", utc_mediavision_mv_face_detection_prepare_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_prepare_n2", utc_mediavision_mv_face_detection_prepare_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_p", utc_mediavision_mv_face_detection_inference_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_n1", utc_mediavision_mv_face_detection_inference_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_n2", utc_mediavision_mv_face_detection_inference_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_async_p", utc_mediavision_mv_face_detection_inference_async_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_async_n1", utc_mediavision_mv_face_detection_inference_async_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_inference_async_n2", utc_mediavision_mv_face_detection_inference_async_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_result_count_p", utc_mediavision_mv_face_detection_get_result_count_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_result_count_n1", utc_mediavision_mv_face_detection_get_result_count_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_result_count_n2", utc_mediavision_mv_face_detection_get_result_count_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_p", utc_mediavision_mv_face_detection_get_bound_box_p, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_n1", utc_mediavision_mv_face_detection_get_bound_box_n1, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_n2", utc_mediavision_mv_face_detection_get_bound_box_n2, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_face_detection_get_bound_box_n3", utc_mediavision_mv_face_detection_get_bound_box_n3, + utc_capi_mv_face_detection_startup2, utc_capi_mv_face_detection_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_create_p", utc_mediavision_mv_facial_landmark_create_p, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_create_n", utc_mediavision_mv_facial_landmark_create_n, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_destroy_p", utc_mediavision_mv_facial_landmark_destroy_p, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_destroy_n", utc_mediavision_mv_facial_landmark_destroy_n, + utc_capi_mv_facial_landmark_startup1, utc_capi_mv_facial_landmark_cleanup1 }, + { "utc_mediavision_mv_facial_landmark_configure_p", utc_mediavision_mv_facial_landmark_configure_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_configure_n", utc_mediavision_mv_facial_landmark_configure_n, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_prepare_p", utc_mediavision_mv_facial_landmark_prepare_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_prepare_n1", utc_mediavision_mv_facial_landmark_prepare_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_prepare_n2", utc_mediavision_mv_facial_landmark_prepare_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_p", utc_mediavision_mv_facial_landmark_inference_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_n1", utc_mediavision_mv_facial_landmark_inference_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_n2", utc_mediavision_mv_facial_landmark_inference_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_async_p", utc_mediavision_mv_facial_landmark_inference_async_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_async_n1", utc_mediavision_mv_facial_landmark_inference_async_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_inference_async_n2", utc_mediavision_mv_facial_landmark_inference_async_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_result_count_p", utc_mediavision_mv_facial_landmark_get_result_count_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_result_count_n1", utc_mediavision_mv_facial_landmark_get_result_count_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_result_count_n2", utc_mediavision_mv_facial_landmark_get_result_count_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_p", utc_mediavision_mv_facial_landmark_get_position_p, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_n1", utc_mediavision_mv_facial_landmark_get_position_n1, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_n2", utc_mediavision_mv_facial_landmark_get_position_n2, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_facial_landmark_get_position_n3", utc_mediavision_mv_facial_landmark_get_position_n3, + utc_capi_mv_facial_landmark_startup2, utc_capi_mv_facial_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_create_p", utc_mediavision_mv_pose_landmark_create_p, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_create_n", utc_mediavision_mv_pose_landmark_create_n, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_destroy_p", utc_mediavision_mv_pose_landmark_destroy_p, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_destroy_n", utc_mediavision_mv_pose_landmark_destroy_n, + utc_capi_mv_pose_landmark_startup1, utc_capi_mv_pose_landmark_cleanup1 }, + { "utc_mediavision_mv_pose_landmark_configure_p", utc_mediavision_mv_pose_landmark_configure_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_configure_n", utc_mediavision_mv_pose_landmark_configure_n, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_prepare_p", utc_mediavision_mv_pose_landmark_prepare_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_prepare_n1", utc_mediavision_mv_pose_landmark_prepare_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_prepare_n2", utc_mediavision_mv_pose_landmark_prepare_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_p", utc_mediavision_mv_pose_landmark_inference_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_n1", utc_mediavision_mv_pose_landmark_inference_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_n2", utc_mediavision_mv_pose_landmark_inference_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_async_p", utc_mediavision_mv_pose_landmark_inference_async_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_async_n1", utc_mediavision_mv_pose_landmark_inference_async_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_inference_async_n2", utc_mediavision_mv_pose_landmark_inference_async_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_result_count_p", utc_mediavision_mv_pose_landmark_get_result_count_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_result_count_n1", utc_mediavision_mv_pose_landmark_get_result_count_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_result_count_n2", utc_mediavision_mv_pose_landmark_get_result_count_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_p", utc_mediavision_mv_pose_landmark_get_position_p, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_n1", utc_mediavision_mv_pose_landmark_get_position_n1, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_n2", utc_mediavision_mv_pose_landmark_get_position_n2, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, + { "utc_mediavision_mv_pose_landmark_get_position_n3", utc_mediavision_mv_pose_landmark_get_position_n3, + utc_capi_mv_pose_landmark_startup2, utc_capi_mv_pose_landmark_cleanup2 }, { NULL, NULL } }; diff --git a/src/utc/capi-media-vision-dl/utc-mv_face_detection.c b/src/utc/capi-media-vision-dl/utc-mv_face_detection.c new file mode 100644 index 000000000..abd21a211 --- /dev/null +++ b/src/utc/capi-media-vision-dl/utc-mv_face_detection.c @@ -0,0 +1,979 @@ +/** + * 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 "assert.h" +#include + +#include +#include +#include +#include +#include + +#include "tct_common.h" +#include +#include +#include + +#define FILE_PATH_SIZE 1024 +#define MAX_INFERENCE_ITERATION 50 +#define API_NAMESPACE "[MediaVision]" +#define IMG_NAME "faceDetection.jpg" + +static bool isVisionSupported = false; +static int gStartupError; + +static mv_face_detection_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +static void *face_detection_callback(void *user_data) +{ + mv_face_detection_h handle = (mv_face_detection_h) user_data; + const int coordinate_answers[2][4] = { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int ret = mv_face_detection_get_result_count(handle, &frame_number, &cnt); + if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + for (unsigned long idx = 0; idx < cnt; ++idx) { + int 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); + assert_eq(coordinate_answers[idx][1], top); + assert_eq(coordinate_answers[idx][2], right); + assert_eq(coordinate_answers[idx][3], bottom); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } + return 0; +} + +static int load_image_to_media_source(const char *file_path, mv_source_h source) +{ + if (NULL == file_path || NULL == source) { + printf("File path or source is NULL\n"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + + unsigned int width = 0; + unsigned int height = 0; + size_t buffer_size = 0; + unsigned char *data_buffer = NULL; + int ret1 = IMAGE_UTIL_ERROR_NONE; + int ret2 = MEDIA_VISION_ERROR_NONE; + image_util_decode_h _decoder = NULL; + image_util_image_h _decoded_image = NULL; + + ret1 = image_util_decode_create(&_decoder); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_input_path(_decoder, file_path); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_run2(_decoder, &_decoded_image); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_get_image(_decoded_image, &width, &height, NULL, &data_buffer, &buffer_size); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_clear(source); + if (ret2 != MEDIA_VISION_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width, + (unsigned int) height, MEDIA_VISION_COLORSPACE_RGB888); + +_LOAD_IMAGE_FAIL: + image_util_decode_destroy(_decoder); + image_util_destroy_image(_decoded_image); + if (data_buffer) + free(data_buffer); + + assert_eq(IMAGE_UTIL_ERROR_NONE, ret1); + assert_eq(MEDIA_VISION_ERROR_NONE, ret2); + + return MEDIA_VISION_ERROR_NONE; +} + +/** + * @function utc_capi_mv_face_detection_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_face_detection_startup1(void) +{ + printf("capi-media-vision mv_face_detection tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + printf("capi-media-vision mv_face_detection tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_face_detection_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_face_detection_cleanup1(void) +{ + printf("capi-media-vision mv_face_detection tests CLEANUP is launched\n"); + printf("capi-media-vision mv_face_detection tests CLEANUP is completed\n"); +} + +/** + * @function utc_capi_mv_face_detection_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_face_detection_startup2(void) +{ + printf("capi-media-vision mv_face_detection tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + char pszValue[CONFIG_VALUE_LEN_MAX] = { + 0, + }; + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) { + PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, + pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", + pszValue); + + } else { + PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for " + "'DEVICE_SUITE_TARGET_30'\n", + __LINE__, API_NAMESPACE); + } + + gStartupError = mv_face_detection_create(&gInferenceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gInferenceHandle = NULL; + printf("mv_face_detection_h create is failed\n"); + return; + } + + gStartupError = mv_create_source(&gSourceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gSourceHandle = NULL; + printf("mv_source_h create is failed\n"); + return; + } + + printf("capi-media-vision mv_face_detection tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_face_detection_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_face_detection_cleanup2(void) +{ + printf("capi-media-vision mv_face_detection tests CLEANUP is launched\n"); + + if (gInferenceHandle) { + mv_face_detection_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir) { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + printf("capi-media-vision mv_face_detection tests CLEANUP is completed\n"); +} + +/** + * @brief Positive test case of mv_face_detection_create_p() + * @testcase utc_mediavision_mv_face_detection_create_p + * @since_tizen 9.0 + * @description Create inference handle + */ +int utc_mediavision_mv_face_detection_create_p(void) +{ + printf("Inside mv_face_detection_create_p\n"); + + mv_face_detection_h inferenceHandle = NULL; + int ret = mv_face_detection_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_face_detection_create_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_create() + * @testcase utc_mediavision_mv_face_detection_create_n + * @since_tizen 9.0 + * @description Create inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_face_detection_create_n(void) +{ + printf("Inside mv_face_detection_create_n\n"); + + int ret = mv_face_detection_create(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_face_detection_create_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_face_detection_destroy_p() + * @testcase utc_mediavision_mv_face_detection_destroy_p + * @since_tizen 9.0 + * @description Destroy inference handle + */ +int utc_mediavision_mv_face_detection_destroy_p(void) +{ + printf("Inside mv_face_detection_destroy_p\n"); + + mv_face_detection_h inferenceHandle = NULL; + int ret = mv_face_detection_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_face_detection_destroy_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_destroy_n() + * @testcase utc_mediavision_mv_face_detection_destroy_n + * @since_tizen 9.0 + * @description Destroy inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_face_detection_destroy_n(void) +{ + printf("Inside mv_face_detection_destroy_n\n"); + + int ret = mv_face_detection_destroy(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_face_detection_destroy_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_face_detection_configure_p() + * @testcase utc_mediavision_mv_face_detection_configure_p + * @since_tizen 9.0 + * @description Configure inference handle + */ +int utc_mediavision_mv_face_detection_configure_p(void) +{ + printf("Inside mv_face_detection_configure_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_face_detection_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_configure_n() + * @testcase utc_mediavision_mv_face_detection_configure_n + * @since_tizen 9.0 + * @description Configure inference handle, + * but fail because input parameters are invalid + */ +int utc_mediavision_mv_face_detection_configure_n(void) +{ + printf("Inside mv_face_detection_configure_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_face_detection_configure(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_face_detection_configure_n1\n"); + return 0; +} + +/** + * @brief Positive test case of mv_face_detection_prepare_p() + * @testcase utc_mediavision_mv_face_detection_prepare_p + * @since_tizen 9.0 + * @description Prepare inference handle + */ +int utc_mediavision_mv_face_detection_prepare_p(void) +{ + printf("Inside mv_face_detection_prepare_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_face_detection_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_prepare_n1() + * @testcase utc_mediavision_mv_face_detection_prepare_n1 + * @since_tizen 9.0 + * @description Prepare inference handle, + * but fail because input handle is NULL + */ +int utc_mediavision_mv_face_detection_prepare_n1(void) +{ + printf("Inside mv_face_detection_prepare_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_face_detection_prepare(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_face_detection_prepare_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_prepare_n2() + * @testcase utc_mediavision_mv_face_detection_prepare_n2 + * @since_tizen 9.0 + * @description Prepare inference handle, but fail because + * mv_face_detection_configure is not called. + */ +int utc_mediavision_mv_face_detection_prepare_n2(void) +{ + printf("Inside mv_face_detection_prepare_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_face_detection_prepare_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_face_detection_inference() + * @testcase utc_mediavision_mv_face_detection_inference_p + * @since_tizen 9.0 + * @description Detect a face + */ +int utc_mediavision_mv_face_detection_inference_p(void) +{ + printf("Inside mv_face_detection_inference_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_face_detection_inference_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_inference() + * @testcase utc_mediavision_mv_face_detection_inference_n1 + * @since_tizen 9.0 + * @description Detect a face, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_face_detection_inference_n1(void) +{ + printf("Inside mv_face_detection_inference_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_face_detection_inference(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_face_detection_inference(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_face_detection_inference(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_face_detection_inference_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_inference() + * @testcase utc_mediavision_mv_face_detection_inference_n2 + * @since_tizen 9.0 + * @description Detect a face, + * but fail because mv_face_detection_prepare() isn't called before + */ +int utc_mediavision_mv_face_detection_inference_n2(void) +{ + printf("Inside mv_face_detection_inference_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_face_detection_prepare() + ret = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_face_detection_inference_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_face_detection_inference_async() + * @testcase utc_mediavision_mv_face_detection_inference_async_p + * @since_tizen 9.0 + * @description Detect a face + */ +int utc_mediavision_mv_face_detection_inference_async_p(void) +{ + printf("Inside mv_face_detection_inference_async_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + ret = mv_face_detection_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + if (iter == 0) + pthread_create(&thread_id, NULL, face_detection_callback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + assert_eq(status, 0); + + printf("Before return mv_face_detection_inference_async_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_inference_async() + * @testcase utc_mediavision_mv_face_detection_inference_async_n1 + * @since_tizen 9.0 + * @description Detect a face, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_face_detection_inference_async_n1(void) +{ + printf("Inside mv_face_detection_inference_async_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_face_detection_inference_async(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_face_detection_inference_async(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_face_detection_inference_async(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_face_detection_inference_async_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_inference_async() + * @testcase utc_mediavision_mv_face_detection_inference_async_n2 + * @since_tizen 9.0 + * @description Detect a face, + * but fail because mv_face_detection_prepare() isn't called before + */ +int utc_mediavision_mv_face_detection_inference_async_n2(void) +{ + printf("Inside mv_face_detection_inference_async_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_face_detection_prepare() + ret = mv_face_detection_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_face_detection_inference_async_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_face_detection_get_result_count() + * @testcase utc_mediavision_mv_face_detection_get_result_count_p + * @since_tizen 9.0 + * @description Detect a face + */ +int utc_mediavision_mv_face_detection_get_result_count_p(void) +{ + printf("Inside mv_face_detection_get_result_count_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_face_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 2); + + printf("Before return mv_face_detection_get_result_count_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_get_result_count() + * @testcase utc_mediavision_mv_face_detection_get_result_count_n1 + * @since_tizen 9.0 + * @description Detect a face, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_face_detection_get_result_count_n1(void) +{ + printf("Inside mv_face_detection_get_result_count_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + unsigned long frame_number; + unsigned int cnt; + + // source is NULL + int ret = mv_face_detection_get_result_count(NULL, &frame_number, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // frame_number is NULL + ret = mv_face_detection_get_result_count(gInferenceHandle, NULL, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // result_cnt is NULL + ret = mv_face_detection_get_result_count(gInferenceHandle, &frame_number, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_face_detection_get_result_count_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_get_result_count() + * @testcase utc_mediavision_mv_face_detection_get_result_count_n2 + * @since_tizen 9.0 + * @description Detect a face, but fail because + * mv_face_detection_inference is not called. + */ +int utc_mediavision_mv_face_detection_get_result_count_n2(void) +{ + printf("Inside mv_face_detection_get_result_count_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_face_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_face_detection_get_result_count_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_face_detection_get_bound_box() + * @testcase utc_mediavision_mv_face_detection_get_bound_box_p + * @since_tizen 9.0 + * @description Detect a face + */ +int utc_mediavision_mv_face_detection_get_bound_box_p(void) +{ + printf("Inside mv_face_detection_get_bound_box_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_face_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 2); + + const int coordinate_answers[2][4] = { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } }; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + int left, top, right, bottom; + + ret = mv_face_detection_get_bound_box(gInferenceHandle, idx, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + assert_eq(coordinate_answers[idx][0], left); + assert_eq(coordinate_answers[idx][1], top); + assert_eq(coordinate_answers[idx][2], right); + assert_eq(coordinate_answers[idx][3], bottom); + } + + printf("Before return mv_face_detection_get_bound_box_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_get_bound_box() + * @testcase utc_mediavision_mv_face_detection_get_bound_box_n1 + * @since_tizen 9.0 + * @description Detect a face, but fail because + * input parameter is NULL. + */ +int utc_mediavision_mv_face_detection_get_bound_box_n1(void) +{ + printf("Inside mv_face_detection_get_bound_box_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int left, top, right, bottom; + + // source is NULL + int ret = mv_face_detection_get_bound_box(NULL, 0, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // left is NULL + ret = mv_face_detection_get_bound_box(gInferenceHandle, 0, NULL, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // top is NULL + ret = mv_face_detection_get_bound_box(gInferenceHandle, 0, &left, NULL, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // right is NULL + ret = mv_face_detection_get_bound_box(gInferenceHandle, 0, &left, &top, NULL, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // bottom is NULL + ret = mv_face_detection_get_bound_box(gInferenceHandle, 0, &left, &top, &right, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // all are NULL + ret = mv_face_detection_get_bound_box(NULL, 0, NULL, NULL, NULL, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_face_detection_get_bound_box_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_get_bound_box() + * @testcase utc_mediavision_mv_face_detection_get_bound_box_n2 + * @since_tizen 9.0 + * @description Detect a face but fail because idx is wrong. + */ +int utc_mediavision_mv_face_detection_get_bound_box_n2(void) +{ + printf("Inside mv_face_detection_get_bound_box_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_face_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 2); + + int left, top, right, bottom; + ret = mv_face_detection_get_bound_box(gInferenceHandle, 2, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_face_detection_get_bound_box_n2\n"); + return 0; +} + +/** + * @brief Negative test case of mv_face_detection_get_bound_box() + * @testcase utc_mediavision_mv_face_detection_get_bound_box_n3 + * @since_tizen 9.0 + * @description Detect a face but fail because + * mv_face_detection_get_result_count is not called. + */ +int utc_mediavision_mv_face_detection_get_bound_box_n3(void) +{ + printf("Inside mv_face_detection_get_bound_box_n3\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_face_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + int left, top, right, bottom; + ret = mv_face_detection_get_bound_box(gInferenceHandle, 0, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_face_detection_get_bound_box_n3\n"); + return 0; +} diff --git a/src/utc/capi-media-vision-dl/utc-mv_face_recognition.c b/src/utc/capi-media-vision-dl/utc-mv_face_recognition.c index d07eb98b7..e86399300 100644 --- a/src/utc/capi-media-vision-dl/utc-mv_face_recognition.c +++ b/src/utc/capi-media-vision-dl/utc-mv_face_recognition.c @@ -76,8 +76,8 @@ static int load_image_to_media_source(const char *file_path, mv_source_h source) if (ret2 != MEDIA_VISION_ERROR_NONE) goto _LOAD_IMAGE_FAIL; - ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned long long) buffer_size, width, - height, MEDIA_VISION_COLORSPACE_RGB888); + ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned long long) buffer_size, width, height, + MEDIA_VISION_COLORSPACE_RGB888); _LOAD_IMAGE_FAIL: image_util_decode_destroy(_decoder); @@ -92,20 +92,24 @@ _LOAD_IMAGE_FAIL: static bool is_face_recognition_feature_supported(void) { - bool isInferenceSupported =false; - bool isTrainingSupported =false; - bool isInferenceFaceRecognitionSupported =false; - bool isTrainingFaceRecognitionSupported =false; + bool isInferenceSupported = false; + bool isTrainingSupported = false; + bool isInferenceFaceRecognitionSupported = false; + bool isTrainingFaceRecognitionSupported = false; system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); system_info_get_platform_bool("http://tizen.org/feature/vision.training", &isTrainingSupported); - system_info_get_platform_bool("http://tizen.org/feature/vision.inference.face_recognition", &isInferenceFaceRecognitionSupported); - system_info_get_platform_bool("http://tizen.org/feature/vision.training.face_recognition", &isTrainingFaceRecognitionSupported); + system_info_get_platform_bool("http://tizen.org/feature/vision.inference.face_recognition", + &isInferenceFaceRecognitionSupported); + system_info_get_platform_bool("http://tizen.org/feature/vision.training.face_recognition", + &isTrainingFaceRecognitionSupported); - if (!isInferenceSupported || !isTrainingSupported || !isInferenceFaceRecognitionSupported || !isTrainingFaceRecognitionSupported) + if (!isInferenceSupported || !isTrainingSupported || !isInferenceFaceRecognitionSupported || + !isTrainingFaceRecognitionSupported) printf("Not support face recognition feature."); - return (isInferenceSupported && isTrainingSupported && isInferenceFaceRecognitionSupported && isTrainingFaceRecognitionSupported); + return (isInferenceSupported && isTrainingSupported && isInferenceFaceRecognitionSupported && + isTrainingFaceRecognitionSupported); } /** diff --git a/src/utc/capi-media-vision-dl/utc-mv_facial_landmark.c b/src/utc/capi-media-vision-dl/utc-mv_facial_landmark.c new file mode 100644 index 000000000..97017111b --- /dev/null +++ b/src/utc/capi-media-vision-dl/utc-mv_facial_landmark.c @@ -0,0 +1,977 @@ +/** + * 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 "assert.h" +#include + +#include +#include +#include +#include +#include + +#include "tct_common.h" +#include +#include +#include + +#define FILE_PATH_SIZE 1024 +#define MAX_INFERENCE_ITERATION 50 +#define API_NAMESPACE "[MediaVision]" +#define IMG_NAME "faceLandmark.jpg" + +static bool isVisionSupported = false; +static int gStartupError; + +static mv_facial_landmark_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +static void *facial_landmark_callback(void *user_data) +{ + mv_facial_landmark_h handle = (mv_facial_landmark_h) user_data; + const unsigned int coordinate_answers[][5] = { { 42, 87, 63, 48, 83 }, { 32, 31, 53, 75, 76 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int ret = mv_facial_landmark_get_result_count(handle, &frame_number, &cnt); + if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + for (unsigned long idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + ret = mv_facial_landmark_get_position(handle, idx, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + + assert(distance_x <= 3 && distance_y <= 3); + } + } + return 0; +} + +static int load_image_to_media_source(const char *file_path, mv_source_h source) +{ + if (NULL == file_path || NULL == source) { + printf("File path or source is NULL\n"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + + unsigned int width = 0; + unsigned int height = 0; + size_t buffer_size = 0; + unsigned char *data_buffer = NULL; + int ret1 = IMAGE_UTIL_ERROR_NONE; + int ret2 = MEDIA_VISION_ERROR_NONE; + image_util_decode_h _decoder = NULL; + image_util_image_h _decoded_image = NULL; + + ret1 = image_util_decode_create(&_decoder); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_input_path(_decoder, file_path); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_run2(_decoder, &_decoded_image); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_get_image(_decoded_image, &width, &height, NULL, &data_buffer, &buffer_size); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_clear(source); + if (ret2 != MEDIA_VISION_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width, + (unsigned int) height, MEDIA_VISION_COLORSPACE_RGB888); + +_LOAD_IMAGE_FAIL: + image_util_decode_destroy(_decoder); + image_util_destroy_image(_decoded_image); + if (data_buffer) + free(data_buffer); + + assert_eq(IMAGE_UTIL_ERROR_NONE, ret1); + assert_eq(MEDIA_VISION_ERROR_NONE, ret2); + + return MEDIA_VISION_ERROR_NONE; +} + +/** + * @function utc_capi_mv_facial_landmark_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_facial_landmark_startup1(void) +{ + printf("capi-media-vision mv_facial_landmark tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + printf("capi-media-vision mv_facial_landmark tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_facial_landmark_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_facial_landmark_cleanup1(void) +{ + printf("capi-media-vision mv_facial_landmark tests CLEANUP is launched\n"); + printf("capi-media-vision mv_facial_landmark tests CLEANUP is completed\n"); +} + +/** + * @function utc_capi_mv_facial_landmark_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_facial_landmark_startup2(void) +{ + printf("capi-media-vision mv_facial_landmark tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + char pszValue[CONFIG_VALUE_LEN_MAX] = { + 0, + }; + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) { + PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, + pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", + pszValue); + + } else { + PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for " + "'DEVICE_SUITE_TARGET_30'\n", + __LINE__, API_NAMESPACE); + } + + gStartupError = mv_facial_landmark_create(&gInferenceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gInferenceHandle = NULL; + printf("mv_facial_landmark_h create is failed\n"); + return; + } + + gStartupError = mv_create_source(&gSourceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gSourceHandle = NULL; + printf("mv_source_h create is failed\n"); + return; + } + + printf("capi-media-vision mv_facial_landmark tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_facial_landmark_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_facial_landmark_cleanup2(void) +{ + printf("capi-media-vision mv_facial_landmark tests CLEANUP is launched\n"); + + if (gInferenceHandle) { + mv_facial_landmark_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir) { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + printf("capi-media-vision mv_facial_landmark tests CLEANUP is completed\n"); +} + +/** + * @brief Positive test case of mv_facial_landmark_create_p() + * @testcase utc_mediavision_mv_facial_landmark_create_p + * @since_tizen 9.0 + * @description Create inference handle + */ +int utc_mediavision_mv_facial_landmark_create_p(void) +{ + printf("Inside mv_facial_landmark_create_p\n"); + + mv_facial_landmark_h inferenceHandle = NULL; + int ret = mv_facial_landmark_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_facial_landmark_create_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_create() + * @testcase utc_mediavision_mv_facial_landmark_create_n + * @since_tizen 9.0 + * @description Create inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_facial_landmark_create_n(void) +{ + printf("Inside mv_facial_landmark_create_n\n"); + + int ret = mv_facial_landmark_create(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_facial_landmark_create_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_facial_landmark_destroy_p() + * @testcase utc_mediavision_mv_facial_landmark_destroy_p + * @since_tizen 9.0 + * @description Destroy inference handle + */ +int utc_mediavision_mv_facial_landmark_destroy_p(void) +{ + printf("Inside mv_facial_landmark_destroy_p\n"); + + mv_facial_landmark_h inferenceHandle = NULL; + int ret = mv_facial_landmark_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_facial_landmark_destroy_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_destroy_n() + * @testcase utc_mediavision_mv_facial_landmark_destroy_n + * @since_tizen 9.0 + * @description Destroy inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_facial_landmark_destroy_n(void) +{ + printf("Inside mv_facial_landmark_destroy_n\n"); + + int ret = mv_facial_landmark_destroy(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_facial_landmark_destroy_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_facial_landmark_configure_p() + * @testcase utc_mediavision_mv_facial_landmark_configure_p + * @since_tizen 9.0 + * @description Configure inference handle + */ +int utc_mediavision_mv_facial_landmark_configure_p(void) +{ + printf("Inside mv_facial_landmark_configure_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_facial_landmark_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_configure_n() + * @testcase utc_mediavision_mv_facial_landmark_configure_n + * @since_tizen 9.0 + * @description Configure inference handle, + * but fail because input parameters are invalid + */ +int utc_mediavision_mv_facial_landmark_configure_n(void) +{ + printf("Inside mv_facial_landmark_configure_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_facial_landmark_configure(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_facial_landmark_configure_n1\n"); + return 0; +} + +/** + * @brief Positive test case of mv_facial_landmark_prepare_p() + * @testcase utc_mediavision_mv_facial_landmark_prepare_p + * @since_tizen 9.0 + * @description Prepare inference handle + */ +int utc_mediavision_mv_facial_landmark_prepare_p(void) +{ + printf("Inside mv_facial_landmark_prepare_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_facial_landmark_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_prepare_n1() + * @testcase utc_mediavision_mv_facial_landmark_prepare_n1 + * @since_tizen 9.0 + * @description Prepare inference handle, + * but fail because input handle is NULL + */ +int utc_mediavision_mv_facial_landmark_prepare_n1(void) +{ + printf("Inside mv_facial_landmark_prepare_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_facial_landmark_prepare(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_facial_landmark_prepare_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_prepare_n2() + * @testcase utc_mediavision_mv_facial_landmark_prepare_n2 + * @since_tizen 9.0 + * @description Prepare inference handle, but fail because + * mv_facial_landmark_configure is not called. + */ +int utc_mediavision_mv_facial_landmark_prepare_n2(void) +{ + printf("Inside mv_facial_landmark_prepare_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_facial_landmark_prepare_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_facial_landmark_inference() + * @testcase utc_mediavision_mv_facial_landmark_inference_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_facial_landmark_inference_p(void) +{ + printf("Inside mv_facial_landmark_inference_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_facial_landmark_inference_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_inference() + * @testcase utc_mediavision_mv_facial_landmark_inference_n1 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_facial_landmark_inference_n1(void) +{ + printf("Inside mv_facial_landmark_inference_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_facial_landmark_inference(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_facial_landmark_inference(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_facial_landmark_inference(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_facial_landmark_inference_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_inference() + * @testcase utc_mediavision_mv_facial_landmark_inference_n2 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because mv_facial_landmark_prepare() isn't called before + */ +int utc_mediavision_mv_facial_landmark_inference_n2(void) +{ + printf("Inside mv_facial_landmark_inference_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_facial_landmark_prepare() + ret = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_facial_landmark_inference_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_facial_landmark_inference_async() + * @testcase utc_mediavision_mv_facial_landmark_inference_async_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_facial_landmark_inference_async_p(void) +{ + printf("Inside mv_facial_landmark_inference_async_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + ret = mv_facial_landmark_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + if (iter == 0) + pthread_create(&thread_id, NULL, facial_landmark_callback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + assert_eq(status, 0); + + printf("Before return mv_facial_landmark_inference_async_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_inference_async() + * @testcase utc_mediavision_mv_facial_landmark_inference_async_n1 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_facial_landmark_inference_async_n1(void) +{ + printf("Inside mv_facial_landmark_inference_async_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_facial_landmark_inference_async(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_facial_landmark_inference_async(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_facial_landmark_inference_async(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_facial_landmark_inference_async_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_inference_async() + * @testcase utc_mediavision_mv_facial_landmark_inference_async_n2 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because mv_facial_landmark_prepare() isn't called before + */ +int utc_mediavision_mv_facial_landmark_inference_async_n2(void) +{ + printf("Inside mv_facial_landmark_inference_async_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_facial_landmark_prepare() + ret = mv_facial_landmark_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_facial_landmark_inference_async_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_facial_landmark_get_result_count() + * @testcase utc_mediavision_mv_facial_landmark_get_result_count_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_facial_landmark_get_result_count_p(void) +{ + printf("Inside mv_facial_landmark_get_result_count_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_facial_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 5); + + printf("Before return mv_facial_landmark_get_result_count_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_get_result_count() + * @testcase utc_mediavision_mv_facial_landmark_get_result_count_n1 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_facial_landmark_get_result_count_n1(void) +{ + printf("Inside mv_facial_landmark_get_result_count_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + unsigned long frame_number; + unsigned int cnt; + + // source is NULL + int ret = mv_facial_landmark_get_result_count(NULL, &frame_number, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // frame_number is NULL + ret = mv_facial_landmark_get_result_count(gInferenceHandle, NULL, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // result_cnt is NULL + ret = mv_facial_landmark_get_result_count(gInferenceHandle, &frame_number, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_facial_landmark_get_result_count_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_get_result_count() + * @testcase utc_mediavision_mv_facial_landmark_get_result_count_n2 + * @since_tizen 9.0 + * @description Detect landmark position, but fail because + * mv_facial_landmark_inference is not called. + */ +int utc_mediavision_mv_facial_landmark_get_result_count_n2(void) +{ + printf("Inside mv_facial_landmark_get_result_count_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_facial_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_facial_landmark_get_result_count_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_facial_landmark_get_position() + * @testcase utc_mediavision_mv_facial_landmark_get_position_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_facial_landmark_get_position_p(void) +{ + printf("Inside mv_facial_landmark_get_position_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_facial_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 5); + + const unsigned int coordinate_answers[][5] = { { 42, 87, 63, 48, 83 }, { 32, 31, 53, 75, 76 } }; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + ret = mv_facial_landmark_get_position(gInferenceHandle, idx, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + + assert(distance_x <= 2 && distance_y <= 2); + } + + printf("Before return mv_facial_landmark_get_position_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_get_position() + * @testcase utc_mediavision_mv_facial_landmark_get_position_n1 + * @since_tizen 9.0 + * @description Detect landmark position, but fail because + * input parameter is NULL. + */ +int utc_mediavision_mv_facial_landmark_get_position_n1(void) +{ + printf("Inside mv_facial_landmark_get_position_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + unsigned int pos_x, pos_y; + + // source is NULL + int ret = mv_facial_landmark_get_position(NULL, 0, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // pos_x is NULL + ret = mv_facial_landmark_get_position(gInferenceHandle, 0, NULL, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // pos_y is NULL + ret = mv_facial_landmark_get_position(gInferenceHandle, 0, &pos_x, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // all are NULL + ret = mv_facial_landmark_get_position(NULL, 0, NULL, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_facial_landmark_get_position_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_get_position() + * @testcase utc_mediavision_mv_facial_landmark_get_position_n2 + * @since_tizen 9.0 + * @description Detect landmark position but fail because idx is wrong. + */ +int utc_mediavision_mv_facial_landmark_get_position_n2(void) +{ + printf("Inside mv_facial_landmark_get_position_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_facial_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 5); + + unsigned int pos_x, pos_y; + ret = mv_facial_landmark_get_position(gInferenceHandle, 5, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_facial_landmark_get_position_n2\n"); + return 0; +} + +/** + * @brief Negative test case of mv_facial_landmark_get_position() + * @testcase utc_mediavision_mv_facial_landmark_get_position_n3 + * @since_tizen 9.0 + * @description Detect landmark position but fail because + * mv_facial_landmark_get_result_count is not called. + */ +int utc_mediavision_mv_facial_landmark_get_position_n3(void) +{ + printf("Inside mv_facial_landmark_get_position_n3\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_facial_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned int pos_x, pos_y; + ret = mv_facial_landmark_get_position(gInferenceHandle, 0, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_facial_landmark_get_position_n3\n"); + return 0; +} diff --git a/src/utc/capi-media-vision-dl/utc-mv_image_classification.c b/src/utc/capi-media-vision-dl/utc-mv_image_classification.c new file mode 100644 index 000000000..8e1a94096 --- /dev/null +++ b/src/utc/capi-media-vision-dl/utc-mv_image_classification.c @@ -0,0 +1,953 @@ +/** + * 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 "assert.h" +#include + +#include +#include +#include +#include +#include + +#include "tct_common.h" +#include +#include +#include + +#define FILE_PATH_SIZE 1024 +#define MAX_INFERENCE_ITERATION 50 +#define API_NAMESPACE "[MediaVision]" +#define IMG_NAME "banana.jpg" + +static bool isVisionSupported = false; +static int gStartupError; + +static mv_image_classification_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +static 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 ret = mv_image_classification_get_result_count(handle, &frame_number, &cnt); + if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + for (unsigned long idx = 0; idx < cnt; ++idx) { + const char *label = NULL; + + ret = mv_image_classification_get_label(handle, idx, &label); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + + assert_eq(strcmp(label, "Banana"), 0); + } + } + return 0; +} + +static int load_image_to_media_source(const char *file_path, mv_source_h source) +{ + if (NULL == file_path || NULL == source) { + printf("File path or source is NULL\n"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + + unsigned int width = 0; + unsigned int height = 0; + size_t buffer_size = 0; + unsigned char *data_buffer = NULL; + int ret1 = IMAGE_UTIL_ERROR_NONE; + int ret2 = MEDIA_VISION_ERROR_NONE; + image_util_decode_h _decoder = NULL; + image_util_image_h _decoded_image = NULL; + + ret1 = image_util_decode_create(&_decoder); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_input_path(_decoder, file_path); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_run2(_decoder, &_decoded_image); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_get_image(_decoded_image, &width, &height, NULL, &data_buffer, &buffer_size); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_clear(source); + if (ret2 != MEDIA_VISION_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width, + (unsigned int) height, MEDIA_VISION_COLORSPACE_RGB888); + +_LOAD_IMAGE_FAIL: + image_util_decode_destroy(_decoder); + image_util_destroy_image(_decoded_image); + if (data_buffer) + free(data_buffer); + + assert_eq(IMAGE_UTIL_ERROR_NONE, ret1); + assert_eq(MEDIA_VISION_ERROR_NONE, ret2); + + return MEDIA_VISION_ERROR_NONE; +} + +/** + * @function utc_capi_mv_image_classification_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_image_classification_startup1(void) +{ + printf("capi-media-vision mv_image_classification tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + printf("capi-media-vision mv_image_classification tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_image_classification_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_image_classification_cleanup1(void) +{ + printf("capi-media-vision mv_image_classification tests CLEANUP is launched\n"); + printf("capi-media-vision mv_image_classification tests CLEANUP is completed\n"); +} + +/** + * @function utc_capi_mv_image_classification_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_image_classification_startup2(void) +{ + printf("capi-media-vision mv_image_classification tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + char pszValue[CONFIG_VALUE_LEN_MAX] = { + 0, + }; + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) { + PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, + pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", + pszValue); + + } else { + PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for " + "'DEVICE_SUITE_TARGET_30'\n", + __LINE__, API_NAMESPACE); + } + + gStartupError = mv_image_classification_create(&gInferenceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gInferenceHandle = NULL; + printf("mv_image_classification_h create is failed\n"); + return; + } + + gStartupError = mv_create_source(&gSourceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gSourceHandle = NULL; + printf("mv_source_h create is failed\n"); + return; + } + + printf("capi-media-vision mv_image_classification tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_image_classification_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_image_classification_cleanup2(void) +{ + printf("capi-media-vision mv_image_classification tests CLEANUP is launched\n"); + + if (gInferenceHandle) { + mv_image_classification_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir) { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + printf("capi-media-vision mv_image_classification tests CLEANUP is completed\n"); +} + +/** + * @brief Positive test case of mv_image_classification_create_p() + * @testcase utc_mediavision_mv_image_classification_create_p + * @since_tizen 9.0 + * @description Create inference handle + */ +int utc_mediavision_mv_image_classification_create_p(void) +{ + printf("Inside mv_image_classification_create_p\n"); + + mv_image_classification_h inferenceHandle = NULL; + int ret = mv_image_classification_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_image_classification_create_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_create() + * @testcase utc_mediavision_mv_image_classification_create_n + * @since_tizen 9.0 + * @description Create inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_image_classification_create_n(void) +{ + printf("Inside mv_image_classification_create_n\n"); + + int ret = mv_image_classification_create(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_image_classification_create_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_image_classification_destroy_p() + * @testcase utc_mediavision_mv_image_classification_destroy_p + * @since_tizen 9.0 + * @description Destroy inference handle + */ +int utc_mediavision_mv_image_classification_destroy_p(void) +{ + printf("Inside mv_image_classification_destroy_p\n"); + + mv_image_classification_h inferenceHandle = NULL; + int ret = mv_image_classification_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_image_classification_destroy_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_destroy_n() + * @testcase utc_mediavision_mv_image_classification_destroy_n + * @since_tizen 9.0 + * @description Destroy inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_image_classification_destroy_n(void) +{ + printf("Inside mv_image_classification_destroy_n\n"); + + int ret = mv_image_classification_destroy(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_image_classification_destroy_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_image_classification_configure_p() + * @testcase utc_mediavision_mv_image_classification_configure_p + * @since_tizen 9.0 + * @description Configure inference handle + */ +int utc_mediavision_mv_image_classification_configure_p(void) +{ + printf("Inside mv_image_classification_configure_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_image_classification_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_configure_n() + * @testcase utc_mediavision_mv_image_classification_configure_n + * @since_tizen 9.0 + * @description Configure inference handle, + * but fail because input parameters are invalid + */ +int utc_mediavision_mv_image_classification_configure_n(void) +{ + printf("Inside mv_image_classification_configure_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_image_classification_configure(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_image_classification_configure_n1\n"); + return 0; +} + +/** + * @brief Positive test case of mv_image_classification_prepare_p() + * @testcase utc_mediavision_mv_image_classification_prepare_p + * @since_tizen 9.0 + * @description Prepare inference handle + */ +int utc_mediavision_mv_image_classification_prepare_p(void) +{ + printf("Inside mv_image_classification_prepare_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_image_classification_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_prepare_n1() + * @testcase utc_mediavision_mv_image_classification_prepare_n1 + * @since_tizen 9.0 + * @description Prepare inference handle, + * but fail because input handle is NULL + */ +int utc_mediavision_mv_image_classification_prepare_n1(void) +{ + printf("Inside mv_image_classification_prepare_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_image_classification_prepare(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_image_classification_prepare_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_prepare_n2() + * @testcase utc_mediavision_mv_image_classification_prepare_n2 + * @since_tizen 9.0 + * @description Prepare inference handle, but fail because + * mv_image_classification_configure is not called. + */ +int utc_mediavision_mv_image_classification_prepare_n2(void) +{ + printf("Inside mv_image_classification_prepare_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_image_classification_prepare_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_image_classification_inference() + * @testcase utc_mediavision_mv_image_classification_inference_p + * @since_tizen 9.0 + * @description Classify an image + */ +int utc_mediavision_mv_image_classification_inference_p(void) +{ + printf("Inside mv_image_classification_inference_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_image_classification_inference_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_inference() + * @testcase utc_mediavision_mv_image_classification_inference_n1 + * @since_tizen 9.0 + * @description Classify an image, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_image_classification_inference_n1(void) +{ + printf("Inside mv_image_classification_inference_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_image_classification_inference(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_image_classification_inference(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_image_classification_inference(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_image_classification_inference_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_inference() + * @testcase utc_mediavision_mv_image_classification_inference_n2 + * @since_tizen 9.0 + * @description Classify an image, + * but fail because mv_image_classification_prepare() isn't called before + */ +int utc_mediavision_mv_image_classification_inference_n2(void) +{ + printf("Inside mv_image_classification_inference_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_image_classification_prepare() + ret = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_image_classification_inference_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_image_classification_inference_async() + * @testcase utc_mediavision_mv_image_classification_inference_async_p + * @since_tizen 9.0 + * @description Classify an image + */ +int utc_mediavision_mv_image_classification_inference_async_p(void) +{ + printf("Inside mv_image_classification_inference_async_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + ret = mv_image_classification_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + if (iter == 0) + pthread_create(&thread_id, NULL, image_classification_callback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + assert_eq(status, 0); + + printf("Before return mv_image_classification_inference_async_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_inference_async() + * @testcase utc_mediavision_mv_image_classification_inference_async_n1 + * @since_tizen 9.0 + * @description Classify an image, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_image_classification_inference_async_n1(void) +{ + printf("Inside mv_image_classification_inference_async_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_image_classification_inference_async(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_image_classification_inference_async(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_image_classification_inference_async(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_image_classification_inference_async_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_inference_async() + * @testcase utc_mediavision_mv_image_classification_inference_async_n2 + * @since_tizen 9.0 + * @description Classify an image, + * but fail because mv_image_classification_prepare() isn't called before + */ +int utc_mediavision_mv_image_classification_inference_async_n2(void) +{ + printf("Inside mv_image_classification_inference_async_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_image_classification_prepare() + ret = mv_image_classification_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_image_classification_inference_async_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_image_classification_get_result_count() + * @testcase utc_mediavision_mv_image_classification_get_result_count_p + * @since_tizen 9.0 + * @description Classify an image + */ +int utc_mediavision_mv_image_classification_get_result_count_p(void) +{ + printf("Inside mv_image_classification_get_result_count_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_image_classification_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 1); + + printf("Before return mv_image_classification_get_result_count_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_get_result_count() + * @testcase utc_mediavision_mv_image_classification_get_result_count_n1 + * @since_tizen 9.0 + * @description Classify an image, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_image_classification_get_result_count_n1(void) +{ + printf("Inside mv_image_classification_get_result_count_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + unsigned long frame_number; + unsigned int cnt; + + // source is NULL + int ret = mv_image_classification_get_result_count(NULL, &frame_number, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // frame_number is NULL + ret = mv_image_classification_get_result_count(gInferenceHandle, NULL, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // result_cnt is NULL + ret = mv_image_classification_get_result_count(gInferenceHandle, &frame_number, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_image_classification_get_result_count_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_get_result_count() + * @testcase utc_mediavision_mv_image_classification_get_result_count_n2 + * @since_tizen 9.0 + * @description Classify an image, but fail because + * mv_image_classification_inference is not called. + */ +int utc_mediavision_mv_image_classification_get_result_count_n2(void) +{ + printf("Inside mv_image_classification_get_result_count_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_image_classification_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_image_classification_get_result_count_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_image_classification_get_label() + * @testcase utc_mediavision_mv_image_classification_get_label_p + * @since_tizen 9.0 + * @description Classify an image + */ +int utc_mediavision_mv_image_classification_get_label_p(void) +{ + printf("Inside mv_image_classification_get_label_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_image_classification_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 1); + + const char *label = NULL; + ret = mv_image_classification_get_label(gInferenceHandle, 0, &label); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(strcmp(label, "Banana"), 0); + + printf("Before return mv_image_classification_get_label_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_get_label() + * @testcase utc_mediavision_mv_image_classification_get_label_n1 + * @since_tizen 9.0 + * @description Classify an image, but fail because + * input parameter is NULL. + */ +int utc_mediavision_mv_image_classification_get_label_n1(void) +{ + printf("Inside mv_image_classification_get_label_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + const char *label = NULL; + + // source is NULL + int ret = mv_image_classification_get_label(NULL, 0, &label); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // label is NULL + ret = mv_image_classification_get_label(gInferenceHandle, 0, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // both are NULL + ret = mv_image_classification_get_label(NULL, 0, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_image_classification_get_label_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_get_label() + * @testcase utc_mediavision_mv_image_classification_get_label_n2 + * @since_tizen 9.0 + * @description Classify an image but fail because idx is wrong. + */ +int utc_mediavision_mv_image_classification_get_label_n2(void) +{ + printf("Inside mv_image_classification_get_label_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_image_classification_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 1); + + const char *label = NULL; + ret = mv_image_classification_get_label(gInferenceHandle, 1, &label); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_image_classification_get_label_n2\n"); + return 0; +} + +/** + * @brief Negative test case of mv_image_classification_get_label() + * @testcase utc_mediavision_mv_image_classification_get_label_n3 + * @since_tizen 9.0 + * @description Classify an image but fail because + * mv_image_classification_get_result_count is not called. + */ +int utc_mediavision_mv_image_classification_get_label_n3(void) +{ + printf("Inside mv_image_classification_get_label_n3\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_image_classification_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + const char *label = NULL; + ret = mv_image_classification_get_label(gInferenceHandle, 0, &label); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_image_classification_get_label_n3\n"); + return 0; +} diff --git a/src/utc/capi-media-vision-dl/utc-mv_inference.c b/src/utc/capi-media-vision-dl/utc-mv_inference.c index d5dd77f60..5d5dc5449 100644 --- a/src/utc/capi-media-vision-dl/utc-mv_inference.c +++ b/src/utc/capi-media-vision-dl/utc-mv_inference.c @@ -36,7 +36,7 @@ static int gStartupError; static mv_inference_h gInferenceHandle = NULL; static mv_engine_config_h gEngineConfigHandle = NULL; static mv_source_h gSourceHandle = NULL; -const char *gInferenceExampleDir = NULL; +static const char *gInferenceExampleDir = NULL; static mv_point_s **gPldResultLandmarks = NULL; static float **gPldResultScore = NULL; static mv_pose_h gPoseHandle = NULL; diff --git a/src/utc/capi-media-vision-dl/utc-mv_object_detection.c b/src/utc/capi-media-vision-dl/utc-mv_object_detection.c new file mode 100644 index 000000000..231d44b9e --- /dev/null +++ b/src/utc/capi-media-vision-dl/utc-mv_object_detection.c @@ -0,0 +1,979 @@ +/** + * 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 "assert.h" +#include + +#include +#include +#include +#include +#include + +#include "tct_common.h" +#include +#include +#include + +#define FILE_PATH_SIZE 1024 +#define MAX_INFERENCE_ITERATION 50 +#define API_NAMESPACE "[MediaVision]" +#define IMG_NAME "dog2.jpg" + +static bool isVisionSupported = false; +static int gStartupError; + +static mv_object_detection_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +static void *object_detection_callback(void *user_data) +{ + mv_object_detection_h handle = (mv_object_detection_h) user_data; + const int coordinate_answers[2][4] = { { 194, 27, 502, 298 }, { 12, 6, 164, 270 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int ret = mv_object_detection_get_result_count(handle, &frame_number, &cnt); + if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + for (unsigned long idx = 0; idx < cnt; ++idx) { + int 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); + assert_eq(coordinate_answers[idx][1], top); + assert_eq(coordinate_answers[idx][2], right); + assert_eq(coordinate_answers[idx][3], bottom); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } + return 0; +} + +static int load_image_to_media_source(const char *file_path, mv_source_h source) +{ + if (NULL == file_path || NULL == source) { + printf("File path or source is NULL\n"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + + unsigned int width = 0; + unsigned int height = 0; + size_t buffer_size = 0; + unsigned char *data_buffer = NULL; + int ret1 = IMAGE_UTIL_ERROR_NONE; + int ret2 = MEDIA_VISION_ERROR_NONE; + image_util_decode_h _decoder = NULL; + image_util_image_h _decoded_image = NULL; + + ret1 = image_util_decode_create(&_decoder); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_input_path(_decoder, file_path); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_run2(_decoder, &_decoded_image); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_get_image(_decoded_image, &width, &height, NULL, &data_buffer, &buffer_size); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_clear(source); + if (ret2 != MEDIA_VISION_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width, + (unsigned int) height, MEDIA_VISION_COLORSPACE_RGB888); + +_LOAD_IMAGE_FAIL: + image_util_decode_destroy(_decoder); + image_util_destroy_image(_decoded_image); + if (data_buffer) + free(data_buffer); + + assert_eq(IMAGE_UTIL_ERROR_NONE, ret1); + assert_eq(MEDIA_VISION_ERROR_NONE, ret2); + + return MEDIA_VISION_ERROR_NONE; +} + +/** + * @function utc_capi_mv_object_detection_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_object_detection_startup1(void) +{ + printf("capi-media-vision mv_object_detection tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + printf("capi-media-vision mv_object_detection tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_object_detection_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_object_detection_cleanup1(void) +{ + printf("capi-media-vision mv_object_detection tests CLEANUP is launched\n"); + printf("capi-media-vision mv_object_detection tests CLEANUP is completed\n"); +} + +/** + * @function utc_capi_mv_object_detection_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_object_detection_startup2(void) +{ + printf("capi-media-vision mv_object_detection tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + char pszValue[CONFIG_VALUE_LEN_MAX] = { + 0, + }; + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) { + PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, + pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", + pszValue); + + } else { + PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for " + "'DEVICE_SUITE_TARGET_30'\n", + __LINE__, API_NAMESPACE); + } + + gStartupError = mv_object_detection_create(&gInferenceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gInferenceHandle = NULL; + printf("mv_object_detection_h create is failed\n"); + return; + } + + gStartupError = mv_create_source(&gSourceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gSourceHandle = NULL; + printf("mv_source_h create is failed\n"); + return; + } + + printf("capi-media-vision mv_object_detection tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_object_detection_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_object_detection_cleanup2(void) +{ + printf("capi-media-vision mv_object_detection tests CLEANUP is launched\n"); + + if (gInferenceHandle) { + mv_object_detection_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir) { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + printf("capi-media-vision mv_object_detection tests CLEANUP is completed\n"); +} + +/** + * @brief Positive test case of mv_object_detection_create_p() + * @testcase utc_mediavision_mv_object_detection_create_p + * @since_tizen 9.0 + * @description Create inference handle + */ +int utc_mediavision_mv_object_detection_create_p(void) +{ + printf("Inside mv_object_detection_create_p\n"); + + mv_object_detection_h inferenceHandle = NULL; + int ret = mv_object_detection_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_object_detection_create_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_create() + * @testcase utc_mediavision_mv_object_detection_create_n + * @since_tizen 9.0 + * @description Create inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_object_detection_create_n(void) +{ + printf("Inside mv_object_detection_create_n\n"); + + int ret = mv_object_detection_create(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_object_detection_create_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_object_detection_destroy_p() + * @testcase utc_mediavision_mv_object_detection_destroy_p + * @since_tizen 9.0 + * @description Destroy inference handle + */ +int utc_mediavision_mv_object_detection_destroy_p(void) +{ + printf("Inside mv_object_detection_destroy_p\n"); + + mv_object_detection_h inferenceHandle = NULL; + int ret = mv_object_detection_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_object_detection_destroy_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_destroy_n() + * @testcase utc_mediavision_mv_object_detection_destroy_n + * @since_tizen 9.0 + * @description Destroy inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_object_detection_destroy_n(void) +{ + printf("Inside mv_object_detection_destroy_n\n"); + + int ret = mv_object_detection_destroy(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_object_detection_destroy_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_object_detection_configure_p() + * @testcase utc_mediavision_mv_object_detection_configure_p + * @since_tizen 9.0 + * @description Configure inference handle + */ +int utc_mediavision_mv_object_detection_configure_p(void) +{ + printf("Inside mv_object_detection_configure_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_object_detection_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_configure_n() + * @testcase utc_mediavision_mv_object_detection_configure_n + * @since_tizen 9.0 + * @description Configure inference handle, + * but fail because input parameters are invalid + */ +int utc_mediavision_mv_object_detection_configure_n(void) +{ + printf("Inside mv_object_detection_configure_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_object_detection_configure(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_object_detection_configure_n1\n"); + return 0; +} + +/** + * @brief Positive test case of mv_object_detection_prepare_p() + * @testcase utc_mediavision_mv_object_detection_prepare_p + * @since_tizen 9.0 + * @description Prepare inference handle + */ +int utc_mediavision_mv_object_detection_prepare_p(void) +{ + printf("Inside mv_object_detection_prepare_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_object_detection_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_prepare_n1() + * @testcase utc_mediavision_mv_object_detection_prepare_n1 + * @since_tizen 9.0 + * @description Prepare inference handle, + * but fail because input handle is NULL + */ +int utc_mediavision_mv_object_detection_prepare_n1(void) +{ + printf("Inside mv_object_detection_prepare_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_object_detection_prepare(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_object_detection_prepare_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_prepare_n2() + * @testcase utc_mediavision_mv_object_detection_prepare_n2 + * @since_tizen 9.0 + * @description Prepare inference handle, but fail because + * mv_object_detection_configure is not called. + */ +int utc_mediavision_mv_object_detection_prepare_n2(void) +{ + printf("Inside mv_object_detection_prepare_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_object_detection_prepare_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_object_detection_inference() + * @testcase utc_mediavision_mv_object_detection_inference_p + * @since_tizen 9.0 + * @description Detect an object + */ +int utc_mediavision_mv_object_detection_inference_p(void) +{ + printf("Inside mv_object_detection_inference_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_object_detection_inference_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_inference() + * @testcase utc_mediavision_mv_object_detection_inference_n1 + * @since_tizen 9.0 + * @description Detect an object, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_object_detection_inference_n1(void) +{ + printf("Inside mv_object_detection_inference_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_object_detection_inference(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_object_detection_inference(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_object_detection_inference(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_object_detection_inference_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_inference() + * @testcase utc_mediavision_mv_object_detection_inference_n2 + * @since_tizen 9.0 + * @description Detect an object, + * but fail because mv_object_detection_prepare() isn't called before + */ +int utc_mediavision_mv_object_detection_inference_n2(void) +{ + printf("Inside mv_object_detection_inference_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_object_detection_prepare() + ret = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_object_detection_inference_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_object_detection_inference_async() + * @testcase utc_mediavision_mv_object_detection_inference_async_p + * @since_tizen 9.0 + * @description Detect an object + */ +int utc_mediavision_mv_object_detection_inference_async_p(void) +{ + printf("Inside mv_object_detection_inference_async_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + ret = mv_object_detection_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + if (iter == 0) + pthread_create(&thread_id, NULL, object_detection_callback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + assert_eq(status, 0); + + printf("Before return mv_object_detection_inference_async_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_inference_async() + * @testcase utc_mediavision_mv_object_detection_inference_async_n1 + * @since_tizen 9.0 + * @description Detect an object, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_object_detection_inference_async_n1(void) +{ + printf("Inside mv_object_detection_inference_async_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_object_detection_inference_async(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_object_detection_inference_async(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_object_detection_inference_async(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_object_detection_inference_async_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_inference_async() + * @testcase utc_mediavision_mv_object_detection_inference_async_n2 + * @since_tizen 9.0 + * @description Detect an object, + * but fail because mv_object_detection_prepare() isn't called before + */ +int utc_mediavision_mv_object_detection_inference_async_n2(void) +{ + printf("Inside mv_object_detection_inference_async_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_object_detection_prepare() + ret = mv_object_detection_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_object_detection_inference_async_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_object_detection_get_result_count() + * @testcase utc_mediavision_mv_object_detection_get_result_count_p + * @since_tizen 9.0 + * @description Detect an object + */ +int utc_mediavision_mv_object_detection_get_result_count_p(void) +{ + printf("Inside mv_object_detection_get_result_count_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_object_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 2); + + printf("Before return mv_object_detection_get_result_count_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_get_result_count() + * @testcase utc_mediavision_mv_object_detection_get_result_count_n1 + * @since_tizen 9.0 + * @description Detect an object, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_object_detection_get_result_count_n1(void) +{ + printf("Inside mv_object_detection_get_result_count_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + unsigned long frame_number; + unsigned int cnt; + + // source is NULL + int ret = mv_object_detection_get_result_count(NULL, &frame_number, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // frame_number is NULL + ret = mv_object_detection_get_result_count(gInferenceHandle, NULL, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // result_cnt is NULL + ret = mv_object_detection_get_result_count(gInferenceHandle, &frame_number, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_object_detection_get_result_count_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_get_result_count() + * @testcase utc_mediavision_mv_object_detection_get_result_count_n2 + * @since_tizen 9.0 + * @description Detect an object, but fail because + * mv_object_detection_inference is not called. + */ +int utc_mediavision_mv_object_detection_get_result_count_n2(void) +{ + printf("Inside mv_object_detection_get_result_count_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_object_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_object_detection_get_result_count_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_object_detection_get_bound_box() + * @testcase utc_mediavision_mv_object_detection_get_bound_box_p + * @since_tizen 9.0 + * @description Detect an object + */ +int utc_mediavision_mv_object_detection_get_bound_box_p(void) +{ + printf("Inside mv_object_detection_get_bound_box_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_object_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 2); + + const int coordinate_answers[2][4] = { { 194, 27, 502, 298 }, { 12, 6, 164, 270 } }; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + int left, top, right, bottom; + + ret = mv_object_detection_get_bound_box(gInferenceHandle, idx, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + assert_eq(coordinate_answers[idx][0], left); + assert_eq(coordinate_answers[idx][1], top); + assert_eq(coordinate_answers[idx][2], right); + assert_eq(coordinate_answers[idx][3], bottom); + } + + printf("Before return mv_object_detection_get_bound_box_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_get_bound_box() + * @testcase utc_mediavision_mv_object_detection_get_bound_box_n1 + * @since_tizen 9.0 + * @description Detect an object, but fail because + * input parameter is NULL. + */ +int utc_mediavision_mv_object_detection_get_bound_box_n1(void) +{ + printf("Inside mv_object_detection_get_bound_box_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int left, top, right, bottom; + + // source is NULL + int ret = mv_object_detection_get_bound_box(NULL, 0, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // left is NULL + ret = mv_object_detection_get_bound_box(gInferenceHandle, 0, NULL, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // top is NULL + ret = mv_object_detection_get_bound_box(gInferenceHandle, 0, &left, NULL, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // right is NULL + ret = mv_object_detection_get_bound_box(gInferenceHandle, 0, &left, &top, NULL, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // bottom is NULL + ret = mv_object_detection_get_bound_box(gInferenceHandle, 0, &left, &top, &right, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // all are NULL + ret = mv_object_detection_get_bound_box(NULL, 0, NULL, NULL, NULL, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_object_detection_get_bound_box_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_get_bound_box() + * @testcase utc_mediavision_mv_object_detection_get_bound_box_n2 + * @since_tizen 9.0 + * @description Detect an object but fail because idx is wrong. + */ +int utc_mediavision_mv_object_detection_get_bound_box_n2(void) +{ + printf("Inside mv_object_detection_get_bound_box_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_object_detection_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 2); + + int left, top, right, bottom; + ret = mv_object_detection_get_bound_box(gInferenceHandle, 2, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_object_detection_get_bound_box_n2\n"); + return 0; +} + +/** + * @brief Negative test case of mv_object_detection_get_bound_box() + * @testcase utc_mediavision_mv_object_detection_get_bound_box_n3 + * @since_tizen 9.0 + * @description Detect an object but fail because + * mv_object_detection_get_result_count is not called. + */ +int utc_mediavision_mv_object_detection_get_bound_box_n3(void) +{ + printf("Inside mv_object_detection_get_bound_box_n3\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_object_detection_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + int left, top, right, bottom; + ret = mv_object_detection_get_bound_box(gInferenceHandle, 0, &left, &top, &right, &bottom); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_object_detection_get_bound_box_n3\n"); + return 0; +} diff --git a/src/utc/capi-media-vision-dl/utc-mv_pose_landmark.c b/src/utc/capi-media-vision-dl/utc-mv_pose_landmark.c new file mode 100644 index 000000000..c65d83c34 --- /dev/null +++ b/src/utc/capi-media-vision-dl/utc-mv_pose_landmark.c @@ -0,0 +1,979 @@ +/** + * 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 "assert.h" +#include + +#include +#include +#include +#include +#include + +#include "tct_common.h" +#include +#include +#include + +#define FILE_PATH_SIZE 1024 +#define MAX_INFERENCE_ITERATION 50 +#define API_NAMESPACE "[MediaVision]" +#define IMG_NAME "poseLandmark.jpg" + +static bool isVisionSupported = false; +static int gStartupError; + +static mv_pose_landmark_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +static void *pose_landmark_callback(void *user_data) +{ + mv_pose_landmark_h handle = (mv_pose_landmark_h) user_data; + const unsigned int coordinate_answers[][10] = { { 300, 300, 275, 250, 325, 325, 225, 225, 350, 375 }, + { 50, 87, 100, 137, 100, 137, 187, 250, 187, 250 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number; + unsigned int cnt; + + int ret = mv_pose_landmark_get_result_count(handle, &frame_number, &cnt); + if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION) + break; + + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + for (unsigned long idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + ret = mv_pose_landmark_get_position(handle, idx, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + + assert(distance_x <= 2 && distance_y <= 2); + } + } + return 0; +} + +static int load_image_to_media_source(const char *file_path, mv_source_h source) +{ + if (NULL == file_path || NULL == source) { + printf("File path or source is NULL\n"); + return MEDIA_VISION_ERROR_INVALID_PARAMETER; + } + + unsigned int width = 0; + unsigned int height = 0; + size_t buffer_size = 0; + unsigned char *data_buffer = NULL; + int ret1 = IMAGE_UTIL_ERROR_NONE; + int ret2 = MEDIA_VISION_ERROR_NONE; + image_util_decode_h _decoder = NULL; + image_util_image_h _decoded_image = NULL; + + ret1 = image_util_decode_create(&_decoder); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_input_path(_decoder, file_path); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_decode_run2(_decoder, &_decoded_image); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + ret1 = image_util_get_image(_decoded_image, &width, &height, NULL, &data_buffer, &buffer_size); + if (ret1 != IMAGE_UTIL_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_clear(source); + if (ret2 != MEDIA_VISION_ERROR_NONE) + goto _LOAD_IMAGE_FAIL; + + ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width, + (unsigned int) height, MEDIA_VISION_COLORSPACE_RGB888); + +_LOAD_IMAGE_FAIL: + image_util_decode_destroy(_decoder); + image_util_destroy_image(_decoded_image); + if (data_buffer) + free(data_buffer); + + assert_eq(IMAGE_UTIL_ERROR_NONE, ret1); + assert_eq(MEDIA_VISION_ERROR_NONE, ret2); + + return MEDIA_VISION_ERROR_NONE; +} + +/** + * @function utc_capi_mv_pose_landmark_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_pose_landmark_startup1(void) +{ + printf("capi-media-vision mv_pose_landmark tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + printf("capi-media-vision mv_pose_landmark tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_pose_landmark_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_pose_landmark_cleanup1(void) +{ + printf("capi-media-vision mv_pose_landmark tests CLEANUP is launched\n"); + printf("capi-media-vision mv_pose_landmark tests CLEANUP is completed\n"); +} + +/** + * @function utc_capi_mv_pose_landmark_startup + * @description Inference module UTC startup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_pose_landmark_startup2(void) +{ + printf("capi-media-vision mv_pose_landmark tests STARTUP is launched\n"); + + bool isInferenceSupported = true; + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + + if (isInferenceSupported) + isVisionSupported = true; + else + isVisionSupported = false; + + char pszValue[CONFIG_VALUE_LEN_MAX] = { + 0, + }; + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) { + PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, + pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", + pszValue); + + } else { + PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for " + "'DEVICE_SUITE_TARGET_30'\n", + __LINE__, API_NAMESPACE); + } + + gStartupError = mv_pose_landmark_create(&gInferenceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gInferenceHandle = NULL; + printf("mv_pose_landmark_h create is failed\n"); + return; + } + + gStartupError = mv_create_source(&gSourceHandle); + if (MEDIA_VISION_ERROR_NONE != gStartupError) { + gSourceHandle = NULL; + printf("mv_source_h create is failed\n"); + return; + } + + printf("capi-media-vision mv_pose_landmark tests STARTUP is completed\n"); +} + +/** + * @function utc_capi_mv_pose_landmark_cleanup + * @description Inference module UTC cleanup code + * @parameter NA + * @return NA + */ +void utc_capi_mv_pose_landmark_cleanup2(void) +{ + printf("capi-media-vision mv_pose_landmark tests CLEANUP is launched\n"); + + if (gInferenceHandle) { + mv_pose_landmark_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir) { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + printf("capi-media-vision mv_pose_landmark tests CLEANUP is completed\n"); +} + +/** + * @brief Positive test case of mv_pose_landmark_create_p() + * @testcase utc_mediavision_mv_pose_landmark_create_p + * @since_tizen 9.0 + * @description Create inference handle + */ +int utc_mediavision_mv_pose_landmark_create_p(void) +{ + printf("Inside mv_pose_landmark_create_p\n"); + + mv_pose_landmark_h inferenceHandle = NULL; + int ret = mv_pose_landmark_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_pose_landmark_create_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_create() + * @testcase utc_mediavision_mv_pose_landmark_create_n + * @since_tizen 9.0 + * @description Create inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_pose_landmark_create_n(void) +{ + printf("Inside mv_pose_landmark_create_n\n"); + + int ret = mv_pose_landmark_create(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_pose_landmark_create_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_pose_landmark_destroy_p() + * @testcase utc_mediavision_mv_pose_landmark_destroy_p + * @since_tizen 9.0 + * @description Destroy inference handle + */ +int utc_mediavision_mv_pose_landmark_destroy_p(void) +{ + printf("Inside mv_pose_landmark_destroy_p\n"); + + mv_pose_landmark_h inferenceHandle = NULL; + int ret = mv_pose_landmark_create(&inferenceHandle); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_destroy(inferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_pose_landmark_destroy_p\n"); + + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_destroy_n() + * @testcase utc_mediavision_mv_pose_landmark_destroy_n + * @since_tizen 9.0 + * @description Destroy inference handle, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_pose_landmark_destroy_n(void) +{ + printf("Inside mv_pose_landmark_destroy_n\n"); + + int ret = mv_pose_landmark_destroy(NULL); + if (!isVisionSupported) { + assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_pose_landmark_destroy_n\n"); + + return 0; +} + +/** + * @brief Positive test case of mv_pose_landmark_configure_p() + * @testcase utc_mediavision_mv_pose_landmark_configure_p + * @since_tizen 9.0 + * @description Configure inference handle + */ +int utc_mediavision_mv_pose_landmark_configure_p(void) +{ + printf("Inside mv_pose_landmark_configure_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_pose_landmark_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_configure_n() + * @testcase utc_mediavision_mv_pose_landmark_configure_n + * @since_tizen 9.0 + * @description Configure inference handle, + * but fail because input parameters are invalid + */ +int utc_mediavision_mv_pose_landmark_configure_n(void) +{ + printf("Inside mv_pose_landmark_configure_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_pose_landmark_configure(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_pose_landmark_configure_n1\n"); + return 0; +} + +/** + * @brief Positive test case of mv_pose_landmark_prepare_p() + * @testcase utc_mediavision_mv_pose_landmark_prepare_p + * @since_tizen 9.0 + * @description Prepare inference handle + */ +int utc_mediavision_mv_pose_landmark_prepare_p(void) +{ + printf("Inside mv_pose_landmark_prepare_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_pose_landmark_configure_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_prepare_n1() + * @testcase utc_mediavision_mv_pose_landmark_prepare_n1 + * @since_tizen 9.0 + * @description Prepare inference handle, + * but fail because input handle is NULL + */ +int utc_mediavision_mv_pose_landmark_prepare_n1(void) +{ + printf("Inside mv_pose_landmark_prepare_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_pose_landmark_prepare(NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_pose_landmark_prepare_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_prepare_n2() + * @testcase utc_mediavision_mv_pose_landmark_prepare_n2 + * @since_tizen 9.0 + * @description Prepare inference handle, but fail because + * mv_pose_landmark_configure is not called. + */ +int utc_mediavision_mv_pose_landmark_prepare_n2(void) +{ + printf("Inside mv_pose_landmark_prepare_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_pose_landmark_prepare_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_pose_landmark_inference() + * @testcase utc_mediavision_mv_pose_landmark_inference_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_pose_landmark_inference_p(void) +{ + printf("Inside mv_pose_landmark_inference_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + printf("Before return mv_pose_landmark_inference_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_inference() + * @testcase utc_mediavision_mv_pose_landmark_inference_n1 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_pose_landmark_inference_n1(void) +{ + printf("Inside mv_pose_landmark_inference_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_pose_landmark_inference(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_pose_landmark_inference(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_pose_landmark_inference(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_pose_landmark_inference_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_inference() + * @testcase utc_mediavision_mv_pose_landmark_inference_n2 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because mv_pose_landmark_prepare() isn't called before + */ +int utc_mediavision_mv_pose_landmark_inference_n2(void) +{ + printf("Inside mv_pose_landmark_inference_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_pose_landmark_prepare() + ret = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_pose_landmark_inference_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_pose_landmark_inference_async() + * @testcase utc_mediavision_mv_pose_landmark_inference_async_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_pose_landmark_inference_async_p(void) +{ + printf("Inside mv_pose_landmark_inference_async_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) { + ret = mv_pose_landmark_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + if (iter == 0) + pthread_create(&thread_id, NULL, pose_landmark_callback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + assert_eq(status, 0); + + printf("Before return mv_pose_landmark_inference_async_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_inference_async() + * @testcase utc_mediavision_mv_pose_landmark_inference_async_n1 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_pose_landmark_inference_async_n1(void) +{ + printf("Inside mv_pose_landmark_inference_async_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // source is NULL + ret = mv_pose_landmark_inference_async(gInferenceHandle, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // inference handle is NULL + ret = mv_pose_landmark_inference_async(NULL, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // both are NULL + ret = mv_pose_landmark_inference_async(NULL, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_pose_landmark_inference_async_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_inference_async() + * @testcase utc_mediavision_mv_pose_landmark_inference_async_n2 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because mv_pose_landmark_prepare() isn't called before + */ +int utc_mediavision_mv_pose_landmark_inference_async_n2(void) +{ + printf("Inside mv_pose_landmark_inference_async_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + // skip the mv_pose_landmark_prepare() + ret = mv_pose_landmark_inference_async(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret); + + printf("Before return mv_pose_landmark_inference_async_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_pose_landmark_get_result_count() + * @testcase utc_mediavision_mv_pose_landmark_get_result_count_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_pose_landmark_get_result_count_p(void) +{ + printf("Inside mv_pose_landmark_get_result_count_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_pose_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 10); + + printf("Before return mv_pose_landmark_get_result_count_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_get_result_count() + * @testcase utc_mediavision_mv_pose_landmark_get_result_count_n1 + * @since_tizen 9.0 + * @description Detect landmark position, + * but fail because input parameter is NULL + */ +int utc_mediavision_mv_pose_landmark_get_result_count_n1(void) +{ + printf("Inside mv_pose_landmark_get_result_count_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + unsigned long frame_number; + unsigned int cnt; + + // source is NULL + int ret = mv_pose_landmark_get_result_count(NULL, &frame_number, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // frame_number is NULL + ret = mv_pose_landmark_get_result_count(gInferenceHandle, NULL, &cnt); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + // result_cnt is NULL + ret = mv_pose_landmark_get_result_count(gInferenceHandle, &frame_number, NULL); + assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret); + + printf("Before return mv_pose_landmark_get_result_count_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_get_result_count() + * @testcase utc_mediavision_mv_pose_landmark_get_result_count_n2 + * @since_tizen 9.0 + * @description Detect landmark position, but fail because + * mv_pose_landmark_inference is not called. + */ +int utc_mediavision_mv_pose_landmark_get_result_count_n2(void) +{ + printf("Inside mv_pose_landmark_get_result_count_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_pose_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_pose_landmark_get_result_count_n2\n"); + return 0; +} + +/** + * @brief Positive test case of mv_pose_landmark_get_position() + * @testcase utc_mediavision_mv_pose_landmark_get_position_p + * @since_tizen 9.0 + * @description Detect landmark position + */ +int utc_mediavision_mv_pose_landmark_get_position_p(void) +{ + printf("Inside mv_pose_landmark_get_position_p\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_pose_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 10); + + const unsigned int coordinate_answers[][10] = { { 300, 300, 275, 250, 325, 325, 225, 225, 350, 375 }, + { 50, 87, 100, 137, 100, 137, 187, 250, 187, 250 } }; + + for (unsigned int idx = 0; idx < cnt; ++idx) { + unsigned int pos_x, pos_y; + + ret = mv_pose_landmark_get_position(gInferenceHandle, idx, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + + assert(distance_x <= 2 && distance_y <= 2); + } + + printf("Before return mv_pose_landmark_get_position_p\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_get_position() + * @testcase utc_mediavision_mv_pose_landmark_get_position_n1 + * @since_tizen 9.0 + * @description Detect landmark position, but fail because + * input parameter is NULL. + */ +int utc_mediavision_mv_pose_landmark_get_position_n1(void) +{ + printf("Inside mv_pose_landmark_get_position_n1\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + unsigned int pos_x, pos_y; + + // source is NULL + int ret = mv_pose_landmark_get_position(NULL, 0, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // pos_x is NULL + ret = mv_pose_landmark_get_position(gInferenceHandle, 0, NULL, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // pos_y is NULL + ret = mv_pose_landmark_get_position(gInferenceHandle, 0, &pos_x, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + // all are NULL + ret = mv_pose_landmark_get_position(NULL, 0, NULL, NULL); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_pose_landmark_get_position_n1\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_get_position() + * @testcase utc_mediavision_mv_pose_landmark_get_position_n2 + * @since_tizen 9.0 + * @description Detect landmark position but fail because idx is wrong. + */ +int utc_mediavision_mv_pose_landmark_get_position_n2(void) +{ + printf("Inside mv_pose_landmark_get_position_n2\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned long frame_number; + unsigned int cnt; + + ret = mv_pose_landmark_get_result_count(gInferenceHandle, &frame_number, &cnt); + assert_eq(ret, MEDIA_VISION_ERROR_NONE); + assert_eq(cnt, 10); + + unsigned int pos_x, pos_y; + ret = mv_pose_landmark_get_position(gInferenceHandle, 10, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_PARAMETER); + + printf("Before return mv_pose_landmark_get_position_n2\n"); + return 0; +} + +/** + * @brief Negative test case of mv_pose_landmark_get_position() + * @testcase utc_mediavision_mv_pose_landmark_get_position_n3 + * @since_tizen 9.0 + * @description Detect landmark position but fail because + * mv_pose_landmark_get_result_count is not called. + */ +int utc_mediavision_mv_pose_landmark_get_position_n3(void) +{ + printf("Inside mv_pose_landmark_get_position_n3\n"); + + if (!isVisionSupported) { + assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED); + return 0; + } + + char imageFilename[1024]; + + int ret = mv_pose_landmark_configure(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_prepare(gInferenceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + snprintf(imageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + ret = load_image_to_media_source(imageFilename, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + ret = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + assert_eq(MEDIA_VISION_ERROR_NONE, ret); + + unsigned int pos_x, pos_y; + ret = mv_pose_landmark_get_position(gInferenceHandle, 0, &pos_x, &pos_y); + assert_eq(ret, MEDIA_VISION_ERROR_INVALID_OPERATION); + + printf("Before return mv_pose_landmark_get_position_n3\n"); + return 0; +}