本文整理汇总了C#中KinectManager.IsInitialized方法的典型用法代码示例。如果您正苦于以下问题:C# KinectManager.IsInitialized方法的具体用法?C# KinectManager.IsInitialized怎么用?C# KinectManager.IsInitialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KinectManager
的用法示例。
在下文中一共展示了KinectManager.IsInitialized方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SencerInitialize
// Use this for initialization
public void SencerInitialize()
{
// キネクトマネージャーの取得
manager = KinectManager.Instance;
if (manager && manager.IsInitialized ()) {
KinectInterop.SensorData sensorData = manager.GetSensorData ();
if (sensorData != null && sensorData.sensorInterface != null) {
// get depth image size
depthImageWidth = sensorData.depthImageWidth;
depthImageHeight = sensorData.depthImageHeight;
// calculate the foreground rectangles
Rect cameraRect = Camera.main.pixelRect;
float rectHeight = cameraRect.height;
float rectWidth = cameraRect.width;
if (rectWidth > rectHeight)
rectWidth = rectHeight * depthImageWidth / depthImageHeight;
else
rectHeight = rectWidth * depthImageHeight / depthImageWidth;
float foregroundOfsX = (cameraRect.width - rectWidth) / 2;
float foregroundOfsY = (cameraRect.height - rectHeight) / 2;
foregroundImgRect = new Rect (foregroundOfsX, foregroundOfsY, rectWidth, rectHeight);
foregroundGuiRect = new Rect (foregroundOfsX, cameraRect.height - foregroundOfsY, rectWidth, -rectHeight);
}
}
}
示例2: Start
void Start ()
{
manager = KinectManager.Instance;
if(manager && manager.IsInitialized())
{
KinectInterop.SensorData sensorData = manager.GetSensorData();
if(sensorData != null && sensorData.sensorInterface != null && foregroundCamera != null)
{
// get depth image size
depthImageWidth = sensorData.depthImageWidth;
depthImageHeight = sensorData.depthImageHeight;
// calculate the foreground rectangles
Rect cameraRect = foregroundCamera.pixelRect;
float rectHeight = cameraRect.height;
float rectWidth = cameraRect.width;
if(rectWidth > rectHeight)
rectWidth = rectHeight * depthImageWidth / depthImageHeight;
else
rectHeight = rectWidth * depthImageHeight / depthImageWidth;
float foregroundOfsX = (cameraRect.width - rectWidth) / 2;
float foregroundOfsY = (cameraRect.height - rectHeight) / 2;
foregroundImgRect = new Rect(foregroundOfsX, foregroundOfsY, rectWidth, rectHeight);
foregroundGuiRect = new Rect(foregroundOfsX, cameraRect.height - foregroundOfsY, rectWidth, -rectHeight);
// create joint colliders
numColliders = sensorData.jointCount;
jointColliders = new GameObject[numColliders];
for(int i = 0; i < numColliders; i++)
{
string sColObjectName = ((KinectInterop.JointType)i).ToString() + "Collider";
jointColliders[i] = new GameObject(sColObjectName);
jointColliders[i].transform.parent = transform;
SphereCollider collider = jointColliders[i].AddComponent<SphereCollider>();
collider.radius = 0.2f;
}
}
}
}
示例3: Start
void Start ()
{
manager = KinectManager.Instance;
if(manager && manager.IsInitialized())
{
Rect cameraRect = Camera.main.pixelRect;
float rectHeight = cameraRect.height;
float rectWidth = cameraRect.width;
KinectInterop.SensorData sensorData = manager.GetSensorData();
if(sensorData != null && sensorData.sensorInterface != null)
{
if(rectWidth > rectHeight)
rectWidth = rectHeight * sensorData.depthImageWidth / sensorData.depthImageHeight;
else
rectHeight = rectWidth * sensorData.depthImageHeight / sensorData.depthImageWidth;
foregroundRect = new Rect((cameraRect.width - rectWidth) / 2, cameraRect.height - (cameraRect.height - rectHeight) / 2, rectWidth, -rectHeight);
}
}
}
示例4: Update
void Update ()
{
// get reference to the Kinect2Interface
if(k2interface == null)
{
manager = KinectManager.Instance;
if(manager && manager.IsInitialized())
{
KinectInterop.SensorData sensorData = manager.GetSensorData();
if(sensorData != null && sensorData.sensorInterface != null)
{
k2interface = (Kinect2Interface)sensorData.sensorInterface;
}
}
}
// get the face points
if(k2interface != null && k2interface.faceFrameResults != null)
{
if(manager != null && manager.IsUserDetected())
{
ulong userId = (ulong)manager.GetPrimaryUserID();
for(int i = 0; i < k2interface.faceFrameResults.Length; i++)
{
if(k2interface.faceFrameResults[i] != null && k2interface.faceFrameResults[i].TrackingId == userId)
{
facePoints = k2interface.faceFrameResults[i].FacePointsInColorSpace;
break;
}
}
}
}
}
示例5: Update
void Update()
{
// get reference to the Kinect2Interface
if(k2interface == null)
{
manager = KinectManager.Instance;
if(manager && manager.IsInitialized())
{
KinectInterop.SensorData sensorData = manager.GetSensorData();
if(sensorData != null && sensorData.sensorInterface != null)
{
k2interface = (Kinect2Interface)sensorData.sensorInterface;
}
}
}
// get the face points
if(k2interface != null && k2interface.faceFrameResults != null)
{
if(manager != null && manager.IsUserDetected())
{
ulong userId = (ulong)manager.GetPrimaryUserID();
for(int i = 0; i < k2interface.faceFrameResults.Length; i++)
{
if(k2interface.faceFrameResults[i] != null && k2interface.faceFrameResults[i].TrackingId == userId)
{
facePoints = k2interface.faceFrameResults[i].FacePointsInColorSpace;
break;
}
}
}
}
if(manager && manager.IsInitialized() && k2interface != null)
{
long userId = manager.GetPrimaryUserID();
if(manager.IsJointTracked(userId, (int)KinectInterop.JointType.Head))
{
//Vector3 headPos = manager.GetJointPosition(userId, (int)KinectInterop.JointType.Head);
string sStatus = string.Empty; // string.Format("Head: {0}\n", headPos);
Vector2 facePointColor = GetFacePoint(facePoint);
if(facePointColor != Vector2.zero && !float.IsInfinity(facePointColor.x) && !float.IsInfinity(facePointColor.y))
{
Vector2 facePointDepth = manager.MapColorPointToDepthCoords(facePointColor, true);
if(facePointDepth != Vector2.zero && !float.IsInfinity(facePointDepth.x) && !float.IsInfinity(facePointDepth.y))
{
ushort depthValue = manager.GetDepthForPixel((int)facePointDepth.x, (int)facePointDepth.y);
Vector3 facePointPos = manager.MapDepthPointToSpaceCoords(facePointDepth, depthValue, true);
facePointTransform.position = facePointPos;
sStatus += string.Format("{0}: {1}", facePoint, facePointPos);
}
}
if(faceInfoText)
{
faceInfoText.text = sStatus;
}
}
}
}