xtion用openni2_launch openni2.launch就可以打开,但是在使用过程中有一些定制性问题:

首先弄清openni2_launch 中一些topic都是什么意思

http://wiki.ros.org/depth_image_proc

关于depthmap是米制还是毫米制:

All nodelets (besides convert_metric) in this package support both standard floating point depth images and OpenNI-specific uint16 depth images. Thus when working with OpenNI cameras (e.g. the Kinect), you can save a few CPU cycles by using the uint16 raw topics instead of the float topics.

/depth/image_raw是uint16格式

/depth_registered/image是CV32FC1

关于topic中rect解释:

http://wiki.ros.org/rgbd_launch

depth_processing (bool, default: true)

Given the raw depth image, rectifies it, converts both the raw and rectified images to metric format (uint16 -> float), and produces a pointcloud. Requires depth/image_raw. Produces depth/image_rect_raw (rectified), depth/image (metric), depth/image_rect (rectified, metric), depth/points (pointcloud).

depth_registered_processing (bool, default: true)

Generates a registered RGBD pointcloud from the device data (requires rgb_processing to be enabled). A pointcloud can be generated through a software registration pipeline (sw_registered_processing = true, used when depth_registration for device driver is set to false ) by registering the depth image from the depth frame to an RGB frame and merging with the RGB image. If software registration is being used, depth_processing needs to be enabled. Alternatively, the device can be directly asked to generate a registered depth image in the RGB frame with can be merged with the RGB Image through the hardware registration pipeline (hw_registered_processing = true, used when depth_registration for device driver is set to true)

在使用过程中出现了

/camera/depth_registered/sw_registered/image_rect_raw

图像显示之后出现很多不规则横杠和竖杠

更改为hw_registered模式就好了

具体更改openni2_launch openni2.launch里

<arg name="depth_registration" default="true" />就好了

关于怎么保存pcd文件

ros里提供了一个包 pcl_ros

使用pointcloud_to_pcd

以下是一个launch file

<launch>
<arg name="viewer" default = "true" />
<arg name="image_saver" default="false" />
<arg name="pcd_saver" default = "false" />
<node pkg="image_view" type="image_view" respawn="false" name="rgb_image_viewer" output="screen" if="$(arg viewer)">
<remap from="image" to="/camera/rgb/image_rect_color"/>
</node>
<node pkg="image_view" type="image_view" respawn="false" name="depth_image_viewer" output="screen" if="$(arg viewer)">
<remap from="image" to="/camera/depth_registered/hw_registered/image_rect"/>
</node> <include file="$(find openni2_launch)/launch/openni2.launch" /> <node pkg="pioneer_zed" type="test_sycronizer" name="rgb_depth_sycronizer" if="$(arg image_saver)"/> <node pkg="pcl_ros" type="pointcloud_to_pcd" name="pointcloud_to_pcd" output="screen" if="$(arg pcd_saver)">
<remap from="input" to="/camera/depth_registered/points"/>
<param name="prefix" value="/home/ubuntu/Workspaces/dataset/homemade/pcd/vel_" />
</node>
</launch>

rgb和depth同步问题

这个可以用message filter来实现

下面是一个程序实现:

#include <ros/ros.h>
#include "RGBDImgsSycronizer.h"
int main(int argc, char** argv)
{
ros::init(argc, argv, "tf_broadcaster");
ros::NodeHandle nh;
RGBDImgsSycronizer test_sycronizer(nh,"/camera/rgb/image_rect_color","/camera/depth_registered/hw_registered/image_rect_raw","/home/ubuntu/Workspaces/dataset/homemade");
ros::spin();
}
#include "RGBDImgsSycronizer.h"
#include <boost/bind/bind.hpp>
RGBDImgsSycronizer::~RGBDImgsSycronizer()
{
fs.release();
}
RGBDImgsSycronizer::RGBDImgsSycronizer(ros::NodeHandle& nh, string imageColorTopic, string imageDepthTopic,string storeDirectory):
nh_(nh),
imageDepth_sub(nh_, imageDepthTopic, ),
imageColor_sub(nh_, imageColorTopic, ),
sync(MySyncPolicy(), imageColor_sub, imageDepth_sub),
storePath(storeDirectory),
fs(storePath+"/depthData.yml", FileStorage::WRITE)
{
ROS_INFO("RGBDImgsSycronizer constrcting");
// ApproximateTime takes a queue size as its constructor argument, hence MySyncPolicy(10)
sync.registerCallback(boost::bind(&RGBDImgsSycronizer::call_back, this,_1, _2));
data_ready = false;
}
//注意这里需要加const
void RGBDImgsSycronizer::call_back(const ImageConstPtr &imageColor, const ImageConstPtr &imageDepth)
{
static int num = ;
ROS_INFO("recive");
cv_bridge::CvImagePtr imageColorPtr = cv_bridge::toCvCopy(imageColor);
OpencvimageColor = imageColorPtr->image;
cv_bridge::CvImagePtr imageDepthPtr = cv_bridge::toCvCopy(imageDepth);
OpencvImageDepth = imageDepthPtr->image; boost::format imageColorStr(storePath+"/color/imageColor%d.png"),imageDepthStr(storePath+"/depth/imageDepth%d.png");
imageColorStr%num;
imageDepthStr%num;
string strToDisplay = imageColorStr.str();
if(!OpencvimageColor.empty())
ROS_INFO("%s",strToDisplay.c_str());
//store color image
imwrite(imageColorStr.str(),OpencvimageColor);
//store depth data
boost::format imageDepthDataStr("imageDepthData%d");
imageDepthDataStr%num;
fs<<imageDepthDataStr.str()<<OpencvImageDepth; //store depth image
double* minVal = new double, *maxVal = new double;
Mat OpencvImageDepthImage;
OpencvImageDepth.copyTo(OpencvImageDepthImage);
minMaxIdx(OpencvImageDepthImage,minVal,maxVal);
ROS_INFO("OpencvImageDepthImage type:%d ",OpencvImageDepthImage.type());
if(maxVal==NULL)
ROS_INFO(" maxVal maxVal"); MatIterator_<float> it, end;
for( it = OpencvImageDepthImage.begin<float>(), end = OpencvImageDepthImage.end<float>(); it != end; ++it)
*it = ((*it)/(*maxVal)*);
Mat OpencvImageDepthImage8U; OpencvImageDepthImage.convertTo(OpencvImageDepthImage8U,CV_8UC1);
imwrite(imageDepthStr.str(),OpencvImageDepthImage8U);
num++;
delete minVal;
delete maxVal; } bool RGBDImgsSycronizer::is_data_ready()
{
if(data_ready)
return true;
else
return false;
}

ros下xtion用法的更多相关文章

  1. ROS下使用ASUS Xtion Pro Live

    一.ROS官网hydro版本OpenNI安装 3. Installation 3.1 Ubuntu installation To install only openni_camera: sudo a ...

  2. LSD-SLAM深入学习(1)-基本介绍与ros下的安装

    前言 借鉴来自RGB-D数据处理的两种方法-基于特征与基于整体的,同样可以考虑整个图片的匹配,而不是只考虑特征点的…… 一般这种稠密的方法需要很大的计算量,DTAM: Dense tracking a ...

  3. ros下多机器人系统(1)

    multi-robot system 经过两个多月的ros学习,对ros的认识有了比较深入的了解,本篇博客主要记录在ros下开发多机器人系统以及对ros更深入的开发.本篇博客是假定读者已经学习完了全部 ...

  4. ZED 相机 && ORB-SLAM2安装环境配置与ROS下的调试

    注:1. 对某些地方进行了更新(红色标注),以方便进行配置. 2. ZED ROS Wrapper官方github已经更新,根据描述新的Wrapper可能已经不适用与Ros Indigo了,如果大家想 ...

  5. pl-svo在ROS下运行笔记

    一.程序更改的思路(参考svo_ros的做法): 1.在ROS下将pl-svo链接成库需要更改相应的CMakeLists.txt文件,添加package.xml文件: 2.注册一个ROS节点使用svo ...

  6. ORB-SLAM2(2) ROS下配置和编译

    1配置USB相机 1.1网友参考: http://www.liuxiao.org/2016/07/ubuntu-orb-slam2-%E5%9C%A8-ros-%E4%B8%8A%E7%BC%96%E ...

  7. linux下automake用法

    linux下automake用法 2017年02月06日 09:21:14 阅读数:3684 标签: makemakefilegnulinux   作为Linux下的程序开发人员,大家一定都遇到过Ma ...

  8. ros下基于百度语音的,语音识别和语音合成

    代码地址如下:http://www.demodashi.com/demo/13153.html 概述: 本demo是ros下基于百度语音的,语音识别和语音合成,能够实现文字转语音,语音转文字的功能. ...

  9. 转:关于rename命令ubuntu下的用法

    下面是我的遭遇:上午想批量改几个文件的名字,觉得mv在批量方面不够方便,百度到了rename这个命令,原谅我吧,我总是在百度不到结果时才去看google,以后还是少去百度的好国内很多贴子都在说linu ...

随机推荐

  1. Python + OpenCV 实现LBP特征提取

    背景 看了些许的纹理特征提取的paper,想自己实现其中部分算法,看看特征提取之后的效果是怎样 运行环境 Mac OS Python3.0 Anaconda3(集成了很多包,浏览器界面编程,清爽) 步 ...

  2. 关于<!DOCTYPE html>的学习(转)

    DOCTYPE是对Document type的缩写,说明用XHTML或者HTML是什么版本的.必须出现在<html>标签的前面,不需要关闭标签. <!DOCTYPE>声明不是标 ...

  3. CentOS6.8单独编译安装PHP gd库扩展

    # PHP-GD安装 #在安装之前可以先更新一下yum源,可以使用国内的阿里云源 yum -y install libjpeg-turbo-devel yum -y install freetype- ...

  4. sping事务的理解

    阅读数:2020 一.事务的基本原理 Spring事务的本质其实就是数据库对事务的支持,没有数据库的事务支持,spring是无法提供事务功能的.对于纯JDBC操作数据库,想要用到事务,可以按照以下步骤 ...

  5. lintcode-62-搜索旋转排序数组

    62-搜索旋转排序数组 假设有一个排序的按未知的旋转轴旋转的数组(比如,0 1 2 4 5 6 7 可能成为4 5 6 7 0 1 2).给定一个目标值进行搜索,如果在数组中找到目标值返回数组中的索引 ...

  6. capacilitys 持续集成

    目前看好像是说以docker为例来看看这个权限到底是怎么来的? 可以通过在二进制上setcap得到,也可以通过函数自己用setcap得到,两种方法,docker肯定是第二种方法啊,docker中间肯定 ...

  7. 【python】python各种类型转换-int,str,char,float,ord,hex,oct等

    [python] int(x [,base ])         将x转换为一个整数 long(x [,base ])        将x转换为一个长整数 float(x )             ...

  8. arc068 E: Snuke Line

    首先要知道 (m/1 + m/2 + ... + m/m) 约为 mlogm 还有一个比较明显的结论,如果一个纪念品区间长度大于d,那么如果列车的停车间隔小于等于d,则这个纪念品一定能被买到 然后把区 ...

  9. 洛谷 P1251 餐巾计划问题

    题目链接 最小费用最大流. 每天拆成两个点,早上和晚上: 晚上可以获得\(r_i\)条脏毛巾,从源点连一条容量为\(r_i\),费用为0的边. 早上要供应\(r_i\)条毛巾,连向汇点一条容量为\(r ...

  10. vue.js 三种方式安装--npm安装

    Vue.js是一个构建数据驱动的 web 界面的渐进式框架.     Vue.js 的目标是通过简单的 API 实现响应的数据绑定和组合的视图组件.它不仅易上手,便于与第三方库或既有项目整合.     ...