Skip to content

Commit

Permalink
feat: make undistort algorithm parameter configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
seixasxbr committed Jan 27, 2025
1 parent f387d64 commit a701038
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions camera_base.orogen
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ task_context "Task", subclasses: "Base" do
doc "The camera_format is converted into this format before it is written to the output port "
"Set it to MODE_UNDEFINED if you want to disable the conversion and the camera_format shall be used"

property("resize_algorithm","/frame_helper/ResizeAlgorithm",:INTER_LINEAR).
property("resize_algorithm","/frame_helper/InterpolationAlgorithm",:INTER_LINEAR).
doc "resize algorithm which is used to scale the frame before it is written to the output port. "
"allowed values are INTER_LINEAR, INTER_NEAREST, INTER_AREA, INTER_CUBIC, INTER_LANCZOS4, BAYER_RESIZE"

Expand Down Expand Up @@ -208,6 +208,10 @@ task_context "Preprocess", subclasses: "Base" do
input_port('iframe', ro_ptr('base::samples::frame::Frame'))
output_port 'oframe', ro_ptr('base::samples::frame::Frame')

property("undistort_algorithm","/frame_helper/InterpolationAlgorithm",:INTER_LINEAR).
doc "interpolation algorithm which is used to undistort the frame before it is written to the output port. "
"allowed values are INTER_LINEAR, INTER_NEAREST, INTER_AREA, INTER_CUBIC, INTER_LANCZOS4, BAYER_RESIZE"

property("undistort","bool",false).
doc 'true => undistort the image before it is written to the output port'

Expand All @@ -218,7 +222,7 @@ task_context "Preprocess", subclasses: "Base" do
doc "The image is converted into this format before it is written to the output port "
"Set it to MODE_UNDEFINED if you want to disable the conversion."

property("resize_algorithm","/frame_helper/ResizeAlgorithm",:INTER_LINEAR).
property("resize_algorithm","/frame_helper/InterpolationAlgorithm",:INTER_LINEAR).
doc "resize algorithm which is used to scale the frame before it is written to the output port. "
"allowed values are INTER_LINEAR, INTER_NEAREST, INTER_AREA, INTER_CUBIC, INTER_LANCZOS4, BAYER_RESIZE"

Expand Down
4 changes: 3 additions & 1 deletion tasks/Preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bool Preprocess::configureHook()
return false;
if (_undistort.value())
frame_helper.setCalibrationParameter(_calibration_parameters.value());
m_undistort_algorithm = _undistort_algorithm.get();
return true;
}

Expand Down Expand Up @@ -58,7 +59,8 @@ void Preprocess::updateHook()
_offset_x.value(),
_offset_y.value(),
_resize_algorithm.value(),
_undistort.value());
_undistort.value(),
m_undistort_algorithm);
}
catch (std::runtime_error e) {
RTT::log(RTT::Error) << "processing error: " << e.what() << RTT::endlog();
Expand Down
2 changes: 2 additions & 0 deletions tasks/Preprocess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "camera_base/PreprocessBase.hpp"
#include "frame_helper/FrameHelper.h"
#include "frame_helper/FrameHelperTypes.h"

namespace camera_base {

Expand Down Expand Up @@ -32,6 +33,7 @@ namespace camera_base {
protected:
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> oframe;
frame_helper::FrameHelper frame_helper; // helper for image processing
frame_helper::InterpolationAlgorithm m_undistort_algorithm;

public:
/** TaskContext constructor for Preprocess
Expand Down

0 comments on commit a701038

Please sign in to comment.