50 #if defined(VISP_HAVE_OPENCV) 52 #include <visp/vpImageConvert.h> 53 #include <visp/vpFrameGrabberException.h> 54 #include <sensor_msgs/CompressedImage.h> 67 first_img_received(false),
68 first_param_received(false),
71 _topic_image(
"image"),
72 _topic_info(
"camera_info"),
73 _master_uri(
"http://localhost:11311"),
75 _image_transport(
"raw"),
153 throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
159 argv[0] =
new char [255];
160 argv[1] =
new char [255];
162 std::string exe =
"ros.exe", arg1 =
"__master:=";
163 strcpy(argv[0], exe.c_str());
165 strcpy(argv[1], arg1.c_str());
226 throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
"Grabber not initialized.") );
230 timestamp . tv_sec =
_sec;
231 timestamp . tv_nsec =
_nsec;
232 vpImageConvert::convert(
data, I,
flip);
255 bool new_image =
false;
258 throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
"Grabber not initialized.") );
262 timestamp . tv_sec =
_sec;
263 timestamp . tv_nsec =
_nsec;
264 vpImageConvert::convert(
data, I,
flip);
287 throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
"Grabber not initialized.") );
291 timestamp . tv_sec =
_sec;
292 timestamp . tv_nsec =
_nsec;
293 vpImageConvert::convert(
data, I,
flip);
316 bool new_image =
false;
319 throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
"Grabber not initialized.") );
323 timestamp . tv_sec =
_sec;
324 timestamp . tv_nsec =
_nsec;
325 vpImageConvert::convert(
data, I,
flip);
349 throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
"Grabber not initialized.") );
353 timestamp . tv_sec =
_sec;
354 timestamp . tv_nsec =
_nsec;
355 retour =
data.clone();
374 struct timespec timestamp;
393 struct timespec timestamp;
409 struct timespec timestamp;
428 struct timespec timestamp;
444 struct timespec timestamp;
613 throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
"Grabber not initialized.") );
630 cv::Mat data_t = cv::imdecode(msg->data,1);
631 cv::Size data_size = data_t.size();
642 _sec = msg->header.stamp.sec;
643 _nsec = msg->header.stamp.nsec;
659 ROS_ERROR(
"cv_bridge exception: %s", e.what());
665 cv_ptr->image.copyTo(
data);
667 cv::Size data_size =
data.size();
670 _sec = msg->header.stamp.sec;
671 _nsec = msg->header.stamp.nsec;
volatile unsigned short usWidth
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
void imageCallbackRaw(const sensor_msgs::Image::ConstPtr &msg)
ROSCPP_DECL const std::string & getURI()
volatile bool first_img_received
void setRectify(bool rectify)
void setFlip(bool flipType)
vpCameraParameters toVispCameraParameters(const sensor_msgs::CameraInfo &cam_info)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
volatile bool mutex_param
ROSCPP_DECL bool isInitialized()
void setCameraInfoTopic(std::string topic_name)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool acquireNoWait(vpImage< unsigned char > &I)
bool getCameraInfo(vpCameraParameters &cam)
void paramCallback(const sensor_msgs::CameraInfo::ConstPtr &msg)
volatile unsigned short usHeight
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
volatile bool isInitialized
void rectifyImage(const cv::Mat &raw, cv::Mat &rectified, int interpolation=cv::INTER_LINEAR) const
ROSCPP_DECL bool get(const std::string &key, std::string &s)
bool fromCameraInfo(const sensor_msgs::CameraInfo &msg)
std::string _image_transport
ros::Subscriber image_data
unsigned short getHeight() const
void imageCallback(const sensor_msgs::CompressedImage::ConstPtr &msg)
ros::AsyncSpinner * spinner
void setImageTransport(std::string image_transport)
class for Camera video capture for ROS middleware.
ros::Subscriber image_info
volatile bool mutex_image
void setNodespace(std::string nodespace)
void setMasterURI(std::string master_uri)
volatile bool first_param_received
void setImageTopic(std::string topic_name)
image_geometry::PinholeCameraModel p
unsigned short getWidth() const