Bootstrap

安装Azure Kinect3 SDK(Orbbec SDK K4A Wrapper)

下载并且安装Azure Kinect3 SDK

官网下载地址,下载后傻瓜式安装,一直下一步下一步........,直到安装完成

2 ,配置开发环境

2.1,新建一个c++空项目文件

2.3,配置包含目录
选中VC++ 目录 , 点击包含目录,点击下拉框,点击编辑

在空白区域输入:

C:\Program Files\Azure Kinect SDK v1.4.1\sdk\include

C:\Program Files\Azure Kinect SDK v1.4.1\sdk\include\k4a

C:\Program Files\Azure Kinect SDK v1.4.1\sdk\include\k4arecord(如果是默认安装Azure Kinect SDK,可以直接复制粘贴即可,改过安装路径需要视情况)​

 点击确认

2.4,配置库目录文件
在VC++目录下,点击库目录,点击下拉框,点击编辑

 ​

在空白区域输入:

C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\lib(如果是默认安装Azure Kinect SDK,可以直接复制粘贴即可,改过安装路径需要视情况)​

 点击确定

 2.5,配置附加依赖项
点击链接器,点击输入,点击附加依赖项,点击下拉框,点击编辑

在空白区域输入:

C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\lib\k4a.lib

C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\lib\k4arecord.lib(如果是默认安装Azure Kinect SDK,可以直接复制粘贴即可,改过安装路径需要视情况)​

 点击确定

测试代码(需配置opencv)

#pragma comment(lib, "k4a.lib")
#include <stdio.h>
#include <k4a/k4a.h>
#include <k4arecord/record.h>
#include <k4arecord/playback.h>
#include < iostream>
#include <stdlib.h>
#include <opencv2/core/core.hpp>  
#include <opencv2\opencv.hpp>
#include <opencv2/highgui/highgui.hpp>  
#include <k4a/k4a.hpp>
#include < cstdlib>

using namespace cv;
using namespace std;

int main()
{
	k4a::capture capture;
	const uint32_t device_count = k4a::device::get_installed_count();//查看设备个数
	if (device_count == 0)
	{
		printf("No K4A devices found\n");
		return 0;
	}

	k4a::device device = k4a::device::open(K4A_DEVICE_DEFAULT);

	k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;	//设定设备参数
	config.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
	config.color_resolution = K4A_COLOR_RESOLUTION_1080P;
	config.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
	config.camera_fps = K4A_FRAMES_PER_SECOND_30;
	config.synchronized_images_only = true;

	device.start_cameras(&config);

	k4a::image rgbImage;
	k4a::image depthImage;

	cv::Mat color_frame;
	cv::Mat depth_frame;

	//cv::namedWindow("depth", cv::WINDOW_NORMAL);
	//cv::resizeWindow("depth", 640, 640);
	//cv::namedWindow("color", cv::WINDOW_NORMAL);
	//cv::resizeWindow("color", 1920, 1080);
	while (true)
	{
		if (device.get_capture(&capture, std::chrono::milliseconds(0)))
		{
			rgbImage = capture.get_color_image();
			depthImage = capture.get_depth_image();



			color_frame = cv::Mat(rgbImage.get_height_pixels(), rgbImage.get_width_pixels(), CV_8UC4, rgbImage.get_buffer());
			depth_frame = cv::Mat(depthImage.get_height_pixels(), depthImage.get_width_pixels(), CV_16U, depthImage.get_buffer());

			depth_frame.convertTo(depth_frame, CV_8U, 1);

			cv::imshow("color", color_frame);
			cv::imshow("depth", depth_frame);

			color_frame.release();
			depth_frame.release();

			capture.reset();
			if (waitKey(1) == 27)
				break;
		}
	}
	cv::destroyAllWindows();
	device.close();
	return 0;
}

配置环境变量(一般不需要)

将以下内容复制到系统变量中的Path下:C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\bin

;