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

Image display utility function

parent b1a8b51e
No related branches found
No related tags found
No related merge requests found
Pipeline #33028 passed
......@@ -14,6 +14,7 @@ set(COMMONSRC
src/exception.cpp
src/file.cpp
src/utility/base64.cpp
src/utility/image_debug.cpp
)
check_function_exists(uriParseSingleUriA HAVE_URIPARSESINGLE)
......
#ifndef _FTL_UTILITY_IMAGE_DEBUG_HPP_
#define _FTL_UTILITY_IMAGE_DEBUG_HPP_
namespace ftl {
namespace utility {
enum class ImageVisualisation {
RAW_COLOUR,
RAW_GRAY,
NORMALISED_FLOAT,
HEAT_MAPPED
};
void show_image(
const cv::cuda::GpuMat &m,
const std::string &name,
float scale,
ImageVisualisation iv);
}
}
#endif
\ No newline at end of file
#include <ftl/utility/image_debug.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/cudaimgproc.hpp>
#include <opencv2/highgui.hpp>
void ftl::utility::show_image(
const cv::cuda::GpuMat &m,
const std::string &name,
float scale,
ImageVisualisation iv
) {
cv::Mat tmp;
m.download(tmp);
if (scale != 1.0f) {
cv::resize(tmp, tmp, cv::Size(float(tmp.cols)*scale, float(tmp.rows)*scale));
}
// Must do some conversion.
if (tmp.type() == CV_32F) {
}
if (iv == ftl::utility::ImageVisualisation::HEAT_MAPPED) {
#if OPENCV_VERSION >= 40102
cv::applyColorMap(tmp, tmp, cv::COLORMAP_TURBO);
#else
cv::applyColorMap(tmp, tmp, cv::COLORMAP_INFERNO);
#endif
}
cv::imshow(name, tmp);
cv::waitKey(1);
}
......@@ -2,6 +2,7 @@
#include "ftl/operators/disparity.hpp"
#include <ftl/operators/cuda/disparity.hpp>
#include <ftl/utility/image_debug.hpp>
#include <opencv2/cudaimgproc.hpp>
#include <opencv2/cudaarithm.hpp>
......@@ -215,6 +216,8 @@ bool FixstarsSGM::apply(Frame &in, Frame &out, cudaStream_t stream) {
cv::cuda::normalize(weightsF_, weightsF_, minweight, 1.0, cv::NORM_MINMAX, -1, cv::noArray(), cvstream);
weightsF_.convertTo(weights_, CV_8UC1, 255.0f, cvstream);
//ftl::utility::show_image(weights_, "VarWeight", 0.5f, ftl::utility::ImageVisualisation::HEAT_MAPPED);
//if ((int)P2_map_.step != P2_map_.cols) LOG(ERROR) << "P2 map step error: " << P2_map_.cols << "," << P2_map_.step;
ssgm_->execute(lbw_.data, rbw_.data, disp_int_.data, P2_map_.data, (uint8_t*) weights_.data, weights_.step1(), config()->value("min_disp", 60), stream);
} else {
......
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