Example #1
0
        public void InitializeHandDetector()
#endif
        {
#if ENABLE_WINMD_SUPPORT
            //Create the HandDetector object
            m_handDetector = await HandDetector.HandDetector.CreateAsync(null);

            await m_handDetector.InitializeAsync(this);
#endif
        }
Example #2
0
        /// <summary>
        /// Asynchronously create a Hand Detector with the first depth camera found
        /// </summary>
        /// <param name="id">The ID of the device to look for if needed. If NULL, a device with "depth" capabilities will be randomly choose.</param>
        /// <returns>The asynchronous task</returns>
        public static async Task <HandDetector> CreateAsync(String id = null)
        {
            Debug.WriteLine("Initialize the hand detector");

            //Search for the correct media frame source
            MediaFrameSourceGroup selectedFrameSourceGroup = null;
            MediaFrameSourceInfo  selectedFrameSourceInfo  = null;

            IReadOnlyList <MediaFrameSourceGroup> allFrameSourceGroups = await MediaFrameSourceGroup.FindAllAsync();

            Debug.WriteLine($"Found {allFrameSourceGroups.Count} frame sources...");

            foreach (MediaFrameSourceGroup group in allFrameSourceGroups)
            {
                Debug.WriteLine($"Group: {group.DisplayName}");
                Debug.WriteLine($"Found {group.SourceInfos.Count} source infos...");
                foreach (MediaFrameSourceInfo info in group.SourceInfos)
                {
                    //Debug.WriteLine($"{info.SourceKind} : {info.MediaStreamType} -> {info.DeviceInformation.EnclosureLocation.Panel}");
                    //If an ID is given
                    if ((id == null || info.DeviceInformation.Id == id) && (info.MediaStreamType == MediaStreamType.VideoPreview || info.MediaStreamType == MediaStreamType.VideoRecord))
                    {
                        //Check the depth capabilities
                        if (info.SourceKind == MediaFrameSourceKind.Depth)
                        {
                            selectedFrameSourceGroup = group;
                            selectedFrameSourceInfo  = info;

                            Debug.WriteLine($"Found Device : {info.DeviceInformation.Name}:{info.DeviceInformation.Id}");
                        }
                    }

                    if (selectedFrameSourceGroup != null)
                    {
                        break;
                    }
                }
                if (selectedFrameSourceGroup != null)
                {
                    break;
                }
            }

            if (selectedFrameSourceGroup == null)
            {
                Debug.WriteLine("No frame source available found");
                return(null);
            }

            HandDetector HandDetector = new HandDetector(selectedFrameSourceGroup, selectedFrameSourceInfo);

            return(HandDetector);
        }