当前位置:   article > 正文

奥比中光 Astra Pro 一代(MX400)RGBD 摄像头 彩色RGB及深度采集_python 奥比中光astra 摄像头采集深度图和rgb图像

python 奥比中光astra 摄像头采集深度图和rgb图像

主要介绍

起因

毕业设计需要自己采集RGB图像和深度图像,就在咸鱼上面淘到了一个RGBD摄像机,230块钱。在使用过程中走了一些弯路,在这分享以下,为后来人提个醒。文章后面会分享完整的C++代码,文章里面也会介绍到python的方法。


实现方法

数据采集

由于摄像头硬件问题,官方给的软件也无法同时采集深度和彩色图像,所以只能自己写程序。深度图的采集使用OpenNI框架,彩色图像使用OpenCV
单纯采集深度图和RGB图像可以直接使用python,分别调用opencv库和openni库就行,其中openni库就是C++函数库的python封装。程序可以参考这篇文章,具体代码就自己看吧,openni的包直接可以在奥比中光的官网下载。
python虽然封装的比较号,但是在使用硬件配准的时候,传值总是报错。不知道是不是一代比较垃圾的原因。但是使用C++编写采集程序的时候就可以使用硬件配准。
下面是C++采集图像的完整程序:

//test.cpp
#include <opencv2/opencv.hpp>
#include <sstream>
#include <fstream>
#include <stdlib.h>
#include <iostream>
#include <string>
#include "OpenNI.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include<sys/stat.h>
#include<sys/types.h>

using namespace std;
using namespace cv;
using namespace openni;
 
void writeMatToXML(const std::string xmlName, const cv::Mat & mat)
{
   
    FileStorage fs(xmlName, FileStorage::WRITE);
    fs << "Mat" << mat;
    fs.release();
};

void CheckOpenNIError( Status result, string status )
{
    
	if( result != STATUS_OK ) 
		cerr << status << " Error: " << OpenNI::getExtendedError() << endl;
};
 
class ScenceNumber
{
   
    // use a file(number.txt) to recoder different scence
    public:

        int scNum;
        string fileName = "./data/number.txt";
        ScenceNumber()
        {
   
            ifstream f;
            f.open(this->fileName);
            if(f.good<
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号