|
From: <pmi...@us...> - 2009-08-07 02:17:04
|
Revision: 20992
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=20992&view=rev
Author: pmihelich
Date: 2009-08-07 02:16:56 +0000 (Fri, 07 Aug 2009)
Log Message:
-----------
sensor_msgs: Cleaned up CompressedImage. Updated image_publisher. Blacklisted jpeg.
Modified Paths:
--------------
pkg/trunk/sandbox/image_publisher/include/image_publisher/image_publisher.h
pkg/trunk/sandbox/image_publisher/src/decoder.cpp
pkg/trunk/sandbox/image_publisher/src/encoder.cpp
pkg/trunk/sandbox/image_publisher/src/image_publisher.cpp
pkg/trunk/sandbox/image_publisher/src/test_publisher.cpp
pkg/trunk/stacks/common_msgs/sensor_msgs/msg/CompressedImage.msg
Added Paths:
-----------
pkg/trunk/vision/jpeg/ROS_BUILD_BLACKLIST
Modified: pkg/trunk/sandbox/image_publisher/include/image_publisher/image_publisher.h
===================================================================
--- pkg/trunk/sandbox/image_publisher/include/image_publisher/image_publisher.h 2009-08-07 02:08:56 UTC (rev 20991)
+++ pkg/trunk/sandbox/image_publisher/include/image_publisher/image_publisher.h 2009-08-07 02:16:56 UTC (rev 20992)
@@ -81,35 +81,35 @@
*
* Returns the total number of subscribers to the raw, thumbnail and compressed topics.
*/
- uint32_t getNumSubscribers() /*const*/;
+ uint32_t getNumSubscribers() const;
/*!
* \brief Returns the topic that this ImagePublisher will publish the raw
* image on.
*/
- std::string getTopic() /*const*/;
+ std::string getTopic() const;
/*!
* \brief Returns the topic that this ImagePublisher will publish the thumbnail
* image on.
*/
- std::string getTopicThumbnail() /*const*/;
+ std::string getTopicThumbnail() const;
/*!
* \brief Returns the topic that this ImagePublisher will publish the compressed
* image on.
*/
- std::string getTopicCompressed() /*const*/;
+ std::string getTopicCompressed() const;
/*!
* \brief Publish an image on the topics associated with this ImagePublisher.
*/
- void publish(const sensor_msgs::Image& message) /*const*/;
+ void publish(const sensor_msgs::Image& message) const;
/*!
* \brief Publish an image on the topics associated with this ImagePublisher.
*/
- void publish(const sensor_msgs::ImageConstPtr& message) /*const*/;
+ void publish(const sensor_msgs::ImageConstPtr& message) const;
/*!
* \brief Shutdown the advertisements associated with this ImagePublisher.
@@ -117,8 +117,8 @@
void shutdown();
private:
- void publishThumbnailImage(sensor_msgs::Image& thumbnail) /*const*/;
- void publishCompressedImage(sensor_msgs::CompressedImage& compressed) /*const*/;
+ void publishThumbnailImage(sensor_msgs::Image& thumbnail) const;
+ void publishCompressedImage(sensor_msgs::CompressedImage& compressed) const;
ros::NodeHandle node_handle_;
ros::Publisher image_pub_;
Modified: pkg/trunk/sandbox/image_publisher/src/decoder.cpp
===================================================================
--- pkg/trunk/sandbox/image_publisher/src/decoder.cpp 2009-08-07 02:08:56 UTC (rev 20991)
+++ pkg/trunk/sandbox/image_publisher/src/decoder.cpp 2009-08-07 02:16:56 UTC (rev 20992)
@@ -43,13 +43,22 @@
void imageCB(const sensor_msgs::CompressedImageConstPtr &msg)
{
- const CvMat compressed = cvMat(1, msg->uint8_data.data.size(), CV_8UC1,
- const_cast<unsigned char*>(&msg->uint8_data.data[0]));
+ const CvMat compressed = cvMat(1, msg->data.size(), CV_8UC1,
+ const_cast<unsigned char*>(&msg->data[0]));
cv::WImageBuffer_b decompressed( cvDecodeImage(&compressed, CV_LOAD_IMAGE_ANYCOLOR) );
sensor_msgs::Image image;
if ( sensor_msgs::CvBridge::fromIpltoRosImage(decompressed.Ipl(), image) ) {
image.header = msg->header;
- image.encoding = msg->encoding;
+ if (decompressed.Channels() == 1) {
+ image.encoding = "mono";
+ }
+ else if (decompressed.Channels() == 3) {
+ image.encoding = "rgb";
+ }
+ else {
+ ROS_ERROR("Unsupported number of channels: %i", decompressed.Channels());
+ return;
+ }
g_decompressed_pub.publish(image);
}
else {
Modified: pkg/trunk/sandbox/image_publisher/src/encoder.cpp
===================================================================
--- pkg/trunk/sandbox/image_publisher/src/encoder.cpp 2009-08-07 02:08:56 UTC (rev 20991)
+++ pkg/trunk/sandbox/image_publisher/src/encoder.cpp 2009-08-07 02:16:56 UTC (rev 20992)
@@ -41,8 +41,11 @@
std::string topic = n.resolveName("image");
ImagePublisher image_pub(topic, n, true);
- ros::Subscriber raw_sub = n.subscribe(topic, 1, &ImagePublisher::publish, &image_pub);
-
+
+ typedef void (ImagePublisher::*PublishMemFn)(const sensor_msgs::ImageConstPtr& message) const;
+ PublishMemFn pub_mem_fn = &ImagePublisher::publish;
+ ros::Subscriber raw_sub = n.subscribe<sensor_msgs::Image>(topic, 1,
+ boost::bind(pub_mem_fn, &image_pub, _1));
ros::spin();
return 0;
Modified: pkg/trunk/sandbox/image_publisher/src/image_publisher.cpp
===================================================================
--- pkg/trunk/sandbox/image_publisher/src/image_publisher.cpp 2009-08-07 02:08:56 UTC (rev 20991)
+++ pkg/trunk/sandbox/image_publisher/src/image_publisher.cpp 2009-08-07 02:16:56 UTC (rev 20992)
@@ -62,28 +62,28 @@
compressed_pub_ = node_handle_.advertise<sensor_msgs::CompressedImage>(topic + "_compressed", 1);
}
-uint32_t ImagePublisher::getNumSubscribers() //const
+uint32_t ImagePublisher::getNumSubscribers() const
{
return image_pub_.getNumSubscribers() + thumbnail_pub_.getNumSubscribers()
+ compressed_pub_.getNumSubscribers();
}
-std::string ImagePublisher::getTopic() //const
+std::string ImagePublisher::getTopic() const
{
return image_pub_.getTopic();
}
-std::string ImagePublisher::getTopicThumbnail() //const
+std::string ImagePublisher::getTopicThumbnail() const
{
return thumbnail_pub_.getTopic();
}
-std::string ImagePublisher::getTopicCompressed() //const
+std::string ImagePublisher::getTopicCompressed() const
{
return compressed_pub_.getTopic();
}
-void ImagePublisher::publish(const sensor_msgs::Image& message) //const
+void ImagePublisher::publish(const sensor_msgs::Image& message) const
{
if (!republishing_)
image_pub_.publish(message);
@@ -105,7 +105,7 @@
if (channels == 1)
encoding = "mono";
else if (channels == 3)
- encoding = "rgb"; /** @todo: avoid BGR->RGB conversion? */
+ encoding = "rgb";
else {
/** @todo: RGBA, BGRA. Can we do anything with other encodings? */
ROS_ERROR("Unsupported number of image channels: %d", channels);
@@ -127,13 +127,11 @@
if (compressed_subscribers > 0) {
sensor_msgs::CompressedImage compressed;
compressed.header = message.header;
- compressed.label = message.label;
- compressed.encoding = encoding;
publishCompressedImage(compressed);
}
}
-void ImagePublisher::publish(const sensor_msgs::ImageConstPtr& message) //const
+void ImagePublisher::publish(const sensor_msgs::ImageConstPtr& message) const
{
publish(*message);
}
@@ -145,7 +143,7 @@
compressed_pub_.shutdown();
}
-void ImagePublisher::publishThumbnailImage(sensor_msgs::Image& thumbnail) //const
+void ImagePublisher::publishThumbnailImage(sensor_msgs::Image& thumbnail) const
{
// Update settings from parameter server
int thumbnail_size = 128;
@@ -170,7 +168,7 @@
}
}
-void ImagePublisher::publishCompressedImage(sensor_msgs::CompressedImage& compressed) //const
+void ImagePublisher::publishCompressedImage(sensor_msgs::CompressedImage& compressed) const
{
// Update settings from parameter server
int params[3] = {0};
@@ -198,18 +196,8 @@
CvMat* buf = cvEncodeImage(extension.c_str(), image, params);
// Set up message and publish
- compressed.format = format;
- compressed.uint8_data.layout.dim.resize(2);
- compressed.uint8_data.layout.dim[0].label = "height";
- compressed.uint8_data.layout.dim[0].size = image->height;
- compressed.uint8_data.layout.dim[0].stride = 0;
-
- compressed.uint8_data.layout.dim[1].label = "width";
- compressed.uint8_data.layout.dim[1].size = image->width;
- compressed.uint8_data.layout.dim[1].stride = 0;
-
- compressed.uint8_data.data.resize(buf->width);
- memcpy(&compressed.uint8_data.data[0], buf->data.ptr, buf->width);
+ compressed.data.resize(buf->width);
+ memcpy(&compressed.data[0], buf->data.ptr, buf->width);
cvReleaseMat(&buf);
compressed_pub_.publish(compressed);
Modified: pkg/trunk/sandbox/image_publisher/src/test_publisher.cpp
===================================================================
--- pkg/trunk/sandbox/image_publisher/src/test_publisher.cpp 2009-08-07 02:08:56 UTC (rev 20991)
+++ pkg/trunk/sandbox/image_publisher/src/test_publisher.cpp 2009-08-07 02:16:56 UTC (rev 20992)
@@ -9,10 +9,11 @@
//ImagePublisher image_pub("raw_image", n);
ros::Publisher image_pub = n.advertise<sensor_msgs::Image>("raw_image", 1);
- cv::WImageBuffer3_b image( cvLoadImage(argv[1], CV_LOAD_IMAGE_COLOR) );
+ //cv::WImageBuffer3_b image( cvLoadImage(argv[1], CV_LOAD_IMAGE_COLOR) );
+ cv::WImageBuffer1_b image( cvLoadImage(argv[1], CV_LOAD_IMAGE_GRAYSCALE) );
sensor_msgs::Image msg;
sensor_msgs::CvBridge::fromIpltoRosImage(image.Ipl(), msg);
- msg.encoding = "bgr";
+ //msg.encoding = "bgr";
msg.header.frame_id = "base_link";
ros::Rate loop_rate(5);
Modified: pkg/trunk/stacks/common_msgs/sensor_msgs/msg/CompressedImage.msg
===================================================================
--- pkg/trunk/stacks/common_msgs/sensor_msgs/msg/CompressedImage.msg 2009-08-07 02:08:56 UTC (rev 20991)
+++ pkg/trunk/stacks/common_msgs/sensor_msgs/msg/CompressedImage.msg 2009-08-07 02:16:56 UTC (rev 20992)
@@ -1,13 +1,5 @@
Header header # Header
-string label # Label for the image
-string encoding # Specifies the color encoding of the data
- # Acceptable values are:
- # 1 channel types:
- # mono
- # 3 channel types:
- # rgb, bgr
string format # Specifies the format of the data
# Acceptable values:
- # jpeg
-
-std_msgs/UInt8MultiArray uint8_data
+ # jpeg, png
+uint8[] data # Compressed image buffer
Added: pkg/trunk/vision/jpeg/ROS_BUILD_BLACKLIST
===================================================================
--- pkg/trunk/vision/jpeg/ROS_BUILD_BLACKLIST (rev 0)
+++ pkg/trunk/vision/jpeg/ROS_BUILD_BLACKLIST 2009-08-07 02:16:56 UTC (rev 20992)
@@ -0,0 +1 @@
+Deprecated, and hasn't been updated to new CompressedImage message.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|