Skip to content
Snippets Groups Projects
Commit e92ce12e authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

interpolation configuration

parent 8d8c1fe5
No related branches found
No related tags found
No related merge requests found
Pipeline #28664 passed
......@@ -46,7 +46,8 @@ using std::chrono::milliseconds;
using std::this_thread::sleep_for;
OpenCVDevice::OpenCVDevice(nlohmann::json &config, bool stereo)
: ftl::rgbd::detail::Device(config), timestamp_(0.0) {
: ftl::rgbd::detail::Device(config), timestamp_(0.0),
interpolation_(cv::INTER_CUBIC) {
std::vector<ftl::rgbd::detail::DeviceDetails> devices_ = getDevices();
......@@ -147,6 +148,12 @@ OpenCVDevice::OpenCVDevice(nlohmann::json &config, bool stereo)
left_hm_ = cv::cuda::HostMem(dheight_, dwidth_, CV_8UC4);
right_hm_ = cv::cuda::HostMem(dheight_, dwidth_, CV_8UC4);
hres_hm_ = cv::cuda::HostMem(height_, width_, CV_8UC4);
interpolation_ = value("inter_cubic", false) ? cv::INTER_CUBIC : cv::INTER_LINEAR;
on("inter_cubic", [this](){
interpolation_ = value("inter_cubic_", false) ?
cv::INTER_CUBIC : cv::INTER_LINEAR;
});
}
OpenCVDevice::~OpenCVDevice() {
......@@ -355,7 +362,7 @@ bool OpenCVDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cud
if (hasHigherRes()) {
// TODO: Use threads?
cv::resize(rfull, r, r.size(), 0.0, 0.0, cv::INTER_CUBIC);
cv::resize(rfull, r, r.size(), 0.0, 0.0, interpolation_);
r_hres_out = rfull;
}
else {
......@@ -397,13 +404,13 @@ bool OpenCVDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cud
// Need to resize
//if (hasHigherRes()) {
// TODO: Use threads?
// cv::resize(rfull, r, r.size(), 0.0, 0.0, cv::INTER_CUBIC);
// cv::resize(rfull, r, r.size(), 0.0, 0.0, interpolation_);
//}
}
if (hasHigherRes()) {
//FTL_Profile("Frame Resize", 0.01);
cv::resize(lfull, l, l.size(), 0.0, 0.0, cv::INTER_CUBIC);
cv::resize(lfull, l, l.size(), 0.0, 0.0, interpolation_);
l_hres_out.upload(hres, stream);
} else {
l_hres_out = cv::cuda::GpuMat();
......
......@@ -62,6 +62,7 @@ class OpenCVDevice : public ftl::rgbd::detail::Device {
cv::Mat frame_l_;
cv::Mat frame_r_;
int interpolation_;
};
}
......
......@@ -24,7 +24,8 @@ using cv::Mat;
using namespace Pylon;
PylonDevice::PylonDevice(nlohmann::json &config)
: ftl::rgbd::detail::Device(config), ready_(false), lcam_(nullptr), rcam_(nullptr) {
: ftl::rgbd::detail::Device(config), ready_(false), lcam_(nullptr), rcam_(nullptr),
interpolation_(cv::INTER_CUBIC) {
auto &inst = CTlFactory::GetInstance();
......@@ -114,6 +115,12 @@ PylonDevice::PylonDevice(nlohmann::json &config)
});
on("buffer_size", buffer_size_, 1);
interpolation_ = value("inter_cubic", false) ? cv::INTER_CUBIC : cv::INTER_LINEAR;
on("inter_cubic", [this](){
interpolation_ = value("inter_cubic", false) ?
cv::INTER_CUBIC : cv::INTER_LINEAR;
});
}
PylonDevice::~PylonDevice() {
......@@ -298,7 +305,7 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda
c->rectify(rfull, Channel::Right);
if (hasHigherRes()) {
cv::resize(rfull, r, r.size(), 0.0, 0.0, cv::INTER_CUBIC);
cv::resize(rfull, r, r.size(), 0.0, 0.0, interpolation_);
h_r = rfull;
}
else {
......@@ -338,7 +345,7 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda
}
if (hasHigherRes()) {
cv::resize(lfull, l, l.size(), 0.0, 0.0, cv::INTER_CUBIC);
cv::resize(lfull, l, l.size(), 0.0, 0.0, interpolation_);
h_l.upload(hres, stream);
} else {
h_l = cv::cuda::GpuMat();
......
......@@ -57,6 +57,7 @@ class PylonDevice : public ftl::rgbd::detail::Device {
cv::cuda::HostMem right_hm_;
cv::cuda::HostMem hres_hm_;
cv::Mat rtmp_;
int interpolation_;
void _configureCamera(Pylon::CBaslerUniversalInstantCamera *cam);
bool _retrieveFrames(Pylon::CGrabResultPtr &result, Pylon::CBaslerUniversalInstantCamera *cam);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment