00001 /****************************************************************************** 00002 * \file 00003 * 00004 * $Id:$ 00005 * 00006 * Copyright (C) Brno University of Technology 00007 * 00008 * This file is part of software developed by dcgm-robotics@FIT group. 00009 * 00010 * Author: Vit Stancl (stancl@fit.vutbr.cz) 00011 * Supervised by: Michal Spanel (spanel@fit.vutbr.cz) 00012 * Date: dd/mm/2011 00013 * 00014 * This file is free software: you can redistribute it and/or modify 00015 * it under the terms of the GNU Lesser General Public License as published by 00016 * the Free Software Foundation, either version 3 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * This file is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this file. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 #pragma once 00028 #ifndef RVIZ_ROS_RTT_TEXTURE_H 00029 #define RVIZ_ROS_RTT_TEXTURE_H 00030 00031 #include <sensor_msgs/Image.h> 00032 00033 #include <OGRE/OgreTexture.h> 00034 #include <OGRE/OgreImage.h> 00035 00036 #include <boost/shared_ptr.hpp> 00037 #include <boost/thread/mutex.hpp> 00038 00039 #include <ros/ros.h> 00040 #include <image_transport/image_transport.h> 00041 #include <image_transport/subscriber_filter.h> 00042 00043 #include <tf/message_filter.h> 00044 00045 #include <stdexcept> 00046 00047 namespace tf 00048 { 00049 class TransformListener; 00050 } 00051 00052 namespace srs_ui_but 00053 { 00054 00055 typedef std::vector<std::string> V_string; 00056 00057 class UnsupportedImageEncoding : public std::runtime_error 00058 { 00059 public: 00060 UnsupportedImageEncoding(const std::string& encoding) 00061 : std::runtime_error("Unsupported image encoding [" + encoding + "]") 00062 {} 00063 }; 00064 00065 class CRosRttTexture 00066 { 00067 public: 00068 CRosRttTexture(unsigned width, unsigned height, Ogre::Camera * camera, bool isDepth = false); 00069 ~CRosRttTexture(); 00070 00071 void setFrame(const std::string& frame); 00072 00073 const Ogre::TexturePtr& getTexture() const { return texture_; } 00074 const sensor_msgs::Image & getImage(); 00075 00076 uint32_t getWidth() const { return width_; } 00077 uint32_t getHeight() const { return height_; } 00078 00079 const std::string& getMaterialName() const { return m_materialName; } 00080 00081 bool hasData() const { return current_image_.width > 0 && current_image_.height > 0; } 00082 00083 void saveImage(const std::string & filename); 00084 00085 protected: 00086 void update(); 00087 00088 sensor_msgs::Image current_image_; 00089 Ogre::TexturePtr texture_; 00090 00091 Ogre::String m_materialName; 00092 00093 uint32_t width_; 00094 uint32_t height_; 00095 00096 std::string frame_; 00097 00098 boost::mutex mutex_; 00099 00100 // Is it depth image 00101 bool m_bIsDepth; 00102 00103 }; 00104 00105 } // namespace srs_ui_but 00106 00107 // RVIZ_ROS_RTT_TEXTURE_H 00108 #endif 00109