Skip to content

Instantly share code, notes, and snippets.

@takumifukasawa
Created March 18, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takumifukasawa/535808dd4f248bac61d896f9bb287518 to your computer and use it in GitHub Desktop.
Save takumifukasawa/535808dd4f248bac61d896f9bb287518 to your computer and use it in GitHub Desktop.
Check AzureKinect's Connection on Unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Microsoft.Azure.Kinect.Sensor;
using System;
public class KinectTest : MonoBehaviour
{
private Device device = null;
void Start()
{
// インデックスを指定して接続する
// 接続台数が増えるにつれ、二台目は1,三台目は2 ... と増えていく
device = Device.Open(0);
Debug.Log("===========================");
// Azurekinectのシリアルナンバー
Debug.Log(device.SerialNum);
// RGBカメラやDepthカメラの設定を指定してキャプチャを始める
// 各種設定はAPIドキュメントから確認できる
// https://microsoft.github.io/Azure-Kinect-Sensor-SDK/release/1.3.x/class_microsoft_1_1_azure_1_1_kinect_1_1_sensor_1_1_device_configuration.html
device.StartCameras(new DeviceConfiguration
{
ColorFormat = ImageFormat.ColorBGRA32,
ColorResolution = ColorResolution.R720p,
DepthMode = DepthMode.NFOV_2x2Binned,
SynchronizedImagesOnly = true,
CameraFPS = FPS.FPS30,
WiredSyncMode = WiredSyncMode.Standalone
});
Debug.Log("Open");
}
void OnDestroy()
{
device.StopCameras();
// 接続解除の際は状態破棄のため必ず呼ぶ
device.Dispose();
Debug.Log("Close");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment