Skip to content

Instantly share code, notes, and snippets.

@TakashiYoshinaga
Last active December 6, 2019 00:38
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 TakashiYoshinaga/0fb6076d4481494061c81c4aac52deee to your computer and use it in GitHub Desktop.
Save TakashiYoshinaga/0fb6076d4481494061c81c4aac52deee to your computer and use it in GitHub Desktop.
Declaration of Valuables and Methods
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//AzureKinectSDKの読み込み
using Microsoft.Azure.Kinect.Sensor;
//非同期処理をする準備
using System.Threading.Tasks;
public class KinectScript : MonoBehaviour
{
//Kinectを扱う変数
Device kinect;
//表示するPointCloudの全点数
int num;
//点の集合を描画するために使用(表示する図形の詳細を管理するオブジェクト)
Mesh mesh;
//PointCloudの各点の座標の配列
Vector3[] vertices;
//PointCloudの各点に対応する色の配列
Color32[] colors;
//vertices中の何番目の点を描画するかのリスト(全部描画するけど手続き上必要)
int[] indices;
//座標変換(Color⇔Depth対応やDepth→xyzなど)をするためのクラス
Transformation transformation;
void Start()
{
//最初の一回だけKinect初期化メソッドを呼び出す
InitKinect();
//点群描画のための初期化
InitMesh();
//Kinectからのデータ取得と描画(ループ)
Task t = KinectLoop();
}
//Kinectの初期化
private void InitKinect()
{
//0番目のKinectと接続
kinect = Device.Open(0);
//Kinectの各種モードを設定して動作開始
kinect.StartCameras(new DeviceConfiguration
{
ColorFormat = ImageFormat.ColorBGRA32,
ColorResolution = ColorResolution.R720p,
DepthMode = DepthMode.NFOV_2x2Binned,
SynchronizedImagesOnly = true,
CameraFPS = FPS.FPS30
});
}
//Meshを用いてPointCloudを描画する準備をする
private void InitMesh()
{
}
//Kinectからデータを取得し、描画するメソッド
private async Task KinectLoop()
{
}
//このオブジェクトが消える(アプリ終了)と同時に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