forked from ucla-vision/xivo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make the estimator a singleton so that other modules can ac…
…cess it without being fed with the estimator
- Loading branch information
Showing
8 changed files
with
115 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// factory method to create a system | ||
#include "param.h" | ||
#include "camera_manager.h" | ||
#include "mm.h" | ||
#include "tracker.h" | ||
#include "graph.h" | ||
#include "estimator.h" | ||
|
||
#ifdef USE_G2O | ||
#include "optimizer.h" | ||
#endif | ||
|
||
namespace xivo { | ||
|
||
EstimatorPtr CreateSystem(const Json::Value &cfg) { | ||
static bool system_created{false}; | ||
|
||
if (system_created) { | ||
return Estimator::instance(); | ||
} | ||
|
||
// Initialize paramter server | ||
ParameterServer::Create(cfg); | ||
LOG(INFO) << "Parameter server created"; | ||
|
||
// Load camera parameters | ||
auto cam_cfg = cfg["camera_cfg"].isString() | ||
? LoadJson(cfg["camera_cfg"].asString()) | ||
: cfg["camera_cfg"]; | ||
Camera::Create(cam_cfg); | ||
LOG(INFO) << "Camera created"; | ||
|
||
// Initialize memory manager | ||
MemoryManager::Create(cfg["memory"].get("max_features", 256).asInt(), | ||
cfg["memory"].get("max_groups", 128).asInt()); | ||
LOG(INFO) << "Memory management unit created"; | ||
|
||
// Initialize tracker | ||
auto tracker_cfg = cfg["tracker_cfg"].isString() | ||
? LoadJson(cfg["tracker_cfg"].asString()) | ||
: cfg["tracker_cfg"]; | ||
Tracker::Create(tracker_cfg); | ||
LOG(INFO) << "Tracker created"; | ||
|
||
// Initialize the visibility graph | ||
Graph::Create(); | ||
LOG(INFO) << "Visibility graph created"; | ||
|
||
#ifdef USE_G2O | ||
// Initialize the optimizer | ||
Optimizer::Create(cfg["optimizer"]); | ||
LOG(INFO) << "Optimizer created"; | ||
#endif | ||
|
||
// Initialize the estimator | ||
Estimator::Create(cfg); | ||
LOG(INFO) << "Estimator created"; | ||
|
||
system_created = true; | ||
|
||
return Estimator::instance(); | ||
} | ||
|
||
|
||
} // namespace xivo |