43 double _f,
double _t,
double _scale)
53 pub = nh.
advertise<stereo_msgs::DisparityImage>(
"disparity", 1);
73 stereo_msgs::DisparityImagePtr p = boost::make_shared<stereo_msgs::DisparityImage>();
75 const uint64_t freq = 1000000000ul;
78 p->header.seq =
seq++;
79 p->header.stamp.sec = time / freq;
80 p->header.stamp.nsec = time - freq * p->header.stamp.sec;
85 p->image.header = p->header;
86 p->image.width =
static_cast<uint32_t
>(buffer->
getWidth(part));
87 p->image.height =
static_cast<uint32_t
>(buffer->
getHeight(part));
90 p->image.step = p->image.width *
sizeof(float);
93 const uint8_t* ps =
static_cast<const uint8_t*
>(buffer->
getBase(part));
97 p->image.data.resize(p->image.step * p->image.height);
99 float* pt =
reinterpret_cast<float*
>(&p->image.data[0]);
104 for (uint32_t k = 0; k < p->image.height; k++)
108 for (uint32_t i = 0; i < p->image.width; i++)
110 uint16_t
d = (ps[0] << 8) | ps[1];
117 dmax = std::max(dmax, *pt);
126 for (uint32_t i = 0; i < p->image.width; i++)
128 uint16_t
d = (ps[1] << 8) | ps[0];
135 dmax = std::max(dmax, *pt);
146 p->f =
f * p->image.width;
148 p->valid_window.x_offset = 0;
149 p->valid_window.y_offset = 0;
150 p->valid_window.width = p->image.width;
151 p->valid_window.height = p->image.height;
152 p->min_disparity = 0;
153 p->max_disparity = std::max(dmax, static_cast<float>(std::ceil(p->f * p->T /
mindepth)));
Interface for all publishers relating to images, point clouds or other stereo-camera data...
void publish(const rcg::Buffer *buffer, uint32_t part, uint64_t pixelformat) override
Offers a buffer for publication.
void publish(const boost::shared_ptr< M > &message) const
bool used() override
Returns true if there are subscribers to the topic.
size_t getXPadding(std::uint32_t part) const
size_t getWidth(std::uint32_t part) const
void * getBase(std::uint32_t part) const
const std::string TYPE_32FC1
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
uint64_t getTimestampNS() const
uint32_t getNumSubscribers() const
DisparityPublisher(ros::NodeHandle &nh, const std::string &frame_id_prefix, double f, double t, double scale)
Initialization of publisher.
void setDepthRange(double _mindepth, double _maxdepth)
Set the depth range of the disparity images.
size_t getHeight(std::uint32_t part) const