Azure Kinect DK C/C++開発概要(仮)
Self Introduction
杉浦 司 (Tsukasa Sugiura)
- Freelance Programmer
- Microsoft MVP for Windows Development
- Point Cloud Library Maintainer
- @UnaNancyOwen
Azure Kinect DK Sensor
Azure Kinect SDK Introduction
Azure Kinect Sensor SDK
(k4a / k4arecord)
Azure Kinect Body Tracking SDK
(k4abt)
- Color, Depth, Infrared, IMU, Point Cloud
- Open Source Library hosted on GitHub
(Depth Engine is Closed Source)
- Cross Platform (Windows, Linux)
- C API, C++ and C# Wrapper
- Body Index Map, Skeleton (26 Joints/Person)
- Deep Learning based Pose Estimation
- Closed Source Library
- Cross Platform (Windows, Linux)
- C API, (C++ Wrapper)
How to Install Azure Kinect SDK?
Azure Kinect Sensor SDK
- Install Pre-Built SDK using Installer
- Build and Install SDK from Source Code
Azure Kinect Body Tracking SDK
- Install SDK using Installer
- Install NVIDIA GPU Driver and Visual C++ 2015 Runtime
for ONNX Runtime (CUDA Backend)
Download Azure Kinect Body Tracking SDK | Microsoft Docs
https://docs.microsoft.com/en-us/azure/Kinect-dk/body-sdk-download
About Azure Kinect Sensor SDK | Microsoft Docs
https://docs.microsoft.com/en-us/azure/Kinect-dk/about-sensor-sdk
How to Generate Project with Azure Kinect SDK?
cmake_minimum_required( VERSION 3.6 )
project( Solution )
add_executable( Project main.cpp )
# Azure Kinect Sensor SDK (Official Support)
find_package( k4a REQUIRED )
find_package( k4arecord REQUIRED )
# Azure Kinect Body Tracking SDK (Un-Official Support)
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" )
find_package( k4abt REQUIRED )
if( k4a_FOUND AND k4arecord_FOUND AND k4abt_FOUND )
target_link_libraries( Project k4a::k4a )
target_link_libraries( Project k4a::k4arecord )
target_link_libraries( Project k4a::k4abt )
endif()
CMake Module for Azure Kinect Sensor SDK | GitHub Gists
https://gist.github.com/UnaNancyOwen/5ce9115ba8b71d12982e5aa9f99788f1#file-findk4abt-cmake
Include CMake and MS Build files in the MSI #370 | GitHub/Azure-Kinect-Sensor-SDK
https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/370
Azure Kinect Sensor SDK Overview
Capture Image
Playback
Device
Azure Kinect Sensor SDK Programming
// Azure Kinect Sensor SDK
#include <k4a/k4a.h>
#include <k4a/k4a.hpp> /* C++ Wrapper */
// Get Connected Devices
const int32_t device_count = k4a::device::get_installed_count();
if( device_count == 0 ){
throw k4a::error( "Failed to found device!" );
}
// Open Default Device
k4a::device device = k4a::device::open( K4A_DEVICE_DEFAULT );
// Start Cameras with Configuration
k4a_device_configuration_t configuration = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
configuration.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
configuration.color_resolution = K4A_COLOR_RESOLUTION_1080P;
configuration.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
configuration.wired_sync_mode = K4A_WIRED_SYNC_MODE_STANDALONE;
configuration.synchronized_images_only = true;
device.start_cameras( &configuration );
Azure Kinect Sensor SDK Programming
// Get Capture
k4a::capture capture;
const std::chrono::milliseconds timeout( K4A_WAIT_INFINITE );
const bool result = device.get_capture( &capture, timeout );
if( !result ){
break;
}
// Get Color Image
k4a::image color_image = capture.get_color_image();
cv::Mat color = k4a::get_mat( color_image );
// Get Depth Image
k4a::image depth_image = capture.get_depth_image();
cv::Mat depth = k4a::get_mat( depth_image );
- k4a::get_mat() is utility function that defined in util.h
Utility for Azure Kinect Sensor SDK | GitHub Gists
https://gist.github.com/UnaNancyOwen/9f16ce7ea4c2673fe08b4ce4804fc209#file-util-h
Azure Kinect Sensor SDK Programming
// Show Image
depth.convertTo( depth, CV_8U, -255.0 / 5000.0, 255.0 );
cv::imshow( "color", color );
cv::imshow( "depth", depth );
// Wait Key
const int32_t key = cv::waitKey( 30 );
if( key == 'q' ){
break;
}
// Close Device
device.close();
// Clear Handle
color_image.reset();
depth_image.reset();
capture.reset();
Azure Kinect Sensor SDK Programming
// Initialize Transformation
k4a::calibration calibration = device.get_calibration( configuration.depth_mode, configuration.color_resolution );
k4a::transformation transformation = k4a::transformation( calibration );
// Transform Color Image to Depth Camera
k4a::image transformed_color_image = transformation.color_image_to_depth_camera( depth_image, color_image );
cv::Mat transformed_color = k4a::get_mat( transformed_color_image );
// Transform Depth Image to Color Camera
k4a::image transformed_depth_image = transformation.depth_image_to_color_camera( depth_image );
cv::Mat transformed_depth = k4a::get_mat( transformed_depth_image );
// Transform Depth Image to Point Cloud
k4a::image xyz_image = transformation.depth_image_to_point_cloud( depth_image, K4A_CALIBRATION_TYPE_DEPTH );
//k4a::image xyz_image = transformation.depth_image_to_point_cloud( transformed_depth_image, K4A_CALIBRATION_TYPE_COLOR );
cv::Mat xyz = k4a::get_mat( xyz_image );
- Transform Image to Other Coordinate System
Color Image → Depth Camera
Depth Image → Color Camera
Depth Image → Point Cloud
Add overload functions that returns k4a::image in k4a::transformation #596 | GitHub/Azure-Kinect-Sensor-SDK
https://github.com/microsoft/Azure-Kinect-Sensor-SDK/pull/596
// Close Transformation
transformation.destroy();
Azure Kinect Sensor SDK Programming
// Azure Kinect Sensor SDK
#include <k4arecord/playback.h>
#include <k4arecord/playback.hpp> /* C++ Wrapper from Azure Kinect Sensor SDK v1.2.0 */
// Open Playback File
k4a::playback playback = k4a::playback::open( "./path/to/file.mkv" );
// Get Capture
k4a::capture capture;
bool result = playback.get_next_capture( &capture );
if( !result ){
break;
}
// Close Playback
playback.close();
- NOTE: k4arecorder (Azure Kinect Sensor SDK v1.1.x) has a bug that first 2-frames are empty.
Move C++ wrapper for playback #493 | GitHub/Azure-Kinect-Sensor-SDK
https://github.com/microsoft/Azure-Kinect-Sensor-SDK/pull/493
Azure Kinect Sensor SDK Programming
Azure Kinect Office Sample Recordings | Microsoft Download Center
https://www.microsoft.com/en-us/download/details.aspx?id=58385
Azure Kinect Body Tracking SDK Overview
Capture Queue
Playback
Device
Frame Body
Azure Kinect Body Tracking SDK Programming
// Azure Kinect Body Tracking SDK
#include <k4abt.h>
#include "k4abt.hpp" /* Un-Official C++ Wrapper */
//#include <k4abt.hpp> /* Official C++ Wrapper Provide from Next Release */
// Create Tracker
k4abt::tracker tracker = k4abt::tracker::create( calibration );
if( !tracker ){
throw k4a::error( "Failed to create tracker!" );
}
// Enqueue Capture
tracker.enqueue_capture( capture );
// Pop Tracker Result
k4abt::frame body_frame = tracker.pop_result();
- Official C++ wrapper is coming soon …
C++Wrapper for Azure Kinect Body Tracking SDK | GitHub Gists
https://gist.github.com/UnaNancyOwen/41b578f5d272aa6f22cf8ff6565fb71b#file-k4abt-hpp
Azure Kinect Body Tracking SDK Programming
// Get Body Index Map
k4a::image body_index_map_image = body_frame.get_body_index_map();
cv::Mat body_index_map = k4a::get_mat( body_index_map_image );
// Draw Body Index Map
cv::Mat body_index = cv::Mat::zeros( body_index_map.size(), CV_8UC3 );
body_index.forEach<cv::Vec3b>(
[&]( cv::Vec3b& pixel, const int32_t* position ){
const int32_t x = position[1], y = position[0];
const uint32_t index = body_index_map.at<uint8_t>( y, x );
if( index != K4ABT_BODY_INDEX_MAP_BACKGROUND ){
pixel = colors[index % colors.size()];
}
}
);
- Background Index is 255 (K4ABT_BODY_INDEX_MAP_BACKGROUND)
Azure Kinect Body Tracking SDK Programming
// Get Body Skeleton
std::vector<k4abt_body_t> bodies = body_frame.get_bodies();
// Get Image that used for Inference
k4a::capture body_capture = body_frame.get_capture();
k4a::image skeleton_image = body_capture.get_color_image();
cv::Mat skeleton = k4a::get_mat( skeleton_image );
// Draw Body Skeleton
for( const k4abt_body_t& body : bodies ){
for( const k4abt_joint_t& joint : body.skeleton.joints ){
k4a_float2_t position;
const bool result = calibration.convert_3d_to_2d( joint.position, K4A_CALIBRATION_TYPE_DEPTH, K4A_CALIBRATION_TYPE_COLOR, &position );
if( !result ){
continue;
}
const int32_t id = body.id;
const cv::Point point( static_cast<int32_t>( position.xy.x ), static_cast<int32_t>( position.xy.y ) );
cv::circle( skeleton, point, 5, colors[id % colors.size()], -1 );
}
}
- Get Image that used for Inference
- Convert Joint Position (3D) to 2D for Draw Circle on Image
Azure Kinect Body Tracking SDK Programming
// Show Image
cv::imshow( "body index", body_index );
cv::imshow( "skeleton", skeleton );
// Wait Key
const int32_t key = cv::waitKey( 30 );
if( key == 'q' ){
break;
}
// Close Tracker
tracker.destroy();
// Clear Handle
body_index_map_image.reset();
skeleton_image.reset();
body_capture.reset();
body_frame.reset();

More Related Content

PDF
Azure kinect DKハンズオン
PDF
ネットワーク ゲームにおけるTCPとUDPの使い分け
PPTX
エッジ/フォグコンピューティング環境におけるコンテナ/マイクロサービスのメリットとリスク
PPTX
KubernetesバックアップツールVeleroとちょっとした苦労話
PDF
Unityによるリアルタイム通信とMagicOnionによるC#大統一理論の実現
PDF
CEDEC 2020 - 高品質かつ低負荷な3Dライブを実現するシェーダー開発 ~『ラブライブ!スクールアイドルフェスティバル ALL STARS』(スク...
PPTX
Azure API Management 俺的マニュアル
PDF
Unity で実装するエイジングテストのお話
Azure kinect DKハンズオン
ネットワーク ゲームにおけるTCPとUDPの使い分け
エッジ/フォグコンピューティング環境におけるコンテナ/マイクロサービスのメリットとリスク
KubernetesバックアップツールVeleroとちょっとした苦労話
Unityによるリアルタイム通信とMagicOnionによるC#大統一理論の実現
CEDEC 2020 - 高品質かつ低負荷な3Dライブを実現するシェーダー開発 ~『ラブライブ!スクールアイドルフェスティバル ALL STARS』(スク...
Azure API Management 俺的マニュアル
Unity で実装するエイジングテストのお話

What's hot (20)

PDF
【Unite 2017 Tokyo】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
PPT
ドメインロジックの実装方法とドメイン駆動設計
PDF
Kubernetes環境で実現するWebアプリケーションセキュリティ
PDF
ゲーム開発者のための C++11/C++14
PDF
「ユニティちゃんを踊らせよう!」モーションキャプチャーデータのアニメーション演出
PDF
コスト最適化概論
PDF
MagicOnion入門
PPTX
世界一わかりやすいClean Architecture
PDF
Docker Compose入門~今日から始めるComposeの初歩からswarm mode対応まで
PDF
新入社員のための大規模ゲーム開発入門 サーバサイド編
PDF
【Unite Tokyo 2019】Render Streaming - WebRTC を用いたストリーミングソリューション
PDF
Unityと.NET
PDF
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組み
PDF
【メタサーベイ】Neural Fields
PDF
いまさら聞けないarmを使ったNEONの基礎と活用事例
PPTX
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
PDF
Android/iOS端末におけるエッジ推論のチューニング
PPTX
Jenkins使ってみた~Windows編~
PDF
Unityでオンラインゲーム作った話
PDF
できる!並列・並行プログラミング
【Unite 2017 Tokyo】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
ドメインロジックの実装方法とドメイン駆動設計
Kubernetes環境で実現するWebアプリケーションセキュリティ
ゲーム開発者のための C++11/C++14
「ユニティちゃんを踊らせよう!」モーションキャプチャーデータのアニメーション演出
コスト最適化概論
MagicOnion入門
世界一わかりやすいClean Architecture
Docker Compose入門~今日から始めるComposeの初歩からswarm mode対応まで
新入社員のための大規模ゲーム開発入門 サーバサイド編
【Unite Tokyo 2019】Render Streaming - WebRTC を用いたストリーミングソリューション
Unityと.NET
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組み
【メタサーベイ】Neural Fields
いまさら聞けないarmを使ったNEONの基礎と活用事例
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
Android/iOS端末におけるエッジ推論のチューニング
Jenkins使ってみた~Windows編~
Unityでオンラインゲーム作った話
できる!並列・並行プログラミング
Ad

Similar to Azure Kinect DK C/C++ 開発概要(仮) (20)

PDF
Deep Learning Edge
KEY
FLAR Workflow
PDF
PyKinect: Body Iteration Application Development Using Python
PDF
Optimizing NN inference performance on Arm NEON and Vulkan
PDF
Cassandra Summit 2014: Highly Scalable Web Application in the Cloud with Cass...
ODP
VPC Implementation In OpenStack Heat
PPTX
Scaling Docker Containers using Kubernetes and Azure Container Service
PDF
Deploy Deep Learning Application with Azure Container Instance - Devdays2018
PDF
Breizhcamp Rennes 2011
PDF
Serverless containers … with source-to-image
PDF
Serverless Container with Source2Image
PPTX
OSDN: Serverless technologies with Kubernetes
PPTX
What is serveless?
PDF
Dockerized .Net Core based app services in azure K8s
PDF
FlutterNinjas 2024: Exploring Full-Stack Dart for Firebase Server-Side Develo...
PDF
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
PDF
426 lecture 4: AR Developer Tools
PDF
Exploring MySQL Operator for Kubernetes in Python
PDF
Getting Started with Apache Spark on Kubernetes
PPTX
NTT SIC marketplace slide deck at Tokyo Summit
Deep Learning Edge
FLAR Workflow
PyKinect: Body Iteration Application Development Using Python
Optimizing NN inference performance on Arm NEON and Vulkan
Cassandra Summit 2014: Highly Scalable Web Application in the Cloud with Cass...
VPC Implementation In OpenStack Heat
Scaling Docker Containers using Kubernetes and Azure Container Service
Deploy Deep Learning Application with Azure Container Instance - Devdays2018
Breizhcamp Rennes 2011
Serverless containers … with source-to-image
Serverless Container with Source2Image
OSDN: Serverless technologies with Kubernetes
What is serveless?
Dockerized .Net Core based app services in azure K8s
FlutterNinjas 2024: Exploring Full-Stack Dart for Firebase Server-Side Develo...
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
426 lecture 4: AR Developer Tools
Exploring MySQL Operator for Kubernetes in Python
Getting Started with Apache Spark on Kubernetes
NTT SIC marketplace slide deck at Tokyo Summit
Ad

More from Tsukasa Sugiura (8)

PPTX
OpenCVとPCLでのRealSenseのサポート状況+α
PDF
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
PDF
Kinect v2 Introduction and Tutorial
PDF
Introduction to Kinect v2
PPTX
ViEW2013 「SS-01 画像センサと応用事例の紹介」
PDF
Leap Motion - 1st Review
PDF
OpenCV2.2 Install Guide ver.0.5
PDF
第2回名古屋CV・PRML勉強会 「Kinectの導入」
OpenCVとPCLでのRealSenseのサポート状況+α
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
Kinect v2 Introduction and Tutorial
Introduction to Kinect v2
ViEW2013 「SS-01 画像センサと応用事例の紹介」
Leap Motion - 1st Review
OpenCV2.2 Install Guide ver.0.5
第2回名古屋CV・PRML勉強会 「Kinectの導入」

Recently uploaded (20)

PPT
3.Software Design for software engineering
PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
PPTX
Why 2025 Is the Best Year to Hire Software Developers in India
PPTX
Human-Computer Interaction for Lecture 2
PPTX
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
PDF
Bright VPN Crack Free Download (Latest 2025)
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PPTX
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
PDF
IT Consulting Services to Secure Future Growth
PDF
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
PDF
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
PDF
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
PDF
Odoo Construction Management System by CandidRoot
PPTX
SmartGit 25.1 Crack + (100% Working) License Key
PPTX
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
PPTX
ESDS_SAP Application Cloud Offerings.pptx
PPTX
Foundations of Marketo Engage: Nurturing
PDF
Crypto Loss And Recovery Guide By Expert Recovery Agency.
PPTX
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
PDF
Cloud Native Aachen Meetup - Aug 21, 2025
3.Software Design for software engineering
Top 10 Project Management Software for Small Teams in 2025.pdf
Why 2025 Is the Best Year to Hire Software Developers in India
Human-Computer Interaction for Lecture 2
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
Bright VPN Crack Free Download (Latest 2025)
ROI from Efficient Content & Campaign Management in the Digital Media Industry
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
IT Consulting Services to Secure Future Growth
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
Odoo Construction Management System by CandidRoot
SmartGit 25.1 Crack + (100% Working) License Key
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
ESDS_SAP Application Cloud Offerings.pptx
Foundations of Marketo Engage: Nurturing
Crypto Loss And Recovery Guide By Expert Recovery Agency.
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
Cloud Native Aachen Meetup - Aug 21, 2025

Azure Kinect DK C/C++ 開発概要(仮)

  • 1. Azure Kinect DK C/C++開発概要(仮)
  • 2. Self Introduction 杉浦 司 (Tsukasa Sugiura) - Freelance Programmer - Microsoft MVP for Windows Development - Point Cloud Library Maintainer - @UnaNancyOwen
  • 4. Azure Kinect SDK Introduction Azure Kinect Sensor SDK (k4a / k4arecord) Azure Kinect Body Tracking SDK (k4abt) - Color, Depth, Infrared, IMU, Point Cloud - Open Source Library hosted on GitHub (Depth Engine is Closed Source) - Cross Platform (Windows, Linux) - C API, C++ and C# Wrapper - Body Index Map, Skeleton (26 Joints/Person) - Deep Learning based Pose Estimation - Closed Source Library - Cross Platform (Windows, Linux) - C API, (C++ Wrapper)
  • 5. How to Install Azure Kinect SDK? Azure Kinect Sensor SDK - Install Pre-Built SDK using Installer - Build and Install SDK from Source Code Azure Kinect Body Tracking SDK - Install SDK using Installer - Install NVIDIA GPU Driver and Visual C++ 2015 Runtime for ONNX Runtime (CUDA Backend) Download Azure Kinect Body Tracking SDK | Microsoft Docs https://docs.microsoft.com/en-us/azure/Kinect-dk/body-sdk-download About Azure Kinect Sensor SDK | Microsoft Docs https://docs.microsoft.com/en-us/azure/Kinect-dk/about-sensor-sdk
  • 6. How to Generate Project with Azure Kinect SDK? cmake_minimum_required( VERSION 3.6 ) project( Solution ) add_executable( Project main.cpp ) # Azure Kinect Sensor SDK (Official Support) find_package( k4a REQUIRED ) find_package( k4arecord REQUIRED ) # Azure Kinect Body Tracking SDK (Un-Official Support) set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ) find_package( k4abt REQUIRED ) if( k4a_FOUND AND k4arecord_FOUND AND k4abt_FOUND ) target_link_libraries( Project k4a::k4a ) target_link_libraries( Project k4a::k4arecord ) target_link_libraries( Project k4a::k4abt ) endif() CMake Module for Azure Kinect Sensor SDK | GitHub Gists https://gist.github.com/UnaNancyOwen/5ce9115ba8b71d12982e5aa9f99788f1#file-findk4abt-cmake Include CMake and MS Build files in the MSI #370 | GitHub/Azure-Kinect-Sensor-SDK https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/370
  • 7. Azure Kinect Sensor SDK Overview Capture Image Playback Device
  • 8. Azure Kinect Sensor SDK Programming // Azure Kinect Sensor SDK #include <k4a/k4a.h> #include <k4a/k4a.hpp> /* C++ Wrapper */ // Get Connected Devices const int32_t device_count = k4a::device::get_installed_count(); if( device_count == 0 ){ throw k4a::error( "Failed to found device!" ); } // Open Default Device k4a::device device = k4a::device::open( K4A_DEVICE_DEFAULT ); // Start Cameras with Configuration k4a_device_configuration_t configuration = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL; configuration.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32; configuration.color_resolution = K4A_COLOR_RESOLUTION_1080P; configuration.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED; configuration.wired_sync_mode = K4A_WIRED_SYNC_MODE_STANDALONE; configuration.synchronized_images_only = true; device.start_cameras( &configuration );
  • 9. Azure Kinect Sensor SDK Programming // Get Capture k4a::capture capture; const std::chrono::milliseconds timeout( K4A_WAIT_INFINITE ); const bool result = device.get_capture( &capture, timeout ); if( !result ){ break; } // Get Color Image k4a::image color_image = capture.get_color_image(); cv::Mat color = k4a::get_mat( color_image ); // Get Depth Image k4a::image depth_image = capture.get_depth_image(); cv::Mat depth = k4a::get_mat( depth_image ); - k4a::get_mat() is utility function that defined in util.h Utility for Azure Kinect Sensor SDK | GitHub Gists https://gist.github.com/UnaNancyOwen/9f16ce7ea4c2673fe08b4ce4804fc209#file-util-h
  • 10. Azure Kinect Sensor SDK Programming // Show Image depth.convertTo( depth, CV_8U, -255.0 / 5000.0, 255.0 ); cv::imshow( "color", color ); cv::imshow( "depth", depth ); // Wait Key const int32_t key = cv::waitKey( 30 ); if( key == 'q' ){ break; } // Close Device device.close(); // Clear Handle color_image.reset(); depth_image.reset(); capture.reset();
  • 11. Azure Kinect Sensor SDK Programming // Initialize Transformation k4a::calibration calibration = device.get_calibration( configuration.depth_mode, configuration.color_resolution ); k4a::transformation transformation = k4a::transformation( calibration ); // Transform Color Image to Depth Camera k4a::image transformed_color_image = transformation.color_image_to_depth_camera( depth_image, color_image ); cv::Mat transformed_color = k4a::get_mat( transformed_color_image ); // Transform Depth Image to Color Camera k4a::image transformed_depth_image = transformation.depth_image_to_color_camera( depth_image ); cv::Mat transformed_depth = k4a::get_mat( transformed_depth_image ); // Transform Depth Image to Point Cloud k4a::image xyz_image = transformation.depth_image_to_point_cloud( depth_image, K4A_CALIBRATION_TYPE_DEPTH ); //k4a::image xyz_image = transformation.depth_image_to_point_cloud( transformed_depth_image, K4A_CALIBRATION_TYPE_COLOR ); cv::Mat xyz = k4a::get_mat( xyz_image ); - Transform Image to Other Coordinate System Color Image → Depth Camera Depth Image → Color Camera Depth Image → Point Cloud Add overload functions that returns k4a::image in k4a::transformation #596 | GitHub/Azure-Kinect-Sensor-SDK https://github.com/microsoft/Azure-Kinect-Sensor-SDK/pull/596 // Close Transformation transformation.destroy();
  • 12. Azure Kinect Sensor SDK Programming // Azure Kinect Sensor SDK #include <k4arecord/playback.h> #include <k4arecord/playback.hpp> /* C++ Wrapper from Azure Kinect Sensor SDK v1.2.0 */ // Open Playback File k4a::playback playback = k4a::playback::open( "./path/to/file.mkv" ); // Get Capture k4a::capture capture; bool result = playback.get_next_capture( &capture ); if( !result ){ break; } // Close Playback playback.close(); - NOTE: k4arecorder (Azure Kinect Sensor SDK v1.1.x) has a bug that first 2-frames are empty. Move C++ wrapper for playback #493 | GitHub/Azure-Kinect-Sensor-SDK https://github.com/microsoft/Azure-Kinect-Sensor-SDK/pull/493
  • 13. Azure Kinect Sensor SDK Programming Azure Kinect Office Sample Recordings | Microsoft Download Center https://www.microsoft.com/en-us/download/details.aspx?id=58385
  • 14. Azure Kinect Body Tracking SDK Overview Capture Queue Playback Device Frame Body
  • 15. Azure Kinect Body Tracking SDK Programming // Azure Kinect Body Tracking SDK #include <k4abt.h> #include "k4abt.hpp" /* Un-Official C++ Wrapper */ //#include <k4abt.hpp> /* Official C++ Wrapper Provide from Next Release */ // Create Tracker k4abt::tracker tracker = k4abt::tracker::create( calibration ); if( !tracker ){ throw k4a::error( "Failed to create tracker!" ); } // Enqueue Capture tracker.enqueue_capture( capture ); // Pop Tracker Result k4abt::frame body_frame = tracker.pop_result(); - Official C++ wrapper is coming soon … C++Wrapper for Azure Kinect Body Tracking SDK | GitHub Gists https://gist.github.com/UnaNancyOwen/41b578f5d272aa6f22cf8ff6565fb71b#file-k4abt-hpp
  • 16. Azure Kinect Body Tracking SDK Programming // Get Body Index Map k4a::image body_index_map_image = body_frame.get_body_index_map(); cv::Mat body_index_map = k4a::get_mat( body_index_map_image ); // Draw Body Index Map cv::Mat body_index = cv::Mat::zeros( body_index_map.size(), CV_8UC3 ); body_index.forEach<cv::Vec3b>( [&]( cv::Vec3b& pixel, const int32_t* position ){ const int32_t x = position[1], y = position[0]; const uint32_t index = body_index_map.at<uint8_t>( y, x ); if( index != K4ABT_BODY_INDEX_MAP_BACKGROUND ){ pixel = colors[index % colors.size()]; } } ); - Background Index is 255 (K4ABT_BODY_INDEX_MAP_BACKGROUND)
  • 17. Azure Kinect Body Tracking SDK Programming // Get Body Skeleton std::vector<k4abt_body_t> bodies = body_frame.get_bodies(); // Get Image that used for Inference k4a::capture body_capture = body_frame.get_capture(); k4a::image skeleton_image = body_capture.get_color_image(); cv::Mat skeleton = k4a::get_mat( skeleton_image ); // Draw Body Skeleton for( const k4abt_body_t& body : bodies ){ for( const k4abt_joint_t& joint : body.skeleton.joints ){ k4a_float2_t position; const bool result = calibration.convert_3d_to_2d( joint.position, K4A_CALIBRATION_TYPE_DEPTH, K4A_CALIBRATION_TYPE_COLOR, &position ); if( !result ){ continue; } const int32_t id = body.id; const cv::Point point( static_cast<int32_t>( position.xy.x ), static_cast<int32_t>( position.xy.y ) ); cv::circle( skeleton, point, 5, colors[id % colors.size()], -1 ); } } - Get Image that used for Inference - Convert Joint Position (3D) to 2D for Draw Circle on Image
  • 18. Azure Kinect Body Tracking SDK Programming // Show Image cv::imshow( "body index", body_index ); cv::imshow( "skeleton", skeleton ); // Wait Key const int32_t key = cv::waitKey( 30 ); if( key == 'q' ){ break; } // Close Tracker tracker.destroy(); // Clear Handle body_index_map_image.reset(); skeleton_image.reset(); body_capture.reset(); body_frame.reset();