在VS2019上部署Azure Kinect项目

在VS2019上部署Azure Kinect项目
1、配置环境
1.1、下载安装Visual Studio 2019 https://www.cnblogs.com/hsjj/p/VisualStudio.html
1.2、文件->新建->项目
创建一个空的c++项目
在这里插入图片描述

右击 ”引用”,选择 ”管理NuGet程序包(N)…”
在这里插入图片描述

选择nuget.org 作为包源,选择“浏览”选项卡,然后搜索 Microsoft.Azure.Kinect.Sensor 。
在这里插入图片描述

点击安装
在这里插入图片描述

在项目中添加源文件,输入下面代码
#pragma comment(lib, “k4a.lib”)
#include <k4a/k4a.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
uint32_t count = k4a_device_get_installed_count();
if (count == 0)
{
printf(“No k4a devices attached!\n”);
return 1;
}
// Open the first plugged in Kinect device
k4a_device_t device = NULL;
if (K4A_FAILED(k4a_device_open(K4A_DEVICE_DEFAULT, &device)))
{
printf(“Failed to open k4a device!\n”);
return 1;
}
// Get the size of the serial number
size_t serial_size = 0;
k4a_device_get_serialnum(device, NULL, &serial_size);
// Allocate memory for the serial, then acquire it
char serial = (char)(malloc(serial_size));
k4a_device_get_serialnum(device, serial, &serial_size);
printf(“Opened device: %s\n”, serial);
free(serial);
// Configure a stream of 4096x3072 BRGA color data at 15 frames per second
k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
config.camera_fps = K4A_FRAMES_PER_SECOND_15;
config.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
config.color_resolution = K4A_COLOR_RESOLUTION_3072P;
// Start the camera with the given configuration
if (K4A_FAILED(k4a_device_start_cameras(device, &config)))
{
printf(“Failed to start cameras!\n”);
k4a_device_close(device);
return 1;
}
// Camera capture and application specific code would go here
// Shut down the camera when finished with application logic
k4a_device_stop_cameras(device);
k4a_device_close(device);
return 0;
}
运行结果如下:
在这里插入图片描述

1.3、添加opencv到Visual Studio 2019,参考下面链接
https://www.jb51.net/article/184819.htm
Step1:打开属性管理器,右击Debug|x64选择属性
在这里插入图片描述

Step2:进入VC++目录,在包含目录中添加C:\opencv\build\include和C:\opencv\build\include\opencv2。在库目录添加C:\opencv\build\x64\vc15\lib
在这里插入图片描述

Step3:进入连接器->输入,在附加依赖项添加opencv_world412d.lib,opencv_world412.lib
在这里插入图片描述

1.4、Azure Kinect DK 深度数据获取并使用opencv可视化
https://blog.csdn.net/qq_40936780/article/details/102634734
1.5、测试结果如下(注意在X64下运行)
在这里插入图片描述

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值