image_overlay.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef IMAGE_OVERLAY_H_
00031 #define IMAGE_OVERLAY_H_
00032 
00033 #include <sensor_msgs/Image.h>
00034 #include <stereo_msgs/DisparityImage.h>
00035 
00036 #include <OGRE/OgreTexture.h>
00037 #include <OGRE/OgreImage.h>
00038 #include <OGRE/OgreMaterial.h>
00039 
00040 #include <boost/thread/mutex.hpp>
00041 
00042 
00043 namespace Ogre
00044 {
00045 class SceneNode;
00046 class Rectangle2D;
00047 }
00048 
00049 namespace rviz_interaction_tools
00050 {
00051 
00054 class ImageOverlay
00055 {
00056 public:
00057 
00058   // @note always setup the render queue group so that the image gets rendered
00059   //       before the other geometry
00060   ImageOverlay( Ogre::SceneNode* scene_root, unsigned char render_queue_group );
00061 
00062   virtual ~ImageOverlay();
00063 
00067   bool setImage( const sensor_msgs::Image &image, const stereo_msgs::DisparityImage &disparity_image );
00068 
00069   bool setImage( const sensor_msgs::Image &image );
00070 
00072   bool setImage( unsigned char *rgb_data, int width, int height );
00073 
00074   // copy the image data to the actual texture buffer
00075   // make sure to call this from the thread in which ogre is running
00076   bool update();
00077 
00078   void clear();
00079 
00080   int getWidth();
00081   int getHeight();
00082 
00083   Ogre::MaterialPtr getMaterial() { return texture_material_; }
00084 
00085 private:
00086 
00087   // used by the other setImage methods
00088   bool setImageNoLock( const sensor_msgs::Image &image );
00089 
00090   boost::mutex mutex_;
00091 
00092   int count_;
00093 
00094   Ogre::MaterialPtr texture_material_;
00095   Ogre::TexturePtr texture_;
00096   Ogre::Image empty_image_;
00097   Ogre::Rectangle2D* image_rect_;
00098 
00099   Ogre::SceneNode* scene_root_;
00100 
00101   // used to transport data from one thread to the other
00102   bool new_image_;
00103   std::vector<unsigned char> image_buffer_;
00104   int width_;
00105   int height_;
00106 
00107   std::string resource_group_name_;
00108 };
00109 
00110 }
00111 
00112 #endif /* IMAGE_OVERLAY_H_ */


rviz_interaction_tools
Author(s): David Gossow
autogenerated on Thu Jan 2 2014 11:37:58