{
"name" : "MV_FACE_DETECTION_MODEL_FILE_PATH",
"type" : "string",
- "value" : "/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml",
+ "value" : "/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml"
},
{
"name" : "MV_FACE_DETECTION_ROI_X",
"type" : "integer",
- "value" : -1,
+ "value" : -1
},
{
"name" : "MV_FACE_DETECTION_ROI_Y",
"type" : "integer",
- "value" : -1,
+ "value" : -1
},
{
"name" : "MV_FACE_DETECTION_ROI_WIDTH",
"type" : "integer",
- "value" : -1,
+ "value" : -1
},
{
"name" : "MV_FACE_DETECTION_ROI_HEIGHT",
"type" : "integer",
- "value" : -1,
+ "value" : -1
},
{
"name" : "MV_FACE_DETECTION_MIN_SIZE_WIDTH",
"type" : "integer",
- "value" : -1,
+ "value" : -1
},
{
"name" : "MV_FACE_DETECTION_MIN_SIZE_HEIGHT",
"type" : "integer",
- "value" : -1,
+ "value" : -1
},
{ "name" : "MV_BARCODE_GENERATE_ATTR_TEXT",
"type" : "integer",
- "value" : 0,
+ "value" : 0
},
{
"name" : "MV_BARCODE_DETECT_ATTR_TARGET",
"type" : "integer",
- "value" : 0,
+ "value" : 0
},
{
"name" : "MV_IMAGE_RECOGNITION_OBJECT_SCALE_FACTOR",
"type" : "double",
- "value" : 1.2,
+ "value" : 1.2
},
{
"name" : "MV_IMAGE_RECOGNITION_OBJECT_MAX_KEYPOINTS_NUM",
"type" : "integer",
- "value" : 1000,
+ "value" : 1000
},
{
"name" : "MV_IMAGE_RECOGNITION_SCENE_SCALE_FACTOR",
"type" : "double",
- "value" : 1.2,
+ "value" : 1.2
},
{
"name" : "MV_IMAGE_RECOGNITION_SCENE_MAX_KEYPOINTS_NUM",
"type" : "integer",
- "value" : 5000,
+ "value" : 5000
},
{
"name" : "MV_IMAGE_RECOGNITION_MIN_MATCH_NUM",
"type" : "integer",
- "value" : 30,
+ "value" : 30
},
{
"name" : "MV_IMAGE_RECOGNITION_REQ_MATCH_PART",
"type" : "double",
- "value" : 0.05,
+ "value" : 0.05
},
{
"name" : "MV_IMAGE_RECOGNITION_TOLERANT_MATCH_PART_ERR",
"type" : "double",
- "value" : 0.1,
+ "value" : 0.1
},
{
"name" : "MV_IMAGE_TRACKING_HISTORY_AMOUNT",
"type" : "integer",
- "value" : 3,
+ "value" : 3
},
{
"name" : "MV_IMAGE_TRACKING_EXPECTED_OFFSET",
"type" : "double",
- "value" : 0,
+ "value" : 0
},
{
"name" : "MV_IMAGE_TRACKING_USE_STABLIZATION",
"type" : "boolean",
- "value" : false,
+ "value" : false
},
{
"name" : "MV_IMAGE_TRACKING_STABLIZATION_TOLERANT_SHIFT",
"type" : "double",
- "value" : 0.006,
+ "value" : 0.006
},
{
"name" : "MV_IMAGE_TRACKING_STABLIZATION_SPEED",
"type" : "double",
- "value" : 2,
+ "value" : 2
},
{
"name" : "MV_IMAGE_TRACKING_STABLIZATION_ACCELERATION",
"type" : "double",
- "value" : 0.001,
+ "value" : 0.001
},
{
"name" : "MV_FACE_RECOGNITION_MODEL_TYPE",
"type" : "integer",
- "value" : 3,
+ "value" : 3
}
]
}
#include <mv_private.h>
-#include <json/json.h>
+#include <json-glib/json-glib.h>
/**
* @file EngineConfig.cpp
DefBoolDict.clear();
DefStrDict.clear();
- json_object *jobj = json_object_from_file(configFilePath.c_str());
+ const char *conf_file = configFilePath.c_str();
+ JsonParser *parser;
+ GError *error = NULL;
- enum json_type type = json_object_get_type(jobj);
- if (json_type_object != type)
+ parser = json_parser_new();
+ json_parser_load_from_file(parser, conf_file, &error);
+ if (error)
{
- LOGE("Can't parse engine config file. Incorrect json markup. "
- "Supported attributes can't be determined.");
- json_object_put(jobj);
+ LOGW("Unable to parse file '%s': %s\n", conf_file, error->message);
+ g_error_free(error);
+ g_object_unref(parser);
return MEDIA_VISION_ERROR_NO_DATA;
}
- json_object *pAttributesObj = json_object_object_get(jobj, "attributes");
- type = json_object_get_type(pAttributesObj);
- if (json_type_array != type)
+ JsonNode *root = json_parser_get_root(parser);
+ if (JSON_NODE_OBJECT != json_node_get_node_type(root))
{
- LOGE("Can't parse engine config file. Incorrect json markup. "
- "Supported attributes can't be determined.");
- json_object_put(jobj);
+ LOGW("Can't parse tests configuration file. "
+ "Incorrect json markup.");
+ g_object_unref(parser);
return MEDIA_VISION_ERROR_NO_DATA;
}
- const int attrNum = json_object_array_length(pAttributesObj);
+ JsonObject *jobj = json_node_get_object(root);
- for (int attrInd = 0; attrInd < attrNum; ++attrInd)
+ if (!json_object_has_member(jobj, "attributes"))
{
- json_object *pAttrObj =
- json_object_array_get_idx(pAttributesObj, attrInd);
- type = json_object_get_type(pAttrObj);
-
- json_object *pAttrNameObj = NULL;
- json_object *pAttrTypeObj = NULL;
- json_object *pAttrValueObj = NULL;
-
- if (json_type_object != type ||
- !json_object_object_get_ex(pAttrObj, "name", &pAttrNameObj) ||
- !json_object_object_get_ex(pAttrObj, "type", &pAttrTypeObj) ||
- !json_object_object_get_ex(pAttrObj, "value", &pAttrValueObj))
+ LOGW("Can't parse tests configuration file. "
+ "No 'attributes' section.");
+ g_object_unref(parser);
+ return MEDIA_VISION_ERROR_NO_DATA;
+ }
+
+ JsonNode *attr_node =
+ json_object_get_member(jobj, "attributes");
+
+ if (JSON_NODE_ARRAY != json_node_get_node_type(attr_node))
+ {
+ LOGW("Can't parse tests configuration file. "
+ "'attributes' section isn't array.");
+ g_object_unref(parser);
+ return MEDIA_VISION_ERROR_NO_DATA;
+ }
+
+ JsonArray *attr_array = json_node_get_array(attr_node);
+
+ const guint attr_num = json_array_get_length(attr_array);
+
+ guint attrInd = 0;
+ for (; attrInd < attr_num; ++attrInd)
+ {
+ JsonNode *attr_node = json_array_get_element(attr_array, attrInd);
+
+ if (JSON_NODE_OBJECT != json_node_get_node_type(attr_node))
+ {
+ LOGW("Attribute %u wasn't parsed from json file.", attrInd);
+ continue;
+ }
+
+ JsonObject *attr_obj = json_node_get_object(attr_node);
+
+ if (!json_object_has_member(attr_obj, "name") ||
+ !json_object_has_member(attr_obj, "type") ||
+ !json_object_has_member(attr_obj, "value"))
{
- LOGW("Attribute %i wasn't parsed from json file.", attrInd);
+ LOGW("Attribute %u wasn't parsed from json file.", attrInd);
continue;
}
- const char *nameStr = json_object_get_string(pAttrNameObj);
- const char *typeStr = json_object_get_string(pAttrTypeObj);
+ const char *nameStr =
+ (char*)json_object_get_string_member(attr_obj, "name");
+ const char *typeStr =
+ (char*)json_object_get_string_member(attr_obj, "type");
- if (0 == strcmp("double", typeStr))
+ if (NULL == nameStr || NULL == typeStr)
+ {
+ LOGW("Attribute %i wasn't parsed from json file. name and/or "
+ "type of the attribute are parsed as NULL.", attrInd);
+ continue;
+ }
+ else if (0 == strcmp("double", typeStr))
{
DefDblDict[std::string(nameStr)] =
- json_object_get_double(pAttrValueObj);
+ (double)json_object_get_double_member(attr_obj, "value");
}
else if (0 == strcmp("integer", typeStr))
{
DefIntDict[std::string(nameStr)] =
- json_object_get_int(pAttrValueObj);
+ (int)json_object_get_int_member(attr_obj, "value");
}
else if (0 == strcmp("boolean", typeStr))
{
DefBoolDict[std::string(nameStr)] =
- json_object_get_boolean(pAttrValueObj) ? true : false;
+ json_object_get_boolean_member(attr_obj, "value") ? true : false;
}
else if (0 == strcmp("string", typeStr))
{
DefStrDict[std::string(nameStr)] =
- json_object_get_string(pAttrValueObj);
+ (char*)json_object_get_string_member(attr_obj, "value");
}
else
{
- LOGW("Attribute %i:%s wasn't parsed from json file. Type isn't supported.", attrInd, nameStr);
+ LOGW("Attribute %i:%s wasn't parsed from json file. "
+ "Type isn't supported.", attrInd, nameStr);
continue;
}
}
- json_object_put(jobj);
+ g_object_unref(parser);
isCached = true;
}