Example #1
0
        public static bool CreateDemoImage(Bitmap bitmap, KinectData data)
        {
            // Get color image
            if (data.Available.colorImageEnable)
            {
                ImageFrameConverter.SetColorImage(bitmap, data.ColorImage);
            }


            // Lighten table
            if (data.Available.tableEnable)
            {
                ImageFrame tableBlob = data.TableInfo.CreateTableBlob(true);
                DarkenRegion(bitmap, tableBlob, 0.25f);
            }

            // Draw arms on image
            if (data.Available.handsEnable)
            {
                // Draw arm shadows
                //DrawArmShadows(bitmap, data.TableInfo, data.Hands);

                // Draw boundaries around arms
                Color[] armColors = { Color.Black, Color.Red, Color.Green, Color.Blue };
                foreach (Hand hand in data.Hands)
                {
                    if (hand.Id + 1 < armColors.Length)
                    {
                        HighlightPoints(bitmap, hand.Boundary, armColors[hand.Id + 1]);
                    }
                }


                // Draw finger tips
                IEnumerable <Point> allFingerTips = data.Hands.Select(x => x.FingerTips).SelectMany(x => x);
                DrawPoints(bitmap, allFingerTips, Color.Green, 3);

                // Draw finger bases
                IEnumerable <Point> allFingerBases = data.Hands.Select(x => x.FingerBases).SelectMany(x => x);
                DrawPoints(bitmap, allFingerBases, Color.Red, 3);

                // Draw arm bases
                IEnumerable <Point> allArmBases = data.Hands.Select(x => x.ArmBase);
                DrawPoints(bitmap, allArmBases, Color.Blue, 3);

                // Draw hand palm
                IEnumerable <Point> allPalmCenters = data.Hands.Select(x => x.PalmCenter);
                DrawPoints(bitmap, allPalmCenters, Color.Purple, 3);
            }

            return(data.Available.colorImageEnable);
        }
Example #2
0
        /// <summary>
        /// Is fired whenever KinectTable has new data ready.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        void client_DataReady(object sender, DataReadyEventArgs args)
        {
            // Get the current data
            args.GetData(out data);

            // Show color image if available
            if (data.Available.colorImageEnable)
            {
                ImageFrameConverter.SetColorImage(colorBitmap, data.ColorImage);
                pictureBoxColor.Image = colorBitmap;
            }

            // Show depth image if available
            if (data.Available.depthImageEnable)
            {
                ImageFrameConverter.SetDepthImage(depthBitmap, data.DepthImage);
                pictureBoxDepth.Image = depthBitmap;
            }

            // Show test image if available
            if (data.Available.testImageEnable)
            {
                ImageFrameConverter.SetColorImage(testBitmap, data.TestImage);
                pictureBoxTest.Image = testBitmap;
            }

            // Create demo image and show it
            bool createdDemoImage = DemoImageCreator.CreateDemoImage(demoBitmap, data);

            if (createdDemoImage)
            {
                pictureBoxDemo.Image = demoBitmap;
            }

            return;
        }