C++ 相机无法捕捉彩色图像

C++ 相机无法捕捉彩色图像,c++,windows,azure,azurekinect,C++,Windows,Azure,Azurekinect,我将Azure Kinect摄像头连接到我的系统,通过代码我可以抓取红外图像和深度图像,但彩色图像无法工作。我自己编译了SDK,当运行k4aviewer.exe时,我得到了同样的结果。红外+深度相机工作,彩色相机只是空的。我收到错误: 无法启动麦克风:无法打开设备 无法启动麦克风侦听器:无法打开设备 然后我安装了官方的SDK,在这个k4aviewer中,我得到了红外和彩色相机。但是,当使用该库和dll编译时,我仍然一无所获。首先是什么导致了这个问题?我不能完全离开,因为我得到了深度数据 mai

我将Azure Kinect摄像头连接到我的系统,通过代码我可以抓取红外图像和深度图像,但彩色图像无法工作。我自己编译了SDK,当运行k4aviewer.exe时,我得到了同样的结果。红外+深度相机工作,彩色相机只是空的。我收到错误:

无法启动麦克风:无法打开设备

无法启动麦克风侦听器:无法打开设备

然后我安装了官方的SDK,在这个k4aviewer中,我得到了红外和彩色相机。但是,当使用该库和dll编译时,我仍然一无所获。首先是什么导致了这个问题?我不能完全离开,因为我得到了深度数据

main.cpp:

#include "azure_camera.h"
#include <opencv2/opencv.hpp>

int main() {
    int count = global::getCameraCount();
    AzureKinect cam (0);
    cam.connectCamera();
    
    k4a_device_configuration_t config;// = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;

    config.camera_fps = K4A_FRAMES_PER_SECOND_30;
    config.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
    config.color_resolution = K4A_COLOR_RESOLUTION_1080P;
    config.depth_delay_off_color_usec = 0;
    config.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
    config.disable_streaming_indicator = false;
    config.subordinate_delay_off_master_usec = 0;
    config.synchronized_images_only = true;
    config.wired_sync_mode = K4A_WIRED_SYNC_MODE_STANDALONE;
        
    cam.startCamera(config);

    AzureKinect::Images m_images;

    cam.grab_images(false, m_images);
    
    {
        cv::imshow("Test Color", m_images.color);
        cv::imshow("Test Depth", m_images.depth);

        cv::waitKey(0);
    }

    cam.stopCamera();
    
    return 0;
}
AzureCamera.h

#include <k4a/k4a.hpp>
#include <opencv2/core.hpp>
#include <stdint.h>

class AzureKinect {
public:
    struct Images {
        cv::Mat color;
        cv::Mat depth;
    };

    AzureKinect(int id) : index(id), colorImage(nullptr), depthImage(nullptr) { }
    ~AzureKinect();

    bool connectCamera();
    bool startCamera(k4a_device_configuration_t _config);
    bool stopCamera();

    bool grab_images(bool rectified, AzureKinect::Images& images);

    cv::Mat get_calibration();
private:
    uint32_t index;
    k4a::device device;
    k4a::capture capture;
    k4a_device_configuration_t config;
    k4a::image colorImage;
    k4a::image depthImage;
};

namespace global {
    uint32_t getCameraCount();
}
#包括
#包括
#包括
AzureKinect类{
公众:
结构图像{
cv::垫色;
cv::铺层深度;
};
AzureKinect(intid):索引(id)、彩色图像(nullptr)、深度图像(nullptr){
~AzureKinect();
bool-connectCamera();
bool startCamera(k4a_设备_配置_t配置);
bool-stopCamera();
bool-grab_图像(bool校正,AzureKinect::图像和图像);
cv::Mat get_校准();
私人:
uint32_t指数;
k4a::装置;
k4a::捕获;
k4a_设备_配置_t配置;
k4a::图像彩色图像;
k4a:图像深度图像;
};
命名空间全局{
uint32_t getCameraCount();
}

注意:我在上发现了一些非常类似的东西,但是我需要它来在这个系统上工作。如何调试此功能?

对于第一次捕获,超时时间可能太短。您也没有检查AzureKinect::grab_images()的错误代码。错误日志中报告了什么

#include <k4a/k4a.hpp>
#include <opencv2/core.hpp>
#include <stdint.h>

class AzureKinect {
public:
    struct Images {
        cv::Mat color;
        cv::Mat depth;
    };

    AzureKinect(int id) : index(id), colorImage(nullptr), depthImage(nullptr) { }
    ~AzureKinect();

    bool connectCamera();
    bool startCamera(k4a_device_configuration_t _config);
    bool stopCamera();

    bool grab_images(bool rectified, AzureKinect::Images& images);

    cv::Mat get_calibration();
private:
    uint32_t index;
    k4a::device device;
    k4a::capture capture;
    k4a_device_configuration_t config;
    k4a::image colorImage;
    k4a::image depthImage;
};

namespace global {
    uint32_t getCameraCount();
}