Beispiel #1
0
    private void OnMultiSourceFrameArrived(object sender, Perception.Kinect.MultiSourceFrameArrivedEventArgs e)
    {
        if (e.ColorFrame != null)
        {
            //UnityEngine.Debug.LogError("frame received!");
            sw.Stop();
            totalTime += sw.Elapsed.TotalSeconds;
            DataStore.SetValue("Time:per:frame", new DataStore.StringValue((++i / totalTime).ToString()), this, sw.Elapsed.ToString());
            sw.Restart();
            //var closestBodyFrame = new ClosestBodyFrame(e.BodyFrame, engageMin, engageMax);
            //var headColorFrame = new HeadColorFrame(e.ColorFrame, closestBodyFrame);
            //var colorFrame = new Perception.Frames.ColorFrame(e.ColorFrame);

            Bitmap b = cropAtRect(ColorImageFrameToBitmap(e.ColorFrame), rectangle);

            byte[] data       = BitmaptoArray(b);
            var    colorArray = new Color32[data.Length / 4];
            for (var i = 0; i < data.Length; i += 4)
            {
                var color = new Color32(data[i + 0], data[i + 1], data[i + 2], data[i + 3]);
                colorArray[i / 4] = color;
            }
            //Color32[] data = colorFrame.GetBytes();


            frame = new Affdex.Frame(colorArray, b.Width, b.Height, e.Timestamp);
            if (detector.IsRunning)
            {
                detector.ProcessFrame(frame);
            }
        }
        //else { UnityEngine.Debug.LogError("frame null!"); }
    }
Beispiel #2
0
    private void OnMultiSourceFrameArrived(object sender, Perception.Kinect.MultiSourceFrameArrivedEventArgs e)
    {
        if (e.DepthFrame != null)
        {
            depthFrame = new Perception.Frames.DepthFrame(e.DepthFrame);

            if (DataStore.HasValue(handRightKey))
            {
                // get right hand position in depth space
            }
            if (DataStore.HasValue(handLeftKey))
            {
                // get left hand position in depth space
            }
        }
    }
Beispiel #3
0
    private void OnMultiSourceFrameArrived(object sender, Perception.Kinect.MultiSourceFrameArrivedEventArgs e)
    {
        if (e.BodyFrame != null)
        {
            var bodyFrame = new ClosestBodyFrame(e.BodyFrame, engageMin, engageMax);

            foreach (var joint in bodyFrame.Joints)
            {
                var jointVectorValue = new DataStore.Vector3Value(new Vector3(joint.Value.Position.X, joint.Value.Position.Y, joint.Value.Position.Z));
                DataStore.SetValue("user:joint:" + joint.Key.ToString(), jointVectorValue, this, joint.Value.JointType.ToString());
                //var isTracked = new DataStore.BoolValue(joint.Value.TrackingState == Windows.Kinect.TrackingState.Tracked);
                //var isInferred = new DataStore.BoolValue(joint.Value.TrackingState == Windows.Kinect.TrackingState.Inferred);
                //DataStore.SetValue("user:joint:tracked:" + joint.Key.ToString(), isTracked, this, "");
                //DataStore.SetValue("user:joint:inferred:" + joint.Key.ToString(), isInferred, this, "");
            }
            DataStore.SetValue("user:joint:timestamp", new DataStore.StringValue(e.Timestamp.ToString()), this, e.Timestamp.ToString());
            DataStore.SetValue("user:engaged", new DataStore.BoolValue(bodyFrame.Engaged), this, bodyFrame.Engaged.ToString());
        }
    }