Skip to content

Commit

Permalink
chore: indent code
Browse files Browse the repository at this point in the history
  • Loading branch information
seixasxbr committed Jan 27, 2025
1 parent 4099d5c commit f387d64
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 39 deletions.
41 changes: 22 additions & 19 deletions tasks/Preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ using namespace camera_base;
using namespace base::samples::frame;

Preprocess::Preprocess(std::string const& name)
: PreprocessBase(name),
oframe(new Frame())
: PreprocessBase(name)
, oframe(new Frame())
{
}

Preprocess::Preprocess(std::string const& name, RTT::ExecutionEngine* engine)
: PreprocessBase(name, engine),
oframe(new Frame())
: PreprocessBase(name, engine)
, oframe(new Frame())
{
}

Expand All @@ -26,38 +26,41 @@ Preprocess::~Preprocess()
// documentation about them.
bool Preprocess::configureHook()
{
if (! PreprocessBase::configureHook())
if (!PreprocessBase::configureHook())
return false;
if(_undistort.value())
if (_undistort.value())
frame_helper.setCalibrationParameter(_calibration_parameters.value());
return true;
}

bool Preprocess::startHook()
{
if (! PreprocessBase::startHook())
if (!PreprocessBase::startHook())
return false;
return true;
}

void Preprocess::updateHook()
{
PreprocessBase::updateHook();
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> iframe;
if(_iframe.read(iframe) != RTT::NewData)
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> iframe;
if (_iframe.read(iframe) != RTT::NewData)
return;

Frame *frame_ptr = oframe.write_access();
frame_ptr->init(iframe->size.width*_scale_x-_offset_x,
iframe->size.height*_scale_y-_offset_y,
iframe->getDataDepth(),_format);
try
{
frame_helper.convert(*iframe,*frame_ptr,_offset_x.value(),
_offset_y.value(),_resize_algorithm.value(),_undistort.value());
Frame* frame_ptr = oframe.write_access();
frame_ptr->init(iframe->size.width * _scale_x - _offset_x,
iframe->size.height * _scale_y - _offset_y,
iframe->getDataDepth(),
_format);
try {
frame_helper.convert(*iframe,
*frame_ptr,
_offset_x.value(),
_offset_y.value(),
_resize_algorithm.value(),
_undistort.value());
}
catch(std::runtime_error e)
{
catch (std::runtime_error e) {
RTT::log(RTT::Error) << "processing error: " << e.what() << RTT::endlog();
if (state() != PROCESSING_ERROR) {
state(PROCESSING_ERROR);
Expand Down
46 changes: 26 additions & 20 deletions tasks/Preprocess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,51 @@

namespace camera_base {

/*! \class Preprocess
* \brief The task context provides and requires services. It uses an ExecutionEngine to perform its functions.
* Essential interfaces are operations, data flow ports and properties. These interfaces have been defined using the oroGen specification.
* In order to modify the interfaces you should (re)use oroGen and rely on the associated workflow.
*
/*! \class Preprocess
* \brief The task context provides and requires services. It uses an ExecutionEngine
to perform its functions.
* Essential interfaces are operations, data flow ports and properties. These
interfaces have been defined using the oroGen specification.
* In order to modify the interfaces you should (re)use oroGen and rely on the
associated workflow.
*
* \details
* The name of a TaskContext is primarily defined via:
\verbatim
deployment 'deployment_name'
task('custom_task_name','camera_base::Preprocess')
end
\endverbatim
* It can be dynamically adapted when the deployment is called with a prefix argument.
* It can be dynamically adapted when the deployment is called with a prefix
argument.
*/
class Preprocess : public PreprocessBase
{
friend class PreprocessBase;
class Preprocess : public PreprocessBase {
friend class PreprocessBase;

protected:
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> oframe;
frame_helper::FrameHelper frame_helper; //helper for image processing
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> oframe;
frame_helper::FrameHelper frame_helper; // helper for image processing

public:
/** TaskContext constructor for Preprocess
* \param name Name of the task. This name needs to be unique to make it identifiable via nameservices.
* \param initial_state The initial TaskState of the TaskContext. Default is Stopped state.
* \param name Name of the task. This name needs to be unique to make it
* identifiable via nameservices. \param initial_state The initial TaskState of
* the TaskContext. Default is Stopped state.
*/
Preprocess(std::string const& name = "camera_base::Preprocess");

/** TaskContext constructor for Preprocess
* \param name Name of the task. This name needs to be unique to make it identifiable for nameservices.
* \param engine The RTT Execution engine to be used for this task, which serialises the execution of all commands, programs, state machines and incoming events for a task.
*
/** TaskContext constructor for Preprocess
* \param name Name of the task. This name needs to be unique to make it
* identifiable for nameservices. \param engine The RTT Execution engine to be
* used for this task, which serialises the execution of all commands, programs,
* state machines and incoming events for a task.
*
*/
Preprocess(std::string const& name, RTT::ExecutionEngine* engine);

/** Default deconstructor of Preprocess
*/
~Preprocess();
~Preprocess();

/** This hook is called by Orocos when the state machine transitions
* from PreOperational to Stopped. If it returns false, then the
Expand Down Expand Up @@ -76,7 +83,7 @@ namespace camera_base {
*
* The error(), exception() and fatal() calls, when called in this hook,
* allow to get into the associated RunTimeError, Exception and
* FatalError states.
* FatalError states.
*
* In the first case, updateHook() is still called, and recover() allows
* you to go back into the Running state. In the second case, the
Expand Down Expand Up @@ -108,4 +115,3 @@ namespace camera_base {
}

#endif

0 comments on commit f387d64

Please sign in to comment.