Skip to content
Snippets Groups Projects
Commit dbcfe76a authored by Nicolas Pope's avatar Nicolas Pope
Browse files

WIP Config resolve changes

parent 1011818f
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,9 @@ class CUDARayCastSDF : public ftl::Configurable
{
public:
CUDARayCastSDF(nlohmann::json& config) : ftl::Configurable(config) {
create(parametersFromConfig(config));
hash_render_ = config.value("hash_renderer", false);
auto &cfg = ftl::config::resolve(config);
create(parametersFromConfig(cfg));
hash_render_ = cfg.value("hash_renderer", false);
}
~CUDARayCastSDF(void) {
......
......@@ -54,22 +54,23 @@ class SceneRep : public ftl::Configurable {
}
static HashParams parametersFromConfig(nlohmann::json &config) {
auto &cfg = ftl::config::resolve(config);
HashParams params;
// First camera view is set to identity pose to be at the centre of
// the virtual coordinate space.
params.m_rigidTransform.setIdentity();
params.m_rigidTransformInverse.setIdentity();
params.m_hashNumBuckets = config["hashNumBuckets"];
params.m_hashNumBuckets = cfg["hashNumBuckets"];
params.m_hashBucketSize = HASH_BUCKET_SIZE;
params.m_hashMaxCollisionLinkedListSize = config["hashMaxCollisionLinkedListSize"];
params.m_hashMaxCollisionLinkedListSize = cfg["hashMaxCollisionLinkedListSize"];
params.m_SDFBlockSize = SDF_BLOCK_SIZE;
params.m_numSDFBlocks = config["hashNumSDFBlocks"];
params.m_virtualVoxelSize = config["SDFVoxelSize"];
params.m_maxIntegrationDistance = config["SDFMaxIntegrationDistance"];
params.m_truncation = config["SDFTruncation"];
params.m_truncScale = config["SDFTruncationScale"];
params.m_integrationWeightSample = config["SDFIntegrationWeightSample"];
params.m_integrationWeightMax = config["SDFIntegrationWeightMax"];
params.m_numSDFBlocks = cfg["hashNumSDFBlocks"];
params.m_virtualVoxelSize = cfg["SDFVoxelSize"];
params.m_maxIntegrationDistance = cfg["SDFMaxIntegrationDistance"];
params.m_truncation = cfg["SDFTruncation"];
params.m_truncScale = cfg["SDFTruncationScale"];
params.m_integrationWeightSample = cfg["SDFIntegrationWeightSample"];
params.m_integrationWeightMax = cfg["SDFIntegrationWeightMax"];
// Note (Nick): We are not streaming voxels in/out of GPU
//params.m_streamingVoxelExtents = MatrixConversion::toCUDA(gas.s_streamingVoxelExtents);
//params.m_streamingGridDimensions = MatrixConversion::toCUDA(gas.s_streamingGridDimensions);
......
......@@ -104,7 +104,7 @@ T *ftl::config::create(json_t &link, ARGS ...args) {
template <typename T, typename... ARGS>
T *ftl::config::create(ftl::Configurable *parent, const std::string &name, ARGS ...args) {
//nlohmann::json &entity = ftl::config::resolve(parent->getConfig()[name]);
nlohmann::json &entity = (parent->getConfig()[name].is_structured()) ? parent->getConfig()[name] : ftl::config::resolve(parent->getConfig())[name];
nlohmann::json &entity = (!parent->getConfig()[name].is_null()) ? parent->getConfig()[name] : ftl::config::resolve(parent->getConfig())[name];
if (entity.is_object()) {
if (!entity["$id"].is_string()) {
......
......@@ -132,7 +132,7 @@ static pcl::PointCloud<pcl::PointXYZRGB>::Ptr rgbdToPointXYZ(const cv::Mat &rgb,
bool Display::render(const cv::Mat &rgb, const cv::Mat &depth, const ftl::rgbd::CameraParameters &p) {
Mat idepth;
if (config_["points"] && rgb.rows != 0) {
if (value("points", false) && rgb.rows != 0) {
#if defined HAVE_PCL
auto pc = rgbdToPointXYZ(rgb, depth, p);
......@@ -166,15 +166,15 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth, const ftl::rgbd::
#endif // HAVE_VIZ
}
if (config_["left"]) {
if (config_["crosshair"]) {
if (value("left", false)) {
if (value("crosshair", false)) {
cv::line(rgb, cv::Point(0, rgb.rows/2), cv::Point(rgb.cols-1, rgb.rows/2), cv::Scalar(0,0,255), 1);
cv::line(rgb, cv::Point(rgb.cols/2, 0), cv::Point(rgb.cols/2, rgb.rows-1), cv::Scalar(0,0,255), 1);
}
cv::namedWindow("Left: " + name_, cv::WINDOW_KEEPRATIO);
cv::imshow("Left: " + name_, rgb);
}
if (config_["right"]) {
if (value("right", false)) {
/*if (config_["crosshair"]) {
cv::line(rgbr, cv::Point(0, rgbr.rows/2), cv::Point(rgbr.cols-1, rgbr.rows/2), cv::Scalar(0,0,255), 1);
cv::line(rgbr, cv::Point(rgbr.cols/2, 0), cv::Point(rgbr.cols/2, rgbr.rows-1), cv::Scalar(0,0,255), 1);
......@@ -183,7 +183,7 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth, const ftl::rgbd::
cv::imshow("Right: " + name_, rgbr);*/
}
if (config_["disparity"]) {
if (value("disparity", false)) {
/*Mat depth32F = (focal * (float)l.cols * base_line) / depth;
normalize(depth32F, depth32F, 0, 255, NORM_MINMAX, CV_8U);
cv::imshow("Depth", depth32F);
......@@ -191,8 +191,8 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth, const ftl::rgbd::
//exit if ESC is pressed
active_ = false;
}*/
} else if (config_["depth"]) {
if ((bool)config_["flip_vert"]) {
} else if (value("depth", false)) {
if (value("flip_vert", false)) {
cv::flip(depth, idepth, 0);
} else {
idepth = depth;
......@@ -228,7 +228,7 @@ bool Display::render(const cv::Mat &img, style_t s) {
} else if (s = STYLE_DISPARITY) {
Mat idepth;
if ((bool)config_["flip_vert"]) {
if (value("flip_vert", false)) {
cv::flip(img, idepth, 0);
} else {
idepth = img;
......@@ -244,7 +244,7 @@ bool Display::render(const cv::Mat &img, style_t s) {
}
void Display::wait(int ms) {
if (config_["points"]) {
if (value("points", false)) {
#if defined HAVE_PCL
if (pclviz_) pclviz_->spinOnce(20);
#elif defined HAVE_VIZ
......@@ -252,7 +252,7 @@ void Display::wait(int ms) {
#endif // HAVE_VIZ
}
if (config_["depth"] || config_["left"] || config_["right"]) {
if (value("depth", false) || value("left", false) || value("right", false)) {
while (true) {
int key = cv::waitKey(ms);
......
......@@ -18,7 +18,7 @@ Disparity::Disparity(nlohmann::json &config)
max_disp_(value("maximum", 256)) {}
Disparity *Disparity::create(ftl::Configurable *parent, const std::string &name) {
nlohmann::json &config = ftl::config::resolve(parent->getConfig()[name]);
nlohmann::json &config = ftl::config::resolve((!parent->getConfig()[name].is_null()) ? parent->getConfig()[name] : ftl::config::resolve(parent->getConfig())[name]); // ftl::config::resolve(parent->getConfig()[name]);
//auto alg = parent->get<std::string>("algorithm");
if (!config["algorithm"].is_string()) {
......
......@@ -53,12 +53,13 @@ bool RGBDSource::snapshot(const std::string &fileprefix) {
}
RGBDSource *RGBDSource::create(nlohmann::json &config, ftl::net::Universe *net) {
if (config["type"].type_name() != "string") {
LOG(ERROR) << "Missing RGB-D source type: " << config["type"].type_name();
auto &cfg = ftl::config::resolve(config);
if (cfg["type"].type_name() != "string") {
LOG(ERROR) << "Missing RGB-D source type: " << cfg["type"].type_name();
//return nullptr;
}
if (sources__->count(config["type"].get<string>()) != 1) return nullptr;
return (*sources__)[config["type"].get<string>()](config, net);
if (sources__->count(cfg["type"].get<string>()) != 1) return nullptr;
return (*sources__)[cfg["type"].get<string>()](config, net);
}
void RGBDSource::_register(const std::string &n,
......
......@@ -75,7 +75,7 @@ StereoVideoSource::StereoVideoSource(nlohmann::json &config, const string &file)
mask_l_ = (mask_l == 0);
disp_ = Disparity::create(this, "disparity");
if (!disp_) LOG(FATAL) << "Unknown disparity algorithm : " << config["disparity"];
if (!disp_) LOG(FATAL) << "Unknown disparity algorithm : " << *get<ftl::config::json_t>("disparity");
LOG(INFO) << "StereoVideo source ready...";
ready_ = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment