Skip to content

Commit

Permalink
Added vPreProcess module code contained in icub23 pc.
Browse files Browse the repository at this point in the history
  • Loading branch information
lunagava committed Apr 22, 2021
1 parent 8e4eed2 commit 5d1f338
Show file tree
Hide file tree
Showing 4 changed files with 422 additions and 470 deletions.
26 changes: 12 additions & 14 deletions src/processing/vPreProcess/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
project(vPreProcess)
cmake_minimum_required(VERSION 2.6)

set(MODULENAME vPreProcess)
project(${MODULENAME})

file(GLOB source src/*.cpp)
file(GLOB header include/*.h)

add_executable(${PROJECT_NAME} ${source} ${header})

target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS}
${EVENTDRIVENLIBS_INCLUDE_DIRS})

target_link_libraries(${PROJECT_NAME} PRIVATE YARP::YARP_OS
YARP::YARP_init
${OpenCV_LIBRARIES}
ev::${EVENTDRIVEN_LIBRARY})
add_executable(${MODULENAME} ${source} ${header})

install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
target_link_libraries(${MODULENAME} ${YARP_LIBRARIES} ${OpenCV_LIBRARIES} ${EVENTDRIVEN_LIBRARIES})

yarp_install(FILES ${PROJECT_NAME}.ini
DESTINATION ${EVENT-DRIVEN_CONTEXTS_INSTALL_DIR}/${CONTEXT_DIR})
install(TARGETS ${MODULENAME} DESTINATION bin)

yarp_install(FILES ${MODULENAME}.ini DESTINATION ${ICUBCONTRIB_CONTEXTS_INSTALL_DIR}/${CONTEXT_DIR})
if(ADD_DOCS_TO_IDE)
add_custom_target(${PROJECT_NAME}_docs SOURCES ${PROJECT_NAME}.ini ${PROJECT_NAME}.xml)
add_custom_target(${MODULENAME}_docs SOURCES ${MODULENAME}.ini ${MODULENAME}.xml)
endif(ADD_DOCS_TO_IDE)

96 changes: 51 additions & 45 deletions src/processing/vPreProcess/include/vPreProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,27 @@
#ifndef __VPREPROCESS__
#define __VPREPROCESS__

#define DECODE_METHOD 2

#include <yarp/os/all.h>
#include <yarp/sig/all.h>
#include <event-driven/all.h>
#include <event-driven/vIPT.h>
#include <iCub/eventdriven/all.h>
//#include <opencv/cv.h>
#include <opencv2/opencv.hpp>
using namespace::ev;

class vPreProcess : public yarp::os::RFModule, public yarp::os::Thread
class vPreProcess : public yarp::os::Thread
{
private:

//output port for the vBottle with the new events computed by the module

ev::vReadPort < vector<int32_t> > inPort;
ev::vWritePort outPortCamLeft;
ev::vWritePort outPortCamLeft_pos;
ev::vWritePort outPortCamLeft_neg;
ev::vWritePort outPortCamRight;
ev::vWritePort outPortCamRight_pos;
ev::vWritePort outPortCamRight_neg;
ev::vWritePort outPortCamStereo;
ev::vWritePort outPortCamStereo_pos;
ev::vWritePort outPortCamStereo_neg;
ev::vWritePort outPortSkin;
ev::vWritePort outPortSkinSamples;
ev::vWritePort out_port_aps_left;
ev::vWritePort out_port_aps_right;
ev::vWritePort out_port_aps_stereo;
ev::vWritePort out_port_imu_samples;
ev::vWritePort out_port_audio;
ev::vWritePort out_port_crn_left;
ev::vWritePort out_port_crn_right;
ev::vWritePort out_port_crn_stereo;
yarp::os::BufferedPort< yarp::sig::Vector > rate_port;
vReadPort < vector<int32_t> > inPort;
vWritePort outPortCamLeft;
vWritePort outPortCamRight;
vWritePort outPortCamCombined;
vWritePort outPortSkin;
vWritePort outPortSkinSamples;

//parameters
std::string name;
Expand All @@ -68,49 +56,67 @@ class vPreProcess : public yarp::os::RFModule, public yarp::os::Thread
bool flipy;

//filter class
bool apply_filter;
ev::vNoiseFilter filter_left;
ev::vNoiseFilter filter_right;
bool pepper;
ev::vNoiseFilter thefilter;
int v_total;
int v_dropped;

//we store an openCV map to use as a look-up table for the undistortion
//given the camera parameters provided
bool rectify;
bool undistort;
ev::vIPT calibrator;
cv::Mat leftMap;
cv::Mat rightMap;
bool truncate;
bool use_local_stamp;

//output
bool split_stereo;
bool split_polarities;
bool combined_stereo;
bool use_local_stamp;
bool corners;
bool split;

//timing stats
std::deque<double> delays;
std::deque<double> rates;
std::deque<double> intervals;
std::deque<double> proc_times;

bool vis{false};
std::deque<double> plot_rates;
void visualise_rate();

public:

vPreProcess();
~vPreProcess();


//inherited functions
virtual bool configure(yarp::os::ResourceFinder &rf);
double getPeriod();
bool interruptModule();
void initBasic(std::string name, int height, int width, bool precheck,
bool flipx, bool flipy, bool pepper, bool rectify, bool undistort,
bool split, bool local_stamp);
void initPepper(int spatialSize, int temporalSize);
void initUndistortion(const yarp::os::Bottle &left,
const yarp::os::Bottle &right,
const yarp::os::Bottle &stereo,
bool truncate);
int queryUnprocessed();
std::deque<double> getDelays();
std::deque<double> getRates();
std::deque<double> getIntervals();
void printFilterStats();
void run();
void onStop();
bool threadInit();
bool updateModule();
void run();

};

class vPreProcessModule : public yarp::os::RFModule
{
//the event bottle input and output handler
vPreProcess eventManager;

public:

//the virtual functions that need to be overloaded
virtual bool configure(yarp::os::ResourceFinder &rf);
virtual bool close();

virtual double getPeriod();
virtual bool updateModule();

};


#endif
Loading

0 comments on commit 5d1f338

Please sign in to comment.