示例#1
0
        protected override void OnClosing(CancelEventArgs e)
        {
            _renderRunning = false;

            task.Stop(true);

            _traking.Dispose();
            _detection.Dispose();
            _recognize.Dispose();
            _age.Dispose();
            _gender.Dispose();

            Marshal.FreeHGlobal(_pImage);

            base.OnClosing(e);
        }
示例#2
0
        private static void TestAgeAndGender()
        {
            using (var detection = LocatorFactory.GetDetectionLocator("appid", "key"))
            {
                var image1 = Image.FromFile("test2.jpg");
                using (var estimate = new FaceAge("appid", "key"))
                {
                    var result1 = estimate.StaticEstimation(detection, new Bitmap(image1));
                    foreach (var result1Age in result1.Ages)
                    {
                        Console.WriteLine(result1Age);
                    }
                }

                using (var estimate = new FaceGender("appid", "key"))
                {
                    var result1 = estimate.StaticEstimation(detection, new Bitmap(image1));
                    foreach (var result1Gender in result1.Genders)
                    {
                        Console.WriteLine(result1Gender);
                    }
                }
            }

            //another
            var age    = new FaceAge("appid", "key");
            var gender = new FaceGender("appid", "key");

            using (var detection = LocatorFactory.GetDetectionLocator("appid", "key", age, gender))
            {
                var image1 = Image.FromFile("test2.jpg");
                var result = detection.Detect(new Bitmap(image1), out var location,
                                              LocateOperation.IncludeAge | LocateOperation.IncludeGender); //default is None, no age and gender estimation
                for (var i = 0; i < location.FaceCount; i++)
                {
                    Console.WriteLine(location.Ages[i]);
                    Console.WriteLine(location.Genders[i]);
                }
            }
            age.Dispose();
            gender.Dispose();
        }