45 DiagnosticNodelet::onInit();
47 srv_ = boost::make_shared <dynamic_reconfigure::Server<Config> > (*pnh_);
48 dynamic_reconfigure::Server<Config>::CallbackType
f =
51 srv_->setCallback (f);
53 pub_ = advertise<jsk_recognition_msgs::RectArray>(
64 async_ = boost::make_shared<message_filters::Synchronizer<ApproxSyncPolicy> >(100);
69 sync_ = boost::make_shared<message_filters::Synchronizer<SyncPolicy> >(100);
94 const int center_x,
const int center_y,
const cv::Mat&
img)
const 100 const int x = center_x + i;
101 const int y = center_y + j;
102 if (0 <= x && x <= img.cols &&
103 0 <= y && y <= img.rows) {
104 d += img.at<
float>(y, x);
113 (
const jsk_recognition_msgs::RectArray::ConstPtr& rect_array_msg,
114 const sensor_msgs::Image::ConstPtr& depth_image_msg,
115 const sensor_msgs::CameraInfo::ConstPtr& info_msg)
121 jsk_recognition_msgs::RectArray result_msg;
122 result_msg.header = rect_array_msg->header;
124 cv::Mat depth = cv_depth->image;
125 cv::Mat average_depth;
130 for (
size_t i = 0; i< rect_array_msg->rects.size(); i++) {
131 jsk_recognition_msgs::Rect rect = rect_array_msg->rects[i];
133 const int center_x = rect.x + rect.width / 2;
134 const int center_y = rect.y + rect.height / 2;
135 const cv::Point
A(rect.x, rect.y);
136 const cv::Point
C(rect.x + rect.width, rect.y + rect.height);
141 if (a_ray.z != 0.0 && c_ray.z != 0.0) {
142 cv::Point3d a_3d = a_ray * (distance / a_ray.z);
143 cv::Point3d c_3d = c_ray * (distance / c_ray.z);
144 const double width = std::abs(a_3d.x - c_3d.x);
145 const double height = std::abs(a_3d.y - c_3d.y);
148 result_msg.rects.push_back(rect);
#define NODELET_ERROR(...)
void publish(const boost::shared_ptr< M > &message) const
virtual double averageDistance(const int center_x, const int center_y, const cv::Mat &img) const
cv::Point3d projectPixelTo3dRay(const cv::Point2d &uv_rect) const
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
message_filters::Subscriber< sensor_msgs::Image > sub_image_
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
PLUGINLIB_EXPORT_CLASS(jsk_perception::RectArrayActualSizeFilter, nodelet::Nodelet)
virtual image_geometry::PinholeCameraModel getPinholeCameraModel() const
boost::shared_ptr< message_filters::Synchronizer< ApproxSyncPolicy > > async_
message_filters::Subscriber< sensor_msgs::CameraInfo > sub_info_
virtual void configCallback(Config &config, uint32_t level)
const std::string TYPE_32FC1
CvImagePtr toCvCopy(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
message_filters::Subscriber< jsk_recognition_msgs::RectArray > sub_rect_array_
void subscribe(ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, const ros::TransportHints &transport_hints=ros::TransportHints(), ros::CallbackQueueInterface *callback_queue=0)
virtual void filter(const jsk_recognition_msgs::RectArray::ConstPtr &rect_array_msg, const sensor_msgs::Image::ConstPtr &depth_image_msg, const sensor_msgs::CameraInfo::ConstPtr &info_msg)
virtual void unsubscribe()
virtual void setCameraInfo(const sensor_msgs::CameraInfo &info)
RectArrayActualSizeFilterConfig Config
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_