• 大小: 12KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: 其他
  • 标签: ROS  Kinect  

资源简介

这是在ROS下同时采集彩色图和深度图的代码包。博客:https://blog.csdn.net/crp997576280/article/details/88377871 对应的代码包,具体使用步骤可以参考博客。如果你的积分不够可以留下邮箱,我看到的时候会发送到你的邮箱当中去。

资源截图

代码片段和文件信息

/**
 * 
 * 函数功能:采集iaikinect2输出的彩色图和深度图数据,并以文件的形式进行存储
 * 
 * 
 * 分隔符为 逗号‘,‘  
 * 时间戳单位为秒(s) 精确到小数点后6位(us)
 * 
 * maker:crp
 * 2017-5-13
 */

#include
#include
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 

#include //将ROS下的sensor_msgs/Image消息类型转化成cv::Mat。
#include//头文件sensor_msgs/Image是ROS下的图像的类型,这个头文件中包含对图像进行编码的函数

#include 
#include 
#include 
#include
#include
#include 
#include
#include 
#include 

using namespace std;
using namespace cv;

Mat rgb depth;
char successed_flag1 =0successed_flag2=0;

string topic1_name = “/kinect2/qhd/image_color“; //topic 名称
string topic2_name = “/kinect2/qhd/image_depth_rect“;

string filename_rgbdata=“/home/crp/recordData/RGBD/rgbdata.txt“;
string filename_depthdata=“/home/crp/recordData/RGBD/depthdata.txt“;
string save_imagedata = “/home/crp/recordData/RGBD/“;

bool display_IMU5211( unsigned char buf[21] timeval time_stampstring &out_result);
void dispDepth(const cv::Mat &in cv::Mat &out const float maxValue);
void  callback_function_color( const sensor_msgs::Image::ConstPtr  image_data);
void  callback_function_depth( const sensor_msgs::Image::ConstPtr  image_data);
int main(int argcchar** argv)
{
    string out_result;

    namedWindow(“image color“CV_WINDOW_AUTOSIZE);
    namedWindow(“image depth“CV_WINDOW_AUTOSIZE);
    ros::init(argcargv“kinect2_listen“);
    if(!ros::ok())
             return 0;
    ros::NodeHandle n;
    ros::Subscriber sub1 = n.subscribe(topic1_name50callback_function_color);
    ros::Subscriber sub2 = n.subscribe(topic2_name50callback_function_depth);
    ros::AsyncSpinner spinner(3); // Use 3 threads
    spinner.start();

   string rgb_str dep_str;

   struct timeval time_val;
   struct timezone tz;
   double time_stamp;

    ofstream fout_rgb(filename_rgbdata.c_str());
    if(!fout_rgb)
    {
            cerr<    }

    ofstream fout_depth(filename_depthdata.c_str());
    if(!fout_depth)
    {
         cerr<    }

    while(ros::ok())
    {

             if( successed_flag1 )
            {
                 gettimeofday(&time_val&tz);//us
//  time_stamp =time_val.tv_sec+ time_val.tv_usec/1000000.0;
                 ostringstream os_rgb;
                 os_rgb<                 rgb_str = save_imagedata+“rgb/“+os_rgb.str()+“.png“;
                  imwrite(rgb_strrgb);
                  fout_rgb<                  successed_flag1=0;
  imshow(“image

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-03-10 15:26  save_rgbd_from_kinect2\
     文件        6741  2019-03-10 15:26  save_rgbd_from_kinect2\CMakeLists.txt
     文件        6799  2016-06-30 15:24  save_rgbd_from_kinect2\CMakeLists.txt~
     目录           0  2019-03-10 15:25  save_rgbd_from_kinect2\include\
     目录           0  2019-03-10 16:12  save_rgbd_from_kinect2\include\save_rgbd_from_kinect2\
     文件        3131  2019-03-10 15:26  save_rgbd_from_kinect2\package.xml
     文件        3131  2016-06-21 14:26  save_rgbd_from_kinect2\package.xml~
     目录           0  2019-03-10 23:40  save_rgbd_from_kinect2\src\
     文件        5960  2019-03-10 23:40  save_rgbd_from_kinect2\src\save_rgbd_from_kinect2.cpp
     文件        5960  2019-03-10 23:40  save_rgbd_from_kinect2\src\save_rgbd_from_kinect2.cpp~

评论

共有 条评论