36 #define BOOST_PARAMETER_MAX_ARITY 7 45 DiagnosticNodelet::onInit();
46 pub_config_ =
pnh_->advertise<jsk_recognition_msgs::HeightmapConfig>(
"output/config",
48 srv_ = boost::make_shared <dynamic_reconfigure::Server<Config> > (*pnh_);
49 typename dynamic_reconfigure::Server<Config>::CallbackType
f =
51 srv_->setCallback (f);
54 pub_ = advertise<sensor_msgs::Image>(*
pnh_,
"output", 1);
80 Config& config, uint32_t level)
93 const sensor_msgs::Image::ConstPtr&
msg)
100 cv::Mat filtered_image;
101 filtered_image = input.clone();
104 for (
size_t j = 0; j < input.rows; j++) {
105 for (
size_t i = 0; i < input.cols; i++) {
106 float v = input.at<cv::Vec2f>(j, i)[0];
107 if (std::isnan(v) || v == -FLT_MAX) {
111 int target_j = j + jj;
112 if (target_j >= 0 && target_j < input.rows) {
114 int target_i = i + ii;
115 if (target_i >= 0 && target_i < input.cols) {
116 if (std::abs(jj) + std::abs(ii) <=
mask_size_) {
117 float vv = input.at<cv::Vec2f>(target_j, target_i)[0];
118 if (!std::isnan(vv) && vv != -FLT_MAX) {
131 filtered_image.at<cv::Vec2f>(j, i)[0] = newv;
132 filtered_image.at<cv::Vec2f>(j, i)[1] = 1 - variance/
max_variance_;
140 for (
size_t j = 0; j < input.rows; j++) {
141 for (
size_t i = 0; i < input.cols; i++) {
142 float v = input.at<cv::Vec2f>(j, i)[0];
143 if (std::isnan(v) || v == -FLT_MAX) {
148 int target_j = j + jj;
149 if (target_j >= 0 && target_j < input.rows) {
151 int target_i = i + ii;
152 if (target_i >= 0 && target_i < input.cols) {
153 int len = std::abs(jj) + std::abs(ii);
155 float vv = input.at<cv::Vec2f>(target_j, target_i)[0];
156 if (!std::isnan(vv) && vv != -FLT_MAX) {
170 filtered_image.at<cv::Vec2f>(j, i)[0] = newv;
180 std::vector<cv::Mat> fimages;
181 cv::split(filtered_image, fimages);
186 for (
size_t j = 0; j < res_image.rows; j++) {
187 for (
size_t i = 0; i < res_image.cols; i++) {
188 float ov = fimages[0].at<
float>(j, i);
189 if (ov == -FLT_MAX) {
190 res_image.at<
float>(j, i) = -FLT_MAX;
196 std::vector<cv::Mat> ret_images;
197 ret_images.push_back(res_image);
198 ret_images.push_back(fimages[1]);
199 cv::merge(ret_images, filtered_image);
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
virtual void filter(const sensor_msgs::Image::ConstPtr &msg)
virtual void configCallback(Config &config, uint32_t level)
virtual void configTopicCallback(const jsk_recognition_msgs::HeightmapConfig::ConstPtr &msg)
void publish(const boost::shared_ptr< M > &message) const
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
PLUGINLIB_EXPORT_CLASS(jsk_pcl_ros::HeightmapMorphologicalFiltering, nodelet::Nodelet)
double bilateral_sigma_color_
std::string getHeightmapConfigTopic(const std::string &base_topic)
double variance(const OneDataStat &d)
wrapper function for variance method for boost::function
double bilateral_sigma_space_
ros::Publisher pub_config_
std::string smooth_method_
ros::Subscriber sub_config_
int bilateral_filter_size_
double count(const OneDataStat &d)
wrapper function for count method for boost::function
const std::string TYPE_32FC2
boost::accumulators::accumulator_set< float, boost::accumulators::stats< boost::accumulators::tag::variance, boost::accumulators::tag::count, boost::accumulators::tag::mean > > Accumulator
HeightmapMorphologicalFilteringConfig Config
virtual void unsubscribe()
sensor_msgs::ImagePtr toImageMsg() const