Fixing protobuf loading bug, preventing tracker and object detection from loading correctly.

This commit is contained in:
Jonathan Thomas
2025-08-12 17:46:56 -05:00
parent 523fb5acf9
commit adff81fefc
2 changed files with 27 additions and 21 deletions

View File

@@ -362,11 +362,14 @@ void ObjectDetection::SetJsonValue(const Json::Value root)
EffectBase::SetJsonValue(root);
// If a protobuf path is provided, load & prefix IDs
if (!root["protobuf_data_path"].isNull() && protobuf_data_path.empty()) {
protobuf_data_path = root["protobuf_data_path"].asString();
if (!LoadObjDetectdData(protobuf_data_path)) {
throw InvalidFile("Invalid protobuf data path", "");
}
if (!root["protobuf_data_path"].isNull()) {
std::string new_path = root["protobuf_data_path"].asString();
if (protobuf_data_path != new_path || trackedObjects.empty()) {
protobuf_data_path = new_path;
if (!LoadObjDetectdData(protobuf_data_path)) {
throw InvalidFile("Invalid protobuf data path", "");
}
}
}
// Selected index, thresholds, UI flags, filters, etc.

View File

@@ -220,22 +220,25 @@ void Tracker::SetJsonValue(const Json::Value root) {
TimeScale = root["TimeScale"].asDouble();
}
if (!root["protobuf_data_path"].isNull() && protobuf_data_path.empty()) {
protobuf_data_path = root["protobuf_data_path"].asString();
if (!trackedData->LoadBoxData(protobuf_data_path)) {
std::clog << "Invalid protobuf data path " << protobuf_data_path << '\n';
protobuf_data_path.clear();
}
else {
// prefix "<effectUUID>-<index>" for each entry
for (auto& kv : trackedObjects) {
auto idx = kv.first;
auto ptr = kv.second;
if (ptr) {
std::string prefix = this->Id();
if (!prefix.empty())
prefix += "-";
ptr->Id(prefix + std::to_string(idx));
if (!root["protobuf_data_path"].isNull()) {
std::string new_path = root["protobuf_data_path"].asString();
if (protobuf_data_path != new_path || trackedData->GetLength() == 0) {
protobuf_data_path = new_path;
if (!trackedData->LoadBoxData(protobuf_data_path)) {
std::clog << "Invalid protobuf data path " << protobuf_data_path << '\n';
protobuf_data_path.clear();
}
else {
// prefix "<effectUUID>-<index>" for each entry
for (auto& kv : trackedObjects) {
auto idx = kv.first;
auto ptr = kv.second;
if (ptr) {
std::string prefix = this->Id();
if (!prefix.empty())
prefix += "-";
ptr->Id(prefix + std::to_string(idx));
}
}
}
}