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. javascript知识总结

    javascript: 面对对象 函数创建方式: 1.工厂模式 function createPerson(name, age, job){ var o = new Object(); //创建工厂对 ...

  2. 基于Thinkphp5+phpQuery 网络爬虫抓取数据接口,统一输出接口数据api

    TP5_Splider 一个基于Thinkphp5+phpQuery 网络爬虫抓取数据接口 统一输出接口数据api.适合正在学习Vue,AngularJs框架学习 开发demo,需要接口并保证接口不跨 ...

  3. 【转】Visio画用例模型图竟然没有include关系

    转自:http://blog.csdn.net/shuixin536/article/details/8289746 由于电脑上没有安装Rose,因此决定用visio来画UML中的用例模型图,在绘制的 ...

  4. [Leetcode] unique paths 独特路径

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...

  5. 获得edittext的图片大小

    1.在布局文件中编写控件,有2张图片 <EditText android:id="@+id/edit" android:background="@drawable/ ...

  6. POJ 3104 Drying(二分

    Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22163   Accepted: 5611 Descripti ...

  7. js中连写两个?:三元运算符语法解释

    在angular 源码中有连写两个三元运算符的代码: var hash = isString(hash) ? hash : isNumber(hash) ? hash.toString() :$loc ...

  8. Collection与Map的对比

    Map:HashMap.HashTable  如何在它们之间选择  一.Array , Arrays  Java所有“存储及随机访问一连串对象”的做法,array是最有效率的一种.  1.  效率高, ...

  9. 7月18号day10总结

    今天学习过程和小结 今天学会了用git从GitHub上克隆代码然后打包成jar包,然后在idea程序中引入这个jar包的依赖来使用jar包中的程序. 通过这个中的网址: 在Git Bash Here中 ...

  10. CentOS 6.5 Linux 安装 openoffice

    资源准备: Apache_OpenOffice_4.1.4_Linux_x86-64_install-rpm_zh-CN.tar.gz 编译安装: 本人资源包放在 /opt/moudles 中, 解压 ...