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

Allow vis of energy channel

parent 71d9e8db
No related branches found
No related tags found
1 merge request!90Implement #150 splat resizing
Pipeline #12715 passed
...@@ -222,6 +222,7 @@ void ftl::gui::Camera::showSettings() { ...@@ -222,6 +222,7 @@ void ftl::gui::Camera::showSettings() {
void ftl::gui::Camera::setChannel(ftl::rgbd::channel_t c) { void ftl::gui::Camera::setChannel(ftl::rgbd::channel_t c) {
channel_ = c; channel_ = c;
switch (c) { switch (c) {
case ftl::rgbd::kChanEnergy:
case ftl::rgbd::kChanFlow: case ftl::rgbd::kChanFlow:
case ftl::rgbd::kChanConfidence: case ftl::rgbd::kChanConfidence:
case ftl::rgbd::kChanNormals: case ftl::rgbd::kChanNormals:
...@@ -255,6 +256,19 @@ static void visualizeDepthMap( const cv::Mat &depth, cv::Mat &out, ...@@ -255,6 +256,19 @@ static void visualizeDepthMap( const cv::Mat &depth, cv::Mat &out,
out.setTo(cv::Scalar(255, 255, 255), mask); out.setTo(cv::Scalar(255, 255, 255), mask);
} }
static void visualizeEnergy( const cv::Mat &depth, cv::Mat &out,
const float max_depth)
{
DCHECK(max_depth > 0.0);
depth.convertTo(out, CV_8U, 255.0f / max_depth);
//out = 255 - out;
cv::Mat mask = (depth >= 39.0f); // TODO (mask for invalid pixels)
applyColorMap(out, out, cv::COLORMAP_JET);
out.setTo(cv::Scalar(255, 255, 255), mask);
}
static void drawEdges( const cv::Mat &in, cv::Mat &out, static void drawEdges( const cv::Mat &in, cv::Mat &out,
const int ksize = 3, double weight = -1.0, const int threshold = 32, const int ksize = 3, double weight = -1.0, const int threshold = 32,
const int threshold_type = cv::THRESH_TOZERO) const int threshold_type = cv::THRESH_TOZERO)
...@@ -303,6 +317,11 @@ const GLTexture &ftl::gui::Camera::captureFrame() { ...@@ -303,6 +317,11 @@ const GLTexture &ftl::gui::Camera::captureFrame() {
cv::Mat tmp; cv::Mat tmp;
switch(channel_) { switch(channel_) {
case ftl::rgbd::kChanEnergy:
if (depth.rows == 0) { break; }
visualizeEnergy(depth, tmp, 10.0);
texture_.update(tmp);
break;
case ftl::rgbd::kChanDepth: case ftl::rgbd::kChanDepth:
if (depth.rows == 0) { break; } if (depth.rows == 0) { break; }
visualizeDepthMap(depth, tmp, 7.0); visualizeDepthMap(depth, tmp, 7.0);
......
...@@ -184,6 +184,15 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""), ...@@ -184,6 +184,15 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""),
} }
}); });
button = new Button(popup, "Energy");
button->setFlags(Button::RadioButton);
button->setCallback([this]() {
ftl::gui::Camera *cam = screen_->activeCamera();
if (cam) {
cam->setChannel(ftl::rgbd::kChanEnergy);
}
});
} }
MediaPanel::~MediaPanel() { MediaPanel::~MediaPanel() {
......
...@@ -95,6 +95,16 @@ void Splatter::render(ftl::rgbd::Source *src, cudaStream_t stream) { ...@@ -95,6 +95,16 @@ void Splatter::render(ftl::rgbd::Source *src, cudaStream_t stream) {
ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream); ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream);
src->writeFrames(colour1_, depth2_, stream); src->writeFrames(colour1_, depth2_, stream);
} }
} else if (src->getChannel() == ftl::rgbd::kChanEnergy) {
//ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream);
//if (src->value("splatting", false)) {
//ftl::cuda::splat_points(depth1_, colour1_, normal1_, depth2_, colour2_, params, stream);
//ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream);
src->writeFrames(colour1_, depth2_, stream);
//} else {
//ftl::cuda::int_to_float(depth1_, depth2_, 1.0f / 1000.0f, stream);
// src->writeFrames(colour1_, depth2_, stream);
//}
} else if (src->getChannel() == ftl::rgbd::kChanRight) { } else if (src->getChannel() == ftl::rgbd::kChanRight) {
// Adjust pose to right eye position // Adjust pose to right eye position
Eigen::Affine3f transform(Eigen::Translation3f(camera.baseline,0.0f,0.0f)); Eigen::Affine3f transform(Eigen::Translation3f(camera.baseline,0.0f,0.0f));
......
...@@ -21,11 +21,12 @@ static const channel_t kChanDeviation = 0x0010; ...@@ -21,11 +21,12 @@ static const channel_t kChanDeviation = 0x0010;
static const channel_t kChanNormals = 0x0020; static const channel_t kChanNormals = 0x0020;
static const channel_t kChanConfidence = 0x0040; static const channel_t kChanConfidence = 0x0040;
static const channel_t kChanFlow = 0x0080; static const channel_t kChanFlow = 0x0080;
static const channel_t kChanEnergy = 0x0100;
static const channel_t kChanOverlay1 = 0x1000; static const channel_t kChanOverlay1 = 0x1000;
inline bool isFloatChannel(ftl::rgbd::channel_t chan) { inline bool isFloatChannel(ftl::rgbd::channel_t chan) {
return (chan == ftl::rgbd::kChanDepth); return (chan == ftl::rgbd::kChanDepth || chan == ftl::rgbd::kChanEnergy);
} }
......
...@@ -101,6 +101,8 @@ Streamer::Streamer(nlohmann::json &config, Universe *net) ...@@ -101,6 +101,8 @@ Streamer::Streamer(nlohmann::json &config, Universe *net)
net->bind("set_channel", [this](const string &uri, unsigned int chan) { net->bind("set_channel", [this](const string &uri, unsigned int chan) {
SHARED_LOCK(mutex_,slk); SHARED_LOCK(mutex_,slk);
LOG(INFO) << "SET CHANNEL " << chan;
if (sources_.find(uri) != sources_.end()) { if (sources_.find(uri) != sources_.end()) {
sources_[uri]->src->setChannel((ftl::rgbd::channel_t)chan); sources_[uri]->src->setChannel((ftl::rgbd::channel_t)chan);
} }
......
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