test: Integrate stream_infer test apps with one
authorInki Dae <inki.dae@samsung.com>
Fri, 25 Sep 2020 07:03:28 +0000 (16:03 +0900)
committerInki Dae <inki.dae@samsung.com>
Fri, 25 Sep 2020 07:03:28 +0000 (16:03 +0900)
Change-Id: I9d7b29b9d5d8b5c41bf6439166a58ce5e8a226ba
Signed-off-by: Inki Dae <inki.dae@samsung.com>
test/testsuites/stream_infer/CMakeLists.txt
test/testsuites/stream_infer/stream_infer.c

index 9be8aace2c357aaeb5fa61b0e98f2957b0540572..5fb1ece005022ab73693b732887ab5071e0ef419 100644 (file)
@@ -17,9 +17,7 @@ include_directories(${INC_IMAGE_HELPER})
 include_directories(${INC_VIDEO_HELPER})
 include_directories(${INC_TS_COMMON})
 
-set(TFLITE_TEST mv_stream_infer_tflite)
-set(MLAPI_TEST mv_stream_infer_mlapi)
-set(ARMNN_TEST mv_stream_infer_armnn)
+set(BIN_NAME mv_stream_infer)
 
 find_package(PkgConfig REQUIRED)
 pkg_check_modules(GLIB_PKG glib-2.0)
@@ -34,64 +32,20 @@ endif()
 SET(dependents "gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 cairo elementary ecore-wl2 appcore-efl capi-ui-efl-util")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(${TFLITE_TEST} REQUIRED ${dependents})
-pkg_check_modules(${MLAPI_TEST} REQUIRED ${dependents})
-FOREACH(flag ${${TFLITE_TEST}_CFLAGS})
-  SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-FOREACH(flag ${${MLAPI_TEST}_CFLAGS})
+pkg_check_modules(${BIN_NAME} REQUIRED ${dependents})
+FOREACH(flag ${${BIN_NAME}_CFLAGS})
   SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
 SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -DEFL_BETA_API_SUPPORT=1")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
-add_executable(${TFLITE_TEST}
+add_executable(${BIN_NAME}
                           ${PROJECT_SOURCE_DIR}/stream_infer/stream_infer_common_util.c
                           ${PROJECT_SOURCE_DIR}/stream_infer/stream_infer.c
                           ${MV_CAPI_MEDIA_VISION_INC_LIST})
 
-target_link_libraries(${TFLITE_TEST} ${MV_INFERENCE_LIB_NAME}
-                                      gstreamer-1.0
-                                      glib-2.0
-                                      capi-system-info
-                                      dlog
-                                      mv_image_helper
-                                      mv_video_helper
-                                      mv_testsuite_common
-                                      cairo
-                                      m
-                                                                         ${${TFLITE_TEST}_LIBRARIES}
-                                                                         )
-
-install(TARGETS ${TFLITE_TEST} DESTINATION ${testbin_dir})
-
-add_executable(${MLAPI_TEST}
-                          ${PROJECT_SOURCE_DIR}/stream_infer/stream_infer_common_util.c
-                          ${PROJECT_SOURCE_DIR}/stream_infer/stream_infer_mlapi.c
-                          ${MV_CAPI_MEDIA_VISION_INC_LIST})
-
-target_link_libraries(${MLAPI_TEST} ${MV_INFERENCE_LIB_NAME}
-                                      gstreamer-1.0
-                                      glib-2.0
-                                      capi-system-info
-                                      dlog
-                                      mv_image_helper
-                                      mv_video_helper
-                                      mv_testsuite_common
-                                      cairo
-                                      m
-                                                                         ${${MLAPI_TEST}_LIBRARIES}
-                                                                         )
-
-install(TARGETS ${MLAPI_TEST} DESTINATION ${testbin_dir})
-
-add_executable(${ARMNN_TEST}
-                          ${PROJECT_SOURCE_DIR}/stream_infer/stream_infer_common_util.c
-                          ${PROJECT_SOURCE_DIR}/stream_infer/stream_infer_armnn.c
-                          ${MV_CAPI_MEDIA_VISION_INC_LIST})
-
-target_link_libraries(${ARMNN_TEST} ${MV_INFERENCE_LIB_NAME}
+target_link_libraries(${BIN_NAME} ${MV_INFERENCE_LIB_NAME}
                                       gstreamer-1.0
                                       glib-2.0
                                       capi-system-info
@@ -101,7 +55,7 @@ target_link_libraries(${ARMNN_TEST} ${MV_INFERENCE_LIB_NAME}
                                       mv_testsuite_common
                                       cairo
                                       m
-                                                                         ${${TFLITE_TEST}_LIBRARIES}
+                                                                         ${${BIN_NAME}_LIBRARIES}
                                                                          )
 
-install(TARGETS ${ARMNN_TEST} DESTINATION ${testbin_dir})
+install(TARGETS ${BIN_NAME} DESTINATION ${testbin_dir})
index f09ad118dc82658e1d123aea2d25a2ee04a8b9db..d7fdfef52779bcfb0554462e0946ee4c1dddb544 100644 (file)
@@ -95,6 +95,8 @@ typedef struct {
        gchar *filename2;
        int numbuffers;
        int modelType;
+       int backendType;
+       int deviceType;
        Evas_Object *win;
        Evas_Object *layout_main;       /* layout widget based on EDJ */
        /* add more variables here */
@@ -114,19 +116,19 @@ static guint bus_watch_id;
 #define PE_POSE_LABEL_PATH "/usr/share/capi-media-vision/models/PLD/tflite/pose-label.txt"
 
 
-#define PE_TFLITE_AIC_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1_lite_224.tflite"
-#define PE_TFLITE_AIC_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_lite_224.tflite"
+#define PE_TFLITE_AIC_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite"
+#define PE_TFLITE_AIC_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite"
 
 
-#define PE_TFLITE_AICLite_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1_0709_f.tflite"
-#define PE_TFLITE_AICLite_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_0709_f.tflite"
+#define PE_TFLITE_AICLite_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_0709_f.tflite"
+#define PE_TFLITE_AICLite_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_0709_f.tflite"
 
-#define PE_TFLITE_AICLiteQ_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1_0709_dq.tflite"
-#define PE_TFLITE_AICLiteQ_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_0709_f.tflite"
+#define PE_TFLITE_AICLiteQ_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_0709_dq.tflite"
+#define PE_TFLITE_AICLiteQ_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_0709_f.tflite"
 
 
-#define PE_TFLITE_AICLite3_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/0831_posenet1_q.tflite"
-#define PE_TFLITE_AICLite3_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/0831_posenet2_q.tflite"
+#define PE_TFLITE_AICLite3_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_1/tflite/0831_posenet1_q.tflite"
+#define PE_TFLITE_AICLite3_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE_2/tflite/0831_posenet2_q.tflite"
 
 
 #define PLD_MOTION_CAPTURE_FILE_PATH "/usr/share/capi-media-vision/models/PLD/mocap/example.bvh"
@@ -226,6 +228,19 @@ static bool IsGestureMode;
 
 static int poseCropSize = 0;
 
+#define MAX_BACKEND_TYPE       3
+const static int gBackendType[MAX_BACKEND_TYPE] = {
+       MV_INFERENCE_BACKEND_TFLITE,
+       MV_INFERENCE_BACKEND_ARMNN,
+       MV_INFERENCE_BACKEND_ONE
+};
+
+#define MAX_DEVICE_TYPE                2
+const static int gDeviceType[MAX_DEVICE_TYPE] = {
+       MV_INFERENCE_TARGET_DEVICE_CPU,
+       MV_INFERENCE_TARGET_DEVICE_GPU
+};
+
 #define IMAGE_SIZE_WIDTH 640
 #define IMAGE_SIZE_HEIGHT 480
 
@@ -836,11 +851,11 @@ int perform_armnn_human_pose_cpm_configure(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_ARMNN);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
-                        MV_INFERENCE_TARGET_TYPE,
-                        MV_INFERENCE_TARGET_GPU);
+                        MV_INFERENCE_TARGET_DEVICE_TYPE,
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -899,11 +914,11 @@ int perform_tflite_human_pose_cpm_configure(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
-                        MV_INFERENCE_TARGET_TYPE,
-                        MV_INFERENCE_TARGET_CPU);
+                        MV_INFERENCE_TARGET_DEVICE_TYPE,
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -937,7 +952,7 @@ int perform_tflite_hand_detection_AIC(mv_engine_config_h mv_engine_cfg)
        }
 
     char *inputNodeName = "input";
-    char *outputNodeNames[2] = {"mobilenetv2/boundingbox2", "mobilenetv2/heatmap"};
+    char *outputNodeNames[2] = {"mobilenetv2/boundingbox", "mobilenetv2/heatmap"};
 
     //outputTensorData = (void*)calloc(56*56*21, sizeof(float));
     mv_engine_config_set_string_attribute(mv_engine_cfg,
@@ -958,11 +973,11 @@ int perform_tflite_hand_detection_AIC(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1011,11 +1026,11 @@ int perform_tflite_hand_detection_AIC2(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1070,11 +1085,11 @@ int perform_tflite_hand_detection_AICLite3_1(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1123,11 +1138,11 @@ int perform_tflite_hand_detection_AICLite3_2(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1182,11 +1197,11 @@ int perform_tflite_hand_detection_AICLite(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1235,11 +1250,11 @@ int perform_tflite_hand_detection_AICLite2(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1294,11 +1309,11 @@ int perform_tflite_hand_detection_AICLiteQ(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1347,11 +1362,11 @@ int perform_tflite_hand_detection_AICLiteQ2(mv_engine_config_h mv_engine_cfg)
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_BACKEND_TYPE,
-                        MV_INFERENCE_BACKEND_TFLITE);
+                        gBackendType[ad.backendType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_TARGET_DEVICE_TYPE,
-                        MV_INFERENCE_TARGET_DEVICE_CPU);
+                        gDeviceType[ad.deviceType]);
 
     mv_engine_config_set_int_attribute(mv_engine_cfg,
                         MV_INFERENCE_INPUT_TENSOR_WIDTH,
@@ -1976,29 +1991,38 @@ struct appcore_ops ops = {
        .terminate = app_terminate,
 };
 
+static void show_test_setting(void)
+{
+       printf("Backend : %s\n", ad.backendType == 0 ? "TFLITE" :
+                       ad.backendType == 1 ? "ARMNN" : "ONE");
+       printf("Device : %s\n", ad.deviceType == 0 ? "CPU" : "GPU");
+}
+
 int main (int argc, char *argv[])
 {
        memset(&ad, 0x0, sizeof(appdata));
        ops.data = &ad;
 
-       if (argc >= 6) {
-               ad.filename = g_strdup(argv[5]);
+       if (argc >= 8) {
+               ad.filename = g_strdup(argv[7]);
                printf("launch with file source (%s)\n", ad.filename);
-               if (argc > 6) {
-                       ad.filename2 = g_strdup(argv[6]);
+               if (argc > 8) {
+                       ad.filename2 = g_strdup(argv[8]);
                        ad.numbuffers = -1;
                        printf("records output(%s)\n", ad.filename2);
                }
-               if (argc > 7) {
-                       ad.numbuffers = atoi(argv[7]);
+               if (argc > 9) {
+                       ad.numbuffers = atoi(argv[9]);
                }
        } else {
                printf("launch with camera source\n");
        }
 
-       if (argc < 2) {
-               printf("usage: mv_stream_infer model [thPoseScore, thResetCount, thCustom, [filename]]");
+       if (argc < 4) {
+               printf("usage: mv_stream_infer model backend device [thPoseScore, thResetCount, thCustom, [filename]]");
                printf("model: 0(CPM), 1(AIC Hand), 2(AIC Lite Hand), 3(AIC Lite Q Hand)\n");
+               printf("backend: 0(TFLITE), 1(ARMNN), 2(ONE)\n");
+               printf("device: 0(CPU), 1(GPU)\n");
                return -1;
        }
 
@@ -2008,21 +2032,37 @@ int main (int argc, char *argv[])
                return -1;
        }
 
+       ad.backendType = atoi(argv[2]);
+       if (ad.backendType < 0 || ad.backendType > 2) {
+               printf("not supported backend type [%d]\n", ad.backendType);
+               printf("0(TFLITE), 1(ARMNN) or 2(ONE) are valid.\n");
+               return -1;
+       }
+
+       ad.deviceType = atoi(argv[3]);
+       if (ad.deviceType < 0 || ad.deviceType > 1) {
+               printf("not supported device type [%d]\n", ad.backendType);
+               printf("0(CPU) and 1(GPU) are valid.\n");
+               return -1;
+       }
+
+       show_test_setting();
+
        if (ad.modelType != MODEL_TYPE_POSE_HAND_AICLite &&
                ad.modelType != MODEL_TYPE_POSE_HAND_AICLite2 &&
                ad.modelType != MODEL_TYPE_POSE_HAND_AICLite2Q &&
                ad.modelType != MODEL_TYPE_POSE_HAND_AICLite3) {
-               thPoseScore = (float)atoi(argv[2])/100.f;
-               thResetCount = atoi(argv[3]);
-               thCustom = (float)atoi(argv[4])/100.f;
+               thPoseScore = (float)atoi(argv[4])/100.f;
+               thResetCount = atoi(argv[5]);
+               thCustom = (float)atoi(argv[6])/100.f;
 
                poseRoi.point.x = 50;
                poseRoi.point.y = 0;
                poseRoi.width = 100;
                poseRoi.height = 192;
        } else {
-               if (argc > 2) {
-                       ad.filename2 = g_strdup(argv[2]);
+               if (argc > 4) {
+                       ad.filename2 = g_strdup(argv[4]);
                }
                poseRoi.point.x = 0;
                poseRoi.point.y = 0;