"/usr/share/capi-media-vision/models/PLD/mocap/example-mocap-mapping.txt"
//Hand Pose Detection
-#define PE_TFLITE_AIC_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1.tflite"
-#define PE_TFLITE_AIC_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_b_1.tflite"
-//#define PE_TFLITE_AIC_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1_tf113_int32.tflite"
-//#define PE_TFLITE_AIC_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_b_1_tf113.tflite"
+#define PE_TFLITE_AICLite_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1_lite_224.tflite"
+#define PE_TFLITE_AICLite_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_lite_224.tflite"
+
+#define PE_TFLITE_AICLite2_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1_0709_f.tflite"
+#define PE_TFLITE_AICLite2_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_0709_f.tflite"
+
+#define PE_TFLITE_AICLite2Q_1_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet1_0709_dq.tflite"
+#define PE_TFLITE_AICLite2Q_2_WEIGHT_PATH "/usr/share/capi-media-vision/models/PE/tflite/posenet2_0709_f.tflite"
+
+int gHandModelOption = 0;
/******
* Public model:
return;
}
-int perform_tflite_hand_detection2(mv_engine_config_h *engine_cfg)
+int perform_tflite_AICLite_hand_detection2(mv_engine_config_h *engine_cfg)
+{
+ int err = MEDIA_VISION_ERROR_NONE;
+
+ mv_engine_config_h handle = NULL;
+ err = mv_create_engine_config(&handle);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to create engine configuration handle.\n");
+ if (handle) {
+ int err2 = mv_destroy_engine_config(handle);
+ if (err2 != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to destroy engine cofniguration.\n");
+ }
+ }
+ return err;
+ }
+
+ char *inputNodeName = "input";
+ char *outputNodeNames[2] = {"mobilenetv2/coord_refine", "mobilenetv2/gesture"};
+
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+ PE_TFLITE_AICLite_2_WEIGHT_PATH);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_DATA_TYPE,
+ MV_INFERENCE_DATA_FLOAT32);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_MEAN_VALUE,
+ 0.0);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_STD_VALUE,
+ 1.0);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_BACKEND_TYPE,
+ MV_INFERENCE_BACKEND_TFLITE);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_TARGET_DEVICE_TYPE,
+ MV_INFERENCE_TARGET_DEVICE_CPU);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_WIDTH,
+ 56);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+ 56);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_CHANNELS,
+ 21);
+
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_INPUT_NODE_NAME,
+ inputNodeName);
+
+ mv_engine_config_set_array_string_attribute(handle,
+ MV_INFERENCE_OUTPUT_NODE_NAMES,
+ outputNodeNames,
+ 2);
+
+ *engine_cfg = handle;
+ return err;
+}
+
+int perform_tflite_AICLite2_hand_detection2(mv_engine_config_h *engine_cfg)
+{
+ int err = MEDIA_VISION_ERROR_NONE;
+
+ mv_engine_config_h handle = NULL;
+ err = mv_create_engine_config(&handle);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to create engine configuration handle.\n");
+ if (handle) {
+ int err2 = mv_destroy_engine_config(handle);
+ if (err2 != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to destroy engine cofniguration.\n");
+ }
+ }
+ return err;
+ }
+
+ char *inputNodeName = "input";
+ char *outputNodeNames[2] = {"mobilenetv2/coord_refine", "mobilenetv2/gesture"};
+
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+ PE_TFLITE_AICLite2_2_WEIGHT_PATH);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_DATA_TYPE,
+ MV_INFERENCE_DATA_FLOAT32);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_MEAN_VALUE,
+ 0.0);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_STD_VALUE,
+ 1.0);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_BACKEND_TYPE,
+ MV_INFERENCE_BACKEND_TFLITE);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_TARGET_DEVICE_TYPE,
+ MV_INFERENCE_TARGET_DEVICE_CPU);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_WIDTH,
+ 56);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+ 56);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_CHANNELS,
+ 21);
+
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_INPUT_NODE_NAME,
+ inputNodeName);
+
+ mv_engine_config_set_array_string_attribute(handle,
+ MV_INFERENCE_OUTPUT_NODE_NAMES,
+ outputNodeNames,
+ 2);
+
+ *engine_cfg = handle;
+ return err;
+}
+
+int perform_tflite_AICLite2Q_hand_detection2(mv_engine_config_h *engine_cfg)
{
int err = MEDIA_VISION_ERROR_NONE;
mv_engine_config_set_string_attribute(handle,
MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
- PE_TFLITE_AIC_2_WEIGHT_PATH);
+ PE_TFLITE_AICLite2Q_2_WEIGHT_PATH);
mv_engine_config_set_int_attribute(handle,
MV_INFERENCE_INPUT_DATA_TYPE,
void _hand_pose_cb (
mv_source_h source,
const int number_of_pose_estimation,
- const mv_point_s *locations,
+ const mv_inference_pose_s *locations,
void *user_data)
{
printf("In callback, %d pose estimation\n", number_of_pose_estimation);
if (!user_data) {
for (int n = 0; n < number_of_pose_estimation; n++) {
- printf("%d: x[%d], y[%d]\n", n, locations[n].x, locations[n].y);
+ printf("%d: x[%d], y[%d]\n", n, locations->landmarks[n].point.x, locations->landmarks[n].point.y);
}
} else {
printf("%p\n", user_data);
mv_engine_config_h engine_cfg2;
mv_create_engine_config(&engine_cfg2);
- perform_tflite_hand_detection2(&engine_cfg2);
+ if (gHandModelOption == 2) {
+ perform_tflite_AICLite_hand_detection2(&engine_cfg2);
+ } else if (gHandModelOption == 3) {
+ perform_tflite_AICLite2_hand_detection2(&engine_cfg2);
+ } else if (gHandModelOption == 4) {
+ perform_tflite_AICLite2Q_hand_detection2(&engine_cfg2);
+ } else {
+ printf("Invalid operation\n");
+ }
mv_inference_h infer2;
int err = mv_inference_create(&infer2);
if (err != MEDIA_VISION_ERROR_NONE) {
printf("Fail to create inference handle [err:%i]\n", err);
}
- printf("infer2 created\n");
//configure
err = mv_inference_configure(infer2, engine_cfg2);
if (err != MEDIA_VISION_ERROR_NONE) {
printf("Fail to configure inference handle [err:%i]\n", err);
}
- printf("engine_cfg2 configured\n");
//prepare
err = mv_inference_prepare(infer2);
- printf("infer2 prepared\n");
err = mv_inference_pose_landmark_detect(source2, infer2, NULL, _hand_pose_cb, (&source));
- printf("pose estimated\n");
mv_destroy_source(source2);
- printf("destroy source2");
mv_inference_destroy(infer2);
mv_destroy_engine_config(engine_cfg2);
}
-int perform_tflite_hand_detection(mv_engine_config_h *engine_cfg)
+int perform_tflite_AICLite_hand_detection(mv_engine_config_h *engine_cfg)
+{
+ int err = MEDIA_VISION_ERROR_NONE;
+
+ mv_engine_config_h handle = NULL;
+ err = mv_create_engine_config(&handle);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to create engine configuration handle.\n");
+ if (handle) {
+ int err2 = mv_destroy_engine_config(handle);
+ if (err2 != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to destroy engine cofniguration.\n");
+ }
+ }
+ return err;
+ }
+
+ char *inputNodeName = "input";
+ char *outputNodeNames[2] = {"mobilenetv2/boundingbox2", "mobilenetv2/heatmap"};
+
+ outputTensorData = (void*)calloc(56*56*21, sizeof(float));
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+ PE_TFLITE_AICLite_1_WEIGHT_PATH);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_DATA_TYPE,
+ MV_INFERENCE_DATA_FLOAT32);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_MEAN_VALUE,
+ 0.0);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_STD_VALUE,
+ 1.0);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_BACKEND_TYPE,
+ MV_INFERENCE_BACKEND_TFLITE);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_TARGET_DEVICE_TYPE,
+ MV_INFERENCE_TARGET_DEVICE_CPU);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_WIDTH,
+ 224);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+ 224);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_CHANNELS,
+ 3);
+
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_INPUT_NODE_NAME,
+ inputNodeName);
+
+ mv_engine_config_set_array_string_attribute(handle,
+ MV_INFERENCE_OUTPUT_NODE_NAMES,
+ outputNodeNames,
+ 2);
+
+ *engine_cfg = handle;
+ return err;
+}
+
+int perform_tflite_AICLite2_hand_detection(mv_engine_config_h *engine_cfg)
{
int err = MEDIA_VISION_ERROR_NONE;
outputTensorData = (void*)calloc(56*56*21, sizeof(float));
mv_engine_config_set_string_attribute(handle,
MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
- PE_TFLITE_AIC_1_WEIGHT_PATH);
+ PE_TFLITE_AICLite2_1_WEIGHT_PATH);
mv_engine_config_set_int_attribute(handle,
MV_INFERENCE_INPUT_DATA_TYPE,
return err;
}
+int perform_tflite_AICLite2Q_hand_detection(mv_engine_config_h *engine_cfg)
+{
+ int err = MEDIA_VISION_ERROR_NONE;
+
+ mv_engine_config_h handle = NULL;
+ err = mv_create_engine_config(&handle);
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to create engine configuration handle.\n");
+ if (handle) {
+ int err2 = mv_destroy_engine_config(handle);
+ if (err2 != MEDIA_VISION_ERROR_NONE) {
+ printf("Fail to destroy engine cofniguration.\n");
+ }
+ }
+ return err;
+ }
+
+ char *inputNodeName = "input";
+ char *outputNodeNames[2] = {"mobilenetv2/boundingbox2", "mobilenetv2/heatmap"};
+
+ outputTensorData = (void*)calloc(56*56*21, sizeof(float));
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+ PE_TFLITE_AICLite2Q_1_WEIGHT_PATH);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_DATA_TYPE,
+ MV_INFERENCE_DATA_UINT8);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_MEAN_VALUE,
+ 0.0);
+
+ mv_engine_config_set_double_attribute(handle,
+ MV_INFERENCE_MODEL_STD_VALUE,
+ 1.0);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_BACKEND_TYPE,
+ MV_INFERENCE_BACKEND_TFLITE);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_TARGET_DEVICE_TYPE,
+ MV_INFERENCE_TARGET_DEVICE_CPU);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_WIDTH,
+ 224);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+ 224);
+
+ mv_engine_config_set_int_attribute(handle,
+ MV_INFERENCE_INPUT_TENSOR_CHANNELS,
+ 3);
+
+ mv_engine_config_set_string_attribute(handle,
+ MV_INFERENCE_INPUT_NODE_NAME,
+ inputNodeName);
+
+ mv_engine_config_set_array_string_attribute(handle,
+ MV_INFERENCE_OUTPUT_NODE_NAMES,
+ outputNodeNames,
+ 2);
+
+ *engine_cfg = handle;
+ return err;
+}
+
int perform_hand_detection()
{
int err = MEDIA_VISION_ERROR_NONE;
int sel_opt = 0;
- const int options[] = {1, 2, 3, 4, 5};
+ const int options[] = {1, 2, 3, 4, 5, 6, 7};
const *names[] = { "Configuration",
- "TFLITE(CPU) + HandDetection",
+ "TFLITE(CPU) + AIC-Lite",
+ "TFLITE(CPU) + AIC-Lite2",
+ "TFLITE(CPU) + AIC-Lite2Q",
"Prepare",
"Run",
"Back"};
if (err2 != MEDIA_VISION_ERROR_NONE)
printf("Fail to destroy engine_cfg [err:%i]\n", err2);
}
- err = perform_tflite_hand_detection(&engine_cfg);
+ err = perform_tflite_AICLite_hand_detection(&engine_cfg);
+ gHandModelOption = 2;
}
break;
case 3:
+ {
+ //perform pose estimation config
+ if (engine_cfg) {
+ int err2 = mv_destroy_engine_config(engine_cfg);
+ if (err2 != MEDIA_VISION_ERROR_NONE)
+ printf("Fail to destroy engine_cfg [err:%i]\n", err2);
+ }
+ err = perform_tflite_AICLite2_hand_detection(&engine_cfg);
+ gHandModelOption = 3;
+ }
+ break;
+ case 4:
+ {
+ //perform pose estimation config
+ if (engine_cfg) {
+ int err2 = mv_destroy_engine_config(engine_cfg);
+ if (err2 != MEDIA_VISION_ERROR_NONE)
+ printf("Fail to destroy engine_cfg [err:%i]\n", err2);
+ }
+ err = perform_tflite_AICLite2Q_hand_detection(&engine_cfg);
+ gHandModelOption = 4;
+ }
+ break;
+ case 5:
{
// create - configure - prepare
if (infer) {
}
}
break;
- case 4:
+ case 6:
{
if (mvSource) {
int err2 = mv_destroy_source(mvSource);
clock_gettime(CLOCK_MONOTONIC, &s_tspec);
// Hand detection
- //err = mv_inference_hand_detect(mvSource, infer, _hand_detected_cb, NULL);
-
printf("mem: %p\n", outputTensorData);
- //err = mv_inference_pose_estimation_detect(mvSource, infer, NULL, _hand_pose_cb, outputTensorData);
err = mv_inference_hand_detect(mvSource, infer, _hand_detected_cb, outputTensorData);
clock_gettime(CLOCK_MONOTONIC, &e_tspec);
break;
}
- case 5:
+ case 7:
{
//perform destroy
if (engine_cfg) {