Created
December 5, 2019 07:05
-
-
Save TakashiYoshinaga/a45457779da7c1023b4b802fbfb2dc3c to your computer and use it in GitHub Desktop.
Connection Test with Azure Kinect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
//(追加1)AzureKinectSDKの読み込み | |
using Microsoft.Azure.Kinect.Sensor; | |
public class KinectScript : MonoBehaviour | |
{ | |
//(追加2)Kinectを扱う変数 | |
Device kinect; | |
void Start() | |
{ | |
//(追加5)最初の一回だけKinect初期化メソッドを呼び出す | |
InitKinect(); | |
} | |
//(追加3)Kinectの初期化(Form1コンストラクタから呼び出す) | |
private void InitKinect() | |
{ | |
//(追加4)0番目のKinectと接続したのちにKinectの各種モードを設定して動作開始 | |
kinect = Device.Open(0); | |
kinect.StartCameras(new DeviceConfiguration | |
{ | |
ColorFormat = ImageFormat.ColorBGRA32, | |
ColorResolution = ColorResolution.R720p, | |
DepthMode = DepthMode.NFOV_2x2Binned, | |
SynchronizedImagesOnly = true, | |
CameraFPS = FPS.FPS30 | |
}); | |
} | |
//(追加6)このオブジェクトが消える(アプリ終了)と同時にKinectを停止 | |
private void OnDestroy() | |
{ | |
kinect.StopCameras(); | |
} | |
void Update() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment