本文整理汇总了C++中image_transport::CameraPublisher类的典型用法代码示例。如果您正苦于以下问题:C++ CameraPublisher类的具体用法?C++ CameraPublisher怎么用?C++ CameraPublisher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CameraPublisher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: publishRgbImage
void OpenNINode::publishRgbImage(const openni_wrapper::Image& rgb_img, image_transport::CameraPublisher img_pub) const {
sensor_msgs::ImagePtr rgb_msg = boost::make_shared<sensor_msgs::Image>();
ros::Time time = ros::Time::now();
rgb_msg->header.stamp = time;
rgb_msg->encoding = enc::RGB8;
rgb_msg->width = depth_width_;
rgb_msg->height = depth_height_;
rgb_msg->step = rgb_msg->width * 3;
rgb_msg->data.resize(rgb_msg->height * rgb_msg->step);
rgb_img.fillRGB(rgb_msg->width, rgb_msg->height, reinterpret_cast<unsigned char*>(&rgb_msg->data[0]), rgb_msg->step);
img_pub.publish(rgb_msg, getDepthCameraInfo(rgb_msg->width, rgb_msg->height, time, 1));
}
开发者ID:Rbelder,项目名称:saphari_final_review,代码行数:14,代码来源:driver.cpp
示例2: publishframe
void publishframe(camera_info_manager::CameraInfoManager *mgr, const image_transport::CameraPublisher &campub, const sensor_msgs::ImagePtr img, const std::string& frame)
{
ros::Time timestamp = ros::Time::now();
sensor_msgs::CameraInfo::Ptr cinfo(new sensor_msgs::CameraInfo(mgr->getCameraInfo()));
std_msgs::Header::Ptr imageheader(new std_msgs::Header());
std_msgs::Header::Ptr cinfoheader(new std_msgs::Header());
imageheader->frame_id = frame;
cinfoheader->frame_id = frame;
imageheader->stamp = timestamp;
cinfoheader->stamp = timestamp;
img->header = *imageheader;
cinfo->header = *cinfoheader;
campub.publish(img, cinfo);
}
开发者ID:Galactus,项目名称:ROS_OpenLeap,代码行数:14,代码来源:ros_leap_driver.cpp
示例3: publishDepthImage
void OpenNINode::publishDepthImage(const openni_wrapper::DepthImage& depth, image_transport::CameraPublisher depth_pub) const {
sensor_msgs::ImagePtr depth_msg = boost::make_shared<sensor_msgs::Image>();
ros::Time time = ros::Time::now();
depth_msg->header.stamp = time;
depth_msg->encoding = sensor_msgs::image_encodings::TYPE_32FC1;
depth_msg->width = depth_width_;
depth_msg->height = depth_height_;
depth_msg->step = depth_msg->width * sizeof(float);
depth_msg->data.resize(depth_msg->height * depth_msg->step);
depth.fillDepthImage(depth_msg->width, depth_msg->height, reinterpret_cast<float*>(&depth_msg->data[0]), depth_msg->step);
depth_pub.publish(depth_msg, getDepthCameraInfo(depth_msg->width, depth_msg->height, time, 1));
//pub.publish(depth_msg);
}
开发者ID:Rbelder,项目名称:saphari_final_review,代码行数:15,代码来源:driver.cpp
示例4: spin
/// Continuously advertises xyz and grey images.
bool spin()
{
boost::mutex::scoped_lock lock(service_mutex_);
sensor_msgs::Image::Ptr xyz_image_msg_ptr;
sensor_msgs::Image::Ptr grey_image_msg_ptr;
sensor_msgs::CameraInfo tof_image_info;
if(tof_camera_->AcquireImages(0, &grey_image_32F1_, &xyz_image_32F3_, false, false, ipa_CameraSensors::INTENSITY) & ipa_Utils::RET_FAILED)
{
ROS_ERROR("[tof_camera] Tof image acquisition failed");
return false;
}
/// Filter images by amplitude and remove tear-off edges
//if(filter_xyz_tearoff_edges_ || filter_xyz_by_amplitude_)
// ROS_ERROR("[tof_camera] FUNCTION UNCOMMENT BY JSF");
if(filter_xyz_tearoff_edges_) ipa_Utils::FilterTearOffEdges(xyz_image_32F3_, 0, (float)tearoff_tear_half_fraction_);
if(filter_xyz_by_amplitude_) ipa_Utils::FilterByAmplitude(xyz_image_32F3_, grey_image_32F1_, 0, 0, lower_amplitude_threshold_, upper_amplitude_threshold_);
try
{
IplImage img = xyz_image_32F3_;
xyz_image_msg_ptr = sensor_msgs::CvBridge::cvToImgMsg(&img, "passthrough");
}
catch (sensor_msgs::CvBridgeException error)
{
ROS_ERROR("[tof_camera] Could not convert 32bit xyz IplImage to ROS message");
return false;
}
try
{
IplImage img = grey_image_32F1_;
grey_image_msg_ptr = sensor_msgs::CvBridge::cvToImgMsg(&img, "passthrough");
}
catch (sensor_msgs::CvBridgeException error)
{
ROS_ERROR("[tof_camera] Could not convert 32bit grey IplImage to ROS message");
return false;
}
/// Set time stamp
ros::Time now = ros::Time::now();
xyz_image_msg_ptr->header.stamp = now;
grey_image_msg_ptr->header.stamp = now;
tof_image_info = camera_info_msg_;
tof_image_info.width = grey_image_32F1_.cols;
tof_image_info.height = grey_image_32F1_.rows;
tof_image_info.header.stamp = now;
/// publish message
xyz_image_publisher_.publish(*xyz_image_msg_ptr, tof_image_info);
grey_image_publisher_.publish(*grey_image_msg_ptr, tof_image_info);
return true;
}
开发者ID:ipa-mars,项目名称:care-o-bot,代码行数:58,代码来源:tof_camera.cpp
示例5: imageCB
void imageCB(const sensor_msgs::ImageConstPtr& image_l,
const sensor_msgs::CameraInfoConstPtr& info_l,
const sensor_msgs::ImageConstPtr& image_r,
const sensor_msgs::CameraInfoConstPtr& info_r) {
sensor_msgs::Image img = *image_r;
sensor_msgs::CameraInfo info = *info_r;
//img.header.stamp = image_l->header.stamp;
//info.header.stamp = info_l->header.stamp;
pub_left_.publish(image_l, info_l);
pub_right_.publish(img, info, info_l->header.stamp);
//pub_right_.publish(*image_r, *info_r, info_l->header.stamp);
}
开发者ID:130s,项目名称:jsk_common,代码行数:15,代码来源:stereo_synchronizer.cpp
示例6: ir_img
void
pubRealSenseInfraredImageMsg(cv::Mat& ir_mat)
{
sensor_msgs::ImagePtr ir_img(new sensor_msgs::Image);;
ir_img->header.seq = head_sequence_id;
ir_img->header.stamp = head_time_stamp;
ir_img->header.frame_id = depth_frame_id;
ir_img->width = ir_mat.cols;
ir_img->height = ir_mat.rows;
ir_img->encoding = sensor_msgs::image_encodings::MONO8;
ir_img->is_bigendian = 0;
int step = sizeof(unsigned char) * ir_img->width;
int size = step * ir_img->height;
ir_img->step = step;
ir_img->data.resize(size);
memcpy(&ir_img->data[0], ir_mat.data, size);
ir_camera_info->header.frame_id = depth_frame_id;
ir_camera_info->header.stamp = head_time_stamp;
ir_camera_info->header.seq = head_sequence_id;
realsense_infrared_image_pub.publish(ir_img, ir_camera_info);
}
开发者ID:nlyubova,项目名称:realsense_camera,代码行数:28,代码来源:realsense_camera.cpp
示例7: depth_img
void
pubRealSenseDepthImageMsg32F(cv::Mat& depth_mat)
{
sensor_msgs::ImagePtr depth_img(new sensor_msgs::Image);
depth_img->header.seq = head_sequence_id;
depth_img->header.stamp = head_time_stamp;
depth_img->header.frame_id = depth_frame_id;
depth_img->width = depth_mat.cols;
depth_img->height = depth_mat.rows;
depth_img->encoding = sensor_msgs::image_encodings::TYPE_32FC1;
depth_img->is_bigendian = 0;
int step = sizeof(float) * depth_img->width;
int size = step * depth_img->height;
depth_img->step = step;
depth_img->data.resize(size);
memcpy(&depth_img->data[0], depth_mat.data, size);
ir_camera_info->header.frame_id = depth_frame_id;
ir_camera_info->header.stamp = head_time_stamp;
ir_camera_info->header.seq = head_sequence_id;
/*double minVal, maxVal;
cv::minMaxLoc(depth_mat, &minVal, &maxVal);
std::cout << " ***** " << minVal << " " << maxVal << std::endl;*/
realsense_depth_image_pub.publish(depth_img, ir_camera_info);
//pub_depth_info.publish(ir_camera_info);
}
开发者ID:nlyubova,项目名称:realsense_camera,代码行数:32,代码来源:realsense_camera.cpp
示例8: connectCb
// Handles (un)subscribing when clients (un)subscribe
void CropDecimateNodelet::connectCb()
{
boost::lock_guard<boost::mutex> lock(connect_mutex_);
if (pub_.getNumSubscribers() == 0)
sub_.shutdown();
else if (!sub_)
sub_ = it_in_->subscribeCamera("image_raw", queue_size_, &CropDecimateNodelet::imageCb, this);
}
开发者ID:strawlab,项目名称:image_pipeline,代码行数:9,代码来源:crop_decimate.cpp
示例9:
virtual ~SensorStreamManager()
{
stream_.removeNewFrameListener(this);
stream_.stop();
stream_.destroy();
publisher_.shutdown();
}
开发者ID:amiltonwong,项目名称:openni2_camera,代码行数:8,代码来源:camera.cpp
示例10: getNumDepthSubscribers
int getNumDepthSubscribers()
{
int n = realsense_points_pub.getNumSubscribers() + realsense_reg_points_pub.getNumSubscribers() + realsense_depth_image_pub.getNumSubscribers();
#ifdef V4L2_PIX_FMT_INZI
n += realsense_infrared_image_pub.getNumSubscribers();
#endif
return n;
}
开发者ID:nlyubova,项目名称:realsense_camera,代码行数:8,代码来源:realsense_camera.cpp
示例11: publishImage
void publishImage (FlyCapture2::Image * frame)
{
//sensor_msgs::CameraInfoPtr cam_info(new sensor_msgs::CameraInfo(cam_info_->getCameraInfo()));
// or with a member variable:
cam_info_ptr_ = sensor_msgs::CameraInfoPtr(new sensor_msgs::CameraInfo(cam_info_mgr_->getCameraInfo()));
if (processFrame (frame, img_, cam_info_ptr_))
streaming_pub_.publish (img_, *cam_info_ptr_);
}
开发者ID:ccny-ros-pkg,项目名称:ccny_camera_drivers,代码行数:9,代码来源:pgr_camera_node.cpp
示例12: stop
void stop ()
{
if (!running)
return;
cam_->stop (); // Must stop camera before streaming_pub_.
poll_srv_.shutdown ();
streaming_pub_.shutdown ();
running = false;
}
开发者ID:ccny-ros-pkg,项目名称:ccny_camera_drivers,代码行数:11,代码来源:pgr_camera_node.cpp
示例13: connectCb
// Handles (un)subscribing when clients (un)subscribe
void CropDecimateNodelet::connectCb()
{
boost::lock_guard<boost::mutex> lock(connect_mutex_);
if (pub_.getNumSubscribers() == 0)
sub_.shutdown();
else if (!sub_)
{
image_transport::TransportHints hints("raw", ros::TransportHints(), getPrivateNodeHandle());
sub_ = it_in_->subscribeCamera("image_raw", queue_size_, &CropDecimateNodelet::imageCb, this, hints);
}
}
开发者ID:OSURoboticsClub,项目名称:Rover2016,代码行数:12,代码来源:crop_decimate.cpp
示例14: onSubscriptionChanged
virtual void onSubscriptionChanged(const image_transport::SingleSubscriberPublisher& topic)
{
size_t disparity_clients = disparity_publisher_.getNumSubscribers() + disparity_registered_publisher_.getNumSubscribers();
size_t depth_clients = publisher_.getNumSubscribers() + depth_registered_publisher_.getNumSubscribers();
size_t all_clients = disparity_clients + depth_clients;
if(!running_ && all_clients > 0)
{
running_ = (stream_.start() == STATUS_OK);
}
else if(running_ && all_clients == 0)
{
stream_.stop();
running_ = false;
}
if(running_)
{
updateActivePublisher();
}
}
开发者ID:amiltonwong,项目名称:openni2_camera,代码行数:21,代码来源:camera.cpp
示例15: take_and_send_image
bool take_and_send_image()
{
usb_cam_camera_grab_image(camera_image_);
fillImage(img_, "rgb8", camera_image_->height, camera_image_->width, 3 * camera_image_->width, camera_image_->image);
img_.header.stamp = ros::Time::now();
sensor_msgs::CameraInfoPtr ci(new sensor_msgs::CameraInfo(cinfo_->getCameraInfo()));
ci->header.frame_id = img_.header.frame_id;
ci->header.stamp = img_.header.stamp;
image_pub_.publish(img_, *ci);
return true;
}
开发者ID:eigendreams,项目名称:workspace,代码行数:13,代码来源:usb_cam_node.cpp
示例16: take_and_send_image
bool take_and_send_image()
{
// grab the image
cam_.grab_image(&img_);
// grab the camera info
sensor_msgs::CameraInfoPtr ci(new sensor_msgs::CameraInfo(cinfo_->getCameraInfo()));
ci->header.frame_id = img_.header.frame_id;
ci->header.stamp = img_.header.stamp;
// publish the image
image_pub_.publish(img_, *ci);
return true;
}
开发者ID:tuloski,项目名称:SherpaHighLevel,代码行数:15,代码来源:usb_cam_node.cpp
示例17: rgb_img
void
pubRealSenseRGBImageMsg(cv::Mat& rgb_mat)
{
sensor_msgs::ImagePtr rgb_img(new sensor_msgs::Image);
rgb_img->header.seq = head_sequence_id;
rgb_img->header.stamp = head_time_stamp;
rgb_img->header.frame_id = rgb_frame_id;
rgb_img->width = rgb_mat.cols;
rgb_img->height = rgb_mat.rows;
rgb_img->encoding = sensor_msgs::image_encodings::BGR8;
rgb_img->is_bigendian = 0;
int step = sizeof(unsigned char) * 3 * rgb_img->width;
int size = step * rgb_img->height;
rgb_img->step = step;
rgb_img->data.resize(size);
memcpy(&(rgb_img->data[0]), rgb_mat.data, size);
rgb_camera_info->header.frame_id = rgb_frame_id;
rgb_camera_info->header.stamp = head_time_stamp;
rgb_camera_info->header.seq = head_sequence_id;
realsense_rgb_image_pub.publish(rgb_img, rgb_camera_info);
//pub_rgb_info.publish(rgb_camera_info);
//save rgb img
// static int count = 0;
// count++;
// if(count > 0)
// {
// struct timeval save_time;
// gettimeofday( &save_time, NULL );
// char save_name[256];
// sprintf(save_name, "~/temp/realsense_rgb_%d.jpg", (int)save_time.tv_sec);
// printf("\nsave realsense rgb img: %s\n", save_name);
// cv::imwrite(save_name, rgb_mat);
// count = 0;
// }
}
开发者ID:nlyubova,项目名称:realsense_camera,代码行数:43,代码来源:realsense_camera.cpp
示例18: publish
/** Publish camera stream topics
*
* @pre image_ contains latest camera frame
*/
void publish()
{
image_.header.frame_id = config_.frame_id;
// get current CameraInfo data
cam_info_ = cinfo_->getCameraInfo();
//ROS_INFO_STREAM ("cam: " << cam_info_.width << " x " << cam_info_.height << ", image: " << image_.width << " x " << image_.height);
if (cam_info_.height != image_.height || cam_info_.width != image_.width)
{
// image size does not match: publish a matching uncalibrated
// CameraInfo instead
if (calibration_matches_)
{
// warn user once
calibration_matches_ = false;
ROS_WARN_STREAM("[" << camera_name_
<< "] camera_info_url: " << config_.camera_info_url);
ROS_WARN_STREAM("[" << camera_name_
<< "] calibration (" << cam_info_.width << "x" << cam_info_.height << ") does not match video mode (" << image_.width << "x" << image_.height << ") "
<< "(publishing uncalibrated data)");
}
cam_info_ = sensor_msgs::CameraInfo();
cam_info_.height = image_.height;
cam_info_.width = image_.width;
}
else if (!calibration_matches_)
{
// calibration OK now
calibration_matches_ = true;
ROS_INFO_STREAM("[" << camera_name_
<< "] calibration matches video mode now");
}
cam_info_.header.frame_id = config_.frame_id;
cam_info_.header.stamp = image_.header.stamp;
// @todo log a warning if (filtered) time since last published
// image is not reasonably close to configured frame_rate
// Publish via image_transport
image_pub_.publish(image_, cam_info_);
}
开发者ID:isk2,项目名称:Flylab,代码行数:47,代码来源:camera1394v2.cpp
示例19: constMaskCb
void constMaskCb(const stereo_msgs::DisparityImageConstPtr& msg)
{
if(!image_rect.empty())
{
cv::Mat masked;
image_rect.copyTo(masked, mask);
cv_bridge::CvImage masked_msg;
masked_msg.header = msg->header;
masked_msg.encoding = sensor_msgs::image_encodings::BGR8;
//if we want rescale then rescale
if(scale_factor > 1)
{
cv::Mat masked_tmp = masked;
cv::resize(masked_tmp, masked,
cv::Size(masked.cols*scale_factor, masked.rows*scale_factor));
}
masked_msg.image = masked;
cam_pub.publish(*masked_msg.toImageMsg(), camera_info);
}
// ROS_INFO("disparityCb runtime: %f ms",
// 1000*(cv::getTickCount() - ticksBefore)/cv::getTickFrequency());
}
开发者ID:achuwilson,项目名称:pal_image_processing,代码行数:24,代码来源:disparity_segmentation.cpp
示例20: spin
/// Callback function for image requests on topic 'request_image'
void spin()
{
ros::Rate rate(3);
while(node_handle_.ok())
{
// ROS images
sensor_msgs::Image right_color_image_msg;
sensor_msgs::Image left_color_image_msg;
sensor_msgs::Image xyz_tof_image_msg;
sensor_msgs::Image grey_tof_image_msg;
// ROS camera information messages
sensor_msgs::CameraInfo right_color_image_info;
sensor_msgs::CameraInfo left_color_image_info;
sensor_msgs::CameraInfo tof_image_info;
ros::Time now = ros::Time::now();
// Acquire left color image
if (left_color_camera_)
{
//ROS_INFO("[all_cameras] LEFT");
/// Release previously acquired IplImage
if (left_color_image_8U3_)
{
cvReleaseImage(&left_color_image_8U3_);
left_color_image_8U3_ = 0;
}
/// Acquire new image
if (left_color_camera_->GetColorImage2(&left_color_image_8U3_, false) & ipa_Utils::RET_FAILED)
{
ROS_ERROR("[all_cameras] Left color image acquisition failed");
break;
}
try
{
left_color_image_msg = *(sensor_msgs::CvBridge::cvToImgMsg(left_color_image_8U3_, "bgr8"));
}
catch (sensor_msgs::CvBridgeException error)
{
ROS_ERROR("[all_cameras] Could not convert left IplImage to ROS message");
break;
}
left_color_image_msg.header.stamp = now;
left_color_image_info = left_color_camera_info_message_;
left_color_image_info.width = left_color_image_8U3_->width;
left_color_image_info.height = left_color_image_8U3_->height;
left_color_image_info.header.stamp = now;
left_color_image_publisher_.publish(left_color_image_msg, left_color_image_info);
}
// Acquire right color image
if (right_color_camera_)
{
//ROS_INFO("[all_cameras] RIGHT");
/// Release previously acquired IplImage
if (right_color_image_8U3_)
{
cvReleaseImage(&right_color_image_8U3_);
right_color_image_8U3_ = 0;
}
/// Acquire new image
if (right_color_camera_->GetColorImage2(&right_color_image_8U3_, false) & ipa_Utils::RET_FAILED)
{
ROS_ERROR("[all_cameras] Right color image acquisition failed");
break;
}
try
{
right_color_image_msg = *(sensor_msgs::CvBridge::cvToImgMsg(right_color_image_8U3_, "bgr8"));
}
catch (sensor_msgs::CvBridgeException error)
{
ROS_ERROR("[all_cameras] Could not convert right IplImage to ROS message");
break;
}
right_color_image_msg.header.stamp = now;
right_color_image_info = right_color_camera_info_message_;
right_color_image_info.width = right_color_image_8U3_->width;
right_color_image_info.height = right_color_image_8U3_->height;
right_color_image_info.header.stamp = now;
right_color_image_publisher_.publish(right_color_image_msg, right_color_image_info);
}
// Acquire image from tof camera
if (tof_camera_)
{
//ROS_INFO("[all_cameras] TOF");
/// Release previously acquired IplImage
if (xyz_tof_image_32F3_)
{
//.........这里部分代码省略.........
开发者ID:Kuhn1981,项目名称:care-o-bot,代码行数:101,代码来源:all_cameras.cpp
注:本文中的image_transport::CameraPublisher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论