vpROSGrabber.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * $Id: vpROSGrabber.h 3803 2012-06-22 10:22:59Z fpasteau $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Camera video capture for ROS image_transort_compressed.
36  *
37  * Authors:
38  * Francois Pasteau
39  * Fabien Spindler
40  *
41  *****************************************************************************/
42 
48 #ifndef vpROSGrabber_h
49 #define vpROSGrabber_h
50 
51 #include <visp/vpConfig.h>
52 
53 #if defined(VISP_HAVE_OPENCV)
54 
55 #include <cv.h>
56 #include <visp/vpImage.h>
57 #include <visp/vpFrameGrabber.h>
58 #include <visp/vpRGBa.h>
59 #include <ros/ros.h>
60 #include <sensor_msgs/CompressedImage.h>
61 #include <sensor_msgs/Image.h>
62 #include <visp_bridge/camera.h>
63 #include <image_geometry/pinhole_camera_model.h>
64 
65 #if VISP_HAVE_OPENCV_VERSION >= 0x020101
66 # include <opencv2/highgui/highgui.hpp>
67 #else
68 # include <highgui.h>
69 #endif
70 
104 class VISP_EXPORT vpROSGrabber : public vpFrameGrabber
105 {
106  protected:
107  ros::NodeHandle *n;
108  ros::Subscriber image_data;
109  ros::Subscriber image_info;
110  ros::AsyncSpinner *spinner;
111  volatile bool isInitialized;
112  volatile unsigned short usWidth;
113  volatile unsigned short usHeight;
114  image_geometry::PinholeCameraModel p;
115  cv::Mat data;
116  bool flip;
117  volatile bool _rectify;
118  volatile bool mutex_image, mutex_param;
119  void imageCallbackRaw(const sensor_msgs::Image::ConstPtr& msg);
120  void imageCallback(const sensor_msgs::CompressedImage::ConstPtr& msg);
121  void paramCallback(const sensor_msgs::CameraInfo::ConstPtr& msg);
122  volatile bool first_img_received, first_param_received;
123  volatile uint32_t _sec,_nsec;
124  std::string _master_uri;
125  std::string _topic_image;
126  std::string _topic_info;
127  std::string _nodespace;
128  std::string _image_transport;
129  vpCameraParameters _cam;
130  public:
131 
132  vpROSGrabber();
133  virtual ~vpROSGrabber();
134 
135  void open(int argc, char **argv);
136  void open();
137  void open(vpImage<unsigned char> &I);
138  void open(vpImage<vpRGBa> &I);
139 
140  void acquire(vpImage<unsigned char> &I);
141  void acquire(vpImage<vpRGBa> &I);
142  cv::Mat acquire();
143  bool acquireNoWait(vpImage<unsigned char> &I);
144  bool acquireNoWait(vpImage<vpRGBa> &I);
145 
146 
147  void acquire(vpImage<unsigned char> &I, struct timespec &timestamp);
148  void acquire(vpImage<vpRGBa> &I, struct timespec &timestamp);
149  cv::Mat acquire(struct timespec &timestamp);
150  bool acquireNoWait(vpImage<unsigned char> &I, struct timespec &timestamp);
151  bool acquireNoWait(vpImage<vpRGBa> &I, struct timespec &timestamp);
152 
153  void close();
154 
155  void setCameraInfoTopic(std::string topic_name);
156  void setImageTopic(std::string topic_name);
157  void setMasterURI(std::string master_uri);
158  void setNodespace(std::string nodespace);
159  void setImageTransport(std::string image_transport);
160  void setFlip(bool flipType);
161  void setRectify(bool rectify);
162 
163  bool getCameraInfo(vpCameraParameters &cam);
164  void getWidth(unsigned short &width) const;
165  void getHeight(unsigned short &height) const;
166  unsigned short getWidth() const;
167  unsigned short getHeight() const;
168 };
169 
170 #endif
171 #endif
172 
volatile unsigned short usWidth
Definition: vpROSGrabber.h:112
std::string _nodespace
Definition: vpROSGrabber.h:127
volatile uint32_t _sec
Definition: vpROSGrabber.h:123
Class for cameras video capture for ROS cameras.
Definition: vpROSGrabber.h:104
vpCameraParameters _cam
Definition: vpROSGrabber.h:129
volatile bool mutex_param
Definition: vpROSGrabber.h:118
volatile unsigned short usHeight
Definition: vpROSGrabber.h:113
volatile bool isInitialized
Definition: vpROSGrabber.h:111
std::string _image_transport
Definition: vpROSGrabber.h:128
ros::Subscriber image_data
Definition: vpROSGrabber.h:108
volatile bool _rectify
Definition: vpROSGrabber.h:117
ros::AsyncSpinner * spinner
Definition: vpROSGrabber.h:110
ros::Subscriber image_info
Definition: vpROSGrabber.h:109
std::string _topic_info
Definition: vpROSGrabber.h:126
std::string _master_uri
Definition: vpROSGrabber.h:124
void setImageTransport(std::string image_transport)
volatile bool first_param_received
Definition: vpROSGrabber.h:122
cv::Mat data
Definition: vpROSGrabber.h:115
ros::NodeHandle * n
Definition: vpROSGrabber.h:107
image_geometry::PinholeCameraModel p
Definition: vpROSGrabber.h:114
std::string _topic_image
Definition: vpROSGrabber.h:125


visp_ros
Author(s): Francois Pasteau, Fabien Spindler
autogenerated on Mon Mar 2 2015 01:32:56