Skip to content

Commit

Permalink
Removed Excess information from json.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Nov 13, 2020
1 parent 1215d04 commit 34aabcc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/KeyFrameBBox.cpp
Expand Up @@ -381,13 +381,13 @@ Json::Value KeyFrameBBox::JsonValue() {
root["boxes"] = Json::Value(Json::arrayValue);

// loop through points
for (auto const& x : BoxVec){
/*for (auto const& x : BoxVec){
Json::Value elem;
elem["key"] = x.first;
elem["val"] = x.second.JsonValue();
root["boxes"].append(elem);
}

*/

root["delta_x"] = delta_x.JsonValue();
root["delta_y"] = delta_y.JsonValue();
Expand Down Expand Up @@ -445,7 +445,7 @@ void KeyFrameBBox::SetJsonValue(const Json::Value root) {
if (!root["TimeScale"].isNull()) {
this->TimeScale = (double) root["TimeScale"].asDouble();
}

/*
if (!root["boxes"].isNull()){
// loop through points
for (const auto existing_point : root["boxes"]) {
Expand All @@ -456,5 +456,6 @@ void KeyFrameBBox::SetJsonValue(const Json::Value root) {
BoxVec.insert({existing_point["key"].asDouble(), box});
}
}
*/
return;
}
17 changes: 10 additions & 7 deletions src/effects/Tracker.cpp
Expand Up @@ -207,6 +207,16 @@ void Tracker::SetJsonValue(const Json::Value root) {

// Set parent data
EffectBase::SetJsonValue(root);

if (!root["BaseFPS"].isNull() && root["BaseFPS"].isObject()) {
if (!root["BaseFPS"]["num"].isNull())
BaseFPS.num = (int) root["BaseFPS"]["num"].asInt();
if (!root["BaseFPS"]["den"].isNull())
BaseFPS.den = (int) root["BaseFPS"]["den"].asInt();
}

trackedData.SetBaseFPS(this->BaseFPS);

// Set data from Json (if key is found)
if (!root["protobuf_data_path"].isNull()){
protobuf_data_path = (root["protobuf_data_path"].asString());
Expand All @@ -216,13 +226,6 @@ void Tracker::SetJsonValue(const Json::Value root) {
protobuf_data_path = "";
}
}

if (!root["BaseFPS"].isNull() && root["BaseFPS"].isObject()) {
if (!root["BaseFPS"]["num"].isNull())
BaseFPS.num = (int) root["BaseFPS"]["num"].asInt();
if (!root["BaseFPS"]["den"].isNull())
BaseFPS.den = (int) root["BaseFPS"]["den"].asInt();
}
}

// Get all properties for a specific frame
Expand Down
5 changes: 1 addition & 4 deletions tests/KeyFrame_Tests.cpp
Expand Up @@ -587,11 +587,8 @@ TEST(KeyFrameBBox_Json_set) {
KeyFrameBBox from_json;
from_json.SetJson(data);

BBox val = kfb.GetValue(0);
BBox val_json = from_json.GetValue(0);

std::cout << from_json.Json() << std::endl;

CHECK_EQUAL(val.cx, val_json.cx);
CHECK_EQUAL(kfb.GetBaseFPS().num, from_json.GetBaseFPS().num);
}

0 comments on commit 34aabcc

Please sign in to comment.