首页 > 其他分享 >Azure Kinect SDK相机配准

Azure Kinect SDK相机配准

时间:2023-08-29 17:55:41浏览次数:37  
标签:rgbImage 配准 Mat get Kinect depthImage Azure include cv

 

#include <iostream>
#include <chrono>
#include <cmath>
#include <iostream>
#include <vector>
#include <memory>
#include <condition_variable>
#include <opencv2/opencv.hpp>
#include <string>
#include <fstream>
#include <sstream>
#include <algorithm>
#include "mot.h"

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <thread>

#include <dirent.h>
#include <k4a/k4a.hpp>
#include <k4a/k4atypes.h>

#define COLOR_NUM 18

/*----  k4a相关声明  ----*/
k4a::device device = k4a::device::open(K4A_DEVICE_DEFAULT);
k4a::capture capture;
k4a::image rgbImage;
k4a::image depthImage;
k4a::image transformed_depthImage;

cv::Mat cv_depth;
cv::Mat cv_depth_8U;
cv::Mat frame_depth;

Mat cv_rgbImage_with_alpha;
Mat cv_rgbImage_no_alpha;


condition_variable con_v;
bool ready = false;
mutex mtx;
Mat frame_line;

Mot mot;

Rect last_rect;
vector<Point> line_vec;

Rect result;
Mat frame;


void get_img()
{
    const uint32_t device_count = k4a::device::get_installed_count();
    cout << "device_count : " << device_count << endl;
    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_720P;
    config.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
    //config.depth_mode = K4A_DEPTH_MODE_WFOV_2X2BINNED;
    config.synchronized_images_only = true;
    device.start_cameras(&config);
    k4a::calibration k4aCalibration = device.get_calibration(config.depth_mode, config.color_resolution);// Get the camera calibration for the entire K4A device, which is used for all transformation functions.
    k4a::transformation k4aTransformation = k4a::transformation(k4aCalibration);
    cout << "--------- 1 ----------" << endl;
    while(1)
    {
        //cap >> frame;
        if(device.get_capture(&capture))
        {
            rgbImage = capture.get_color_image();
            depthImage = capture.get_depth_image();
            
            
            
            
            cv_rgbImage_with_alpha = cv::Mat(rgbImage.get_height_pixels(), rgbImage.get_width_pixels(), CV_8UC4,
                                             (void *) rgbImage.get_buffer());
            cv::cvtColor(cv_rgbImage_with_alpha, cv_rgbImage_no_alpha, cv::COLOR_BGRA2BGR);
            
            
            transformed_depthImage = k4aTransformation.depth_image_to_color_camera(depthImage);
            cv_depth = cv::Mat(transformed_depthImage.get_height_pixels(), transformed_depthImage.get_width_pixels(), CV_16U,
                               (void *) transformed_depthImage.get_buffer(), static_cast<size_t>(transformed_depthImage.get_stride_bytes()));
            normalize(cv_depth, cv_depth_8U, 0, 256 * 256, NORM_MINMAX);        
            cout << "rgbImage.size() : " << cv_rgbImage_no_alpha.size() << endl;
            cout << "cv_depth_8U.size() : " << cv_depth_8U.size() << endl;
            //cv_depth_8U.convertTo(cv_depth, CV_8U, 1);
            
        }
        frame = cv_rgbImage_no_alpha.clone();
        frame_depth = cv_depth_8U.clone();
        imshow("rgb", frame);
        imshow("depth", frame_depth);
        waitKey(1);
    }
}




int main()
{
    get_img();
    
    return 0;



}

 

标签:rgbImage,配准,Mat,get,Kinect,depthImage,Azure,include,cv
From: https://www.cnblogs.com/xiaochouk/p/17665511.html

相关文章

  • .NET 实现Azure DevOps中通过API对工作项的ID列表获取
    前言:最近在做对接AzureDevOps的API的工作,最开始也做了很多调研,官方给的API也是很丰富与完整,但是在对接工作项(WorkItems)时发现,官方并没有给WorkItems的列表或者分页的API,具体原因并不清楚,不过也可以通过id的list去获取工作项的list,id的list就需要通过wiql去获取。这里对A......
  • [Microsoft Azure] Microsoft Azure VM Windows系统盘扩容
    本文将详细介绍如何扩展MicrosoftAzureVMWindows系统盘容量。您将学到如何在AzurePortal中调整磁盘大小,以及如何在Windows操作系统内部扩展分区,以实现系统盘容量的扩展。 随着应用程序和数据的不断增长,您可能会发现现有的MicrosoftAzure虚拟机(VM)Windows系统盘容量不再满......
  • Azure Data Factory(六)数据集类型为Dataverse的Link测试
    一,引言之前有讲过AzureDataFactory的CopyData的操作,演示了将BlobStorage1的数据通过AzureDataFactory复制到BlobStorage2中,今天我们玩一个不一样的,AzureDataverse-》AzureDataverse。开始今天的内容之前,我们先了解一下什么是AzureDataverse?Azur......
  • 使用 Azure OpenAI 使用 C# 生成图像
    Microsoft启用使用AzureOpenAI生成映像的选项。在这篇文章中,我将向您展示如何轻松地使用RESTAPI通过人工智能生成图像,方法是用C#编写一个简单的控制台应用程序来连接到AzureOpenAI实例。介绍Microsoft引入了在AzureOpenAI服务中使用DALL-E生成映像的可能性。在......
  • 【Azure Developer】使用 Microsoft Graph API查看用户状态和登录记录
    问题描述通过MicrosoftGraph的API如何来查看用户信息和登录记录呢? 问题解答第一步:需要一个授权Token比如一个拥有查看用户权限的Azure账号,通过AzureCLI命令获取到一个AccessTokenazcloudset--nameAzureChinaCloudazloginazaccountget-access-token--resource'https......
  • 【Azure Developer】使用 Microsoft Graph API查看用户状态和登录记录
    问题描述通过MicrosoftGraph的API如何来查看用户信息和登录记录呢? 问题解答第一步:需要一个授权Token比如一个拥有查看用户权限的Azure账号,通过AzureCLI命令获取到一个AccessTokenazcloudset--nameAzureChinaCloudazloginazaccountget-access-token--resourc......
  • use @azure/arm-monitor sdk 遇见 ManagedIdentityCredential authentication failed.
    问题描述在使用@azure/arm-monitorsdk创建MonitorClient对象时候,遇见错误 ManagedIdentityCredentialauthenticationfailed.(statuscode500)CredentialUnavailableError:ERROR:AADSTS500011:Theresourceprincipalnamehttps://management.azure.comwasnotfoundi......
  • 【Azure Developer】use @azure/arm-monitor sdk 遇见 ManagedIdentityCredential aut
    问题描述在使用@azure/arm-monitorsdk创建MonitorClient对象时候,遇见错误 ManagedIdentityCredentialauthenticationfailed.(statuscode500)CredentialUnavailableError:ERROR:AADSTS500011:Theresourceprincipalnamehttps://management.azure.comwasnotfoun......
  • 关于Azure-存储账户-文件共享的内网访问-专用终结点连接-配置说明
    这里以标准性能的StorageV2的存储账户为例(即同时包含了容器,文件共享,队列,表)本文的实验环境,是想让Azure上的虚拟机通过内网访问文件共享,而数据连接不走Internet公网我们可以使用到存储账户,菜单下的Networking配置,下面的【专用终结点连接|Privateendpointconnections】 创建......
  • [Microsoft Azure] Azure VM Windows操作系统首选语言设置(英文-中文)
    本文将介绍如何在MicrosoftAzure虚拟机的Windows操作系统中设置首选语言,将其从英语更改为中文。我们将详细介绍设置步骤,帮助用户轻松实现语言更改。在使用MicrosoftAzure虚拟机(VM)时,您可能需要将操作系统的首选语言更改为中文。本文将指导您完成这一过程,确保您在Azure......