利用libfreenect2获取Kinect 2 彩色和深度图像以及相机参数

本文详细介绍了如何使用libfreenect2库从Kinect 2设备中获取彩色和深度图像,同时涵盖了提取相机参数的步骤,为深度感知和三维重建提供基础。
#include <iostream>
#include <string>
#include <sstream>
#include <opencv2/opencv.hpp>
#include <sys/time.h>
#include <unistd.h>
#include <fstream>

#include <libfreenect2/libfreenect2.hpp>
#include <libfreenect2/frame_listener_impl.h>
#include <libfreenect2/registration.h>
#include <libfreenect2/packet_pipeline.h>
#include <libfreenect2/config.h>

using namespace std;
using namespace cv;

libfreenect2::Freenect2 freenect2;
libfreenect2::Freenect2Device *device = nullptr;   //传感器设备
libfreenect2::PacketPipeline *pipeline = nullptr;  //数据传输方式
libfreenect2::SyncMultiFrameListener* listeners ; //同步多窗口监听器
libfreenect2::Registration *reg;

enum Processors { _CPU = 1, _CUDA, _OpenGL} ;
Processors processor = _CPU;

enum ImgTypes{ _rgb=1,_depth,_undistort} ;

struct IntrinsicMatrix
{
    float fx;
    float fy;
    float cx;
    float cy;
} ColorIntrinsic, DepthIntrinsic;

struct Distortion
{
    float k1;
    float k2;
    float p1;
    float p2;
    float k3;
} distortion;

struct timeval tv;

bool shutdown = false;
/**
  *@param :
  **   processor: the processor which you want to use as packet pipeline
  *@Description:initial and open the device of kinect,and set the Processor
  * to traismit the data from kinect.
*/
bool InitSensor(const Processors processor)
{
    ///scan the sensor
    if(freenect2.enumerateDevices() == 0)
    {
        throw " [Info] [Initial Erro]: No device connected.";
 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值