13 #include "hrpsys/idl/pointcloud.hh" 17 static const char*
spec[] =
19 "implementation_id",
"AverageFilter",
20 "type_name",
"AverageFilter",
21 "description",
"Average Filter",
22 "version", HRPSYS_PACKAGE_VERSION,
24 "category",
"example",
25 "activity_type",
"DataFlowComponent",
28 "lang_type",
"compile",
30 "conf.default.resolution",
"0.01",
31 "conf.default.windowSize",
"4",
32 "conf.default.dilation",
"0",
41 m_originalIn(
"original", m_original),
42 m_filteredOut(
"filtered", m_filtered),
88 m_filtered.fields[0].data_type = PointCloudTypes::FLOAT32;
92 m_filtered.fields[1].data_type = PointCloudTypes::FLOAT32;
96 m_filtered.fields[2].data_type = PointCloudTypes::FLOAT32;
130 std::cout <<
m_profile.instance_name<<
": onActivated(" << ec_id <<
")" << std::endl;
136 std::cout <<
m_profile.instance_name<<
": onDeactivated(" << ec_id <<
")" << std::endl;
147 if (!
m_original.data.length())
return RTC::RTC_OK;
150 float xmin, xmax, ymin, ymax;
151 float *src = (
float *)
m_original.data.get_buffer();
153 for (
unsigned int i=0;
i<npoint;
i++){
155 xmin = xmax = src[0];
156 ymin = ymax = src[1];
158 if (xmin > src[0]) xmin = src[0];
159 if (xmax < src[0]) xmax = src[0];
160 if (ymin > src[1]) ymin = src[1];
161 if (ymax < src[1]) ymax = src[1];
171 std::vector<float> cell(nx*ny, std::numeric_limits<float>::quiet_NaN());
177 for (
unsigned int i=0;
i<npoint;
i++){
181 double z = cell[
rank], z_new = src[2];
182 if (isnan(z) || !isnan(z) && z_new > z){
188 for (
unsigned int i=0;
i<npoint;
i++){
191 for (
int j=0; j<2; j++){
192 for (
int k=0; k<2; k++){
193 int rank = ix+j + nx*(iy+k);
194 double z = cell[
rank], z_new = src[2];
195 if (isnan(z) || !isnan(z) && z_new >
z){
206 float *dst = (
float *)
m_filtered.data.get_buffer();
209 for (
int x=whalf;
x<nx-whalf;
x++){
210 for (
int y=whalf;
y<ny-whalf;
y++){
214 for (
int dx=-whalf; dx<=whalf; dx++){
215 for (
int dy=-whalf; dy<whalf; dy++){
216 int index =
x + dx + nx*(
y + dy);
217 if (!isnan(cell[index])){
286 RTC::Create<AverageFilter>,
287 RTC::Delete<AverageFilter>);
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
static const char * spec[]
OutPort< PointCloudTypes::PointCloud > m_filteredOut
coil::Properties & getProperties()
bool addOutPort(const char *name, OutPortBase &outport)
ExecutionContextHandle_t UniqueId
PointCloudTypes::PointCloud m_original
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
AverageFilter(RTC::Manager *manager)
Constructor.
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
PointCloudTypes::PointCloud m_filtered
virtual ~AverageFilter()
Destructor.
virtual bool write(DataType &value)
virtual RTC::ReturnCode_t onInitialize()
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
bool addInPort(const char *name, InPortBase &inport)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
void AverageFilterInit(RTC::Manager *manager)
InPort< PointCloudTypes::PointCloud > m_originalIn