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. Hadoop执行bin/stop-all.sh时no namenode to stop异常

    1 先关闭hadoop所有服务 命令: bin/stop-all.sh 2 格式化namenode 命令: bin/hadoop namenode -format 3 重新启动所有服务 命令: bin ...

  2. springMVC前后台数据交互

    假设项目需求是在springMVC框架下,后台要传送一个list到前台,那我们就要做以下几个步骤: 1 在web.xml文件中进行springMVC的配置: <?xml version=&quo ...

  3. vue2.0中父子组件之间的通信总结

    父组件: 子组件: 接受父组件的信息: 向父组件发送事件: (其中slot是插槽,可以将父组件中的<p>123</p>插入进来,如果父组件没有插入的内容,则显示slot内部的内 ...

  4. 如何在MyEclipse下查看JDK源代码

    在MyEclipse中查看JDK类库的源代码~ 设置: 1.点 "window"-> "Preferences" -> "Java&quo ...

  5. 并发(二)CyclicBarrier

    CyclicBarrier 循环屏障,用于一组固定数目的线程互相等待.使用场景如下: 主任务有一组串行的执行节点,每个节点之间有一批任务,固定数量的线程执行这些任务,执行完成后,在节点完成集合后,再继 ...

  6. 【bzoj2124】等差子序列 STL-bitset

    题目描述 给一个1到N的排列{Ai},询问是否存在1<=p1<p2<p3<p4<p5<…<pLen<=N (Len>=3),使得Ap1,Ap2,A ...

  7. LeetCode -- Linked List Circle ii

    Question: Given a linked list, return the node where the cycle begins. If there is no cycle, return  ...

  8. hbase(0.94) get、scan源码分析

    简介 本文是需要用到hbase timestamp性质时研究源码所写.内容有一定侧重.且个人理解不算深入,如有错误请不吝指出. 如何看源码 hbase依赖很重,没有独立的client包.所以目前如果在 ...

  9. 【CF MEMSQL 3.0 B. Lazy Security Guard】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  10. python并发进程

    1 引言 2 创建进程 2.1 通过定义函数的方式创建进程 2.2 通过定义类的方式创建进程 3 Process中常用属性和方法 3.1 守护进程:daemon 3.2 进程终结于存活检查:termi ...