52 pub = nh.
advertise<stereo_msgs::DisparityImage>(
"disparity", 1);
71 stereo_msgs::DisparityImagePtr p = boost::make_shared<stereo_msgs::DisparityImage>();
73 const uint64_t freq = 1000000000ul;
76 p->header.seq =
seq++;
77 p->header.stamp.sec = time / freq;
78 p->header.stamp.nsec = time - freq * p->header.stamp.sec;
83 p->image.header = p->header;
84 p->image.width =
static_cast<uint32_t
>(buffer->
getWidth(part));
85 p->image.height =
static_cast<uint32_t
>(buffer->
getHeight(part));
88 p->image.step = p->image.width *
sizeof(float);
91 const uint8_t* ps =
static_cast<const uint8_t*
>(buffer->
getBase(part));
95 p->image.data.resize(p->image.step * p->image.height);
97 float* pt =
reinterpret_cast<float*
>(&p->image.data[0]);
102 for (uint32_t k = 0; k < p->image.height; k++)
106 for (uint32_t i = 0; i < p->image.width; i++)
108 uint16_t
d = (ps[0] << 8) | ps[1];
115 dmax = std::max(dmax, *pt);
124 for (uint32_t i = 0; i < p->image.width; i++)
126 uint16_t
d = (ps[1] << 8) | ps[0];
133 dmax = std::max(dmax, *pt);
144 p->f =
f * p->image.width;
146 p->valid_window.x_offset = 0;
147 p->valid_window.y_offset = 0;
148 p->valid_window.width = p->image.width;
149 p->valid_window.height = p->image.height;
150 p->min_disparity = 0;
151 p->max_disparity = std::max(dmax, static_cast<float>(
disprange));
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
void setDisprange(int disprange)
Set the disparity range for scaling of images.
DisparityPublisher(ros::NodeHandle &nh, const std::string &frame_id_prefix, double f, double t, double scale)
Initialization of publisher.
size_t getHeight(std::uint32_t part) const