コード例 #1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            CancellationTokenSource cts = new CancellationTokenSource();

            Console.CancelKeyPress += (sender, a) =>
            {
                a.Cancel = true;
                cts.Cancel();
            };

            string configurationFilePath;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                configurationFilePath = @"/share/JAVS.Hypnos.Pi.HDMIController/PiSettings.json";
            }
            else
            {
                configurationFilePath = @"./PiSettings.json";
            }

            _piSettings = await JSONFile.LoadAsync <PiSettings>(configurationFilePath);

            FaceDetectionService faceDetectionService = new FaceDetectionService(_piSettings);

            await faceDetectionService.Init();

            faceDetectionService.ListenFor <FaceDetectionStats>((stats) =>
            {
                Console.WriteLine("Face Change.");
                string output = "";
                if (stats.IsZeroFaceAlert)
                {
                    output = @"vcgencmd display_power 0".Bash();
                }
                else if (stats.FaceRectangles?.Count > 0)
                {
                    output  = @"xset s reset";
                    output += @"vcgencmd display_power 1".Bash();
                }

                Console.WriteLine(output);

                //if (stats.IsZeroFaceAlert)
                //    output = @"echo 'standby 0' | cec-client -s -d 1".Bash();
                //else if(stats.FaceRectangles?.Count > 0)
                //    output = @"echo 'standby 1' | cec-client -s -d 1".Bash();
            });

            await faceDetectionService.Join(new JoinGroupRequest()
            {
                IsHDMIController = true,
                Password         = "******"
            });

            while (!cts.IsCancellationRequested)
            {
            }
        }
コード例 #2
0
        static async Task Main(string[] args)
        {
            _faceDetectionConfiguration = new FaceDetectionConfiguration()
            {
                ScaleFactor          = 1.2,
                MinimumNeighbors     = 5,
                MinimumFaceWidth     = 20,
                MinimumFaceHeight    = 20,
                FaceTimeoutInSeconds = 5
            };
            Console.WriteLine("Hello World!");
            CancellationTokenSource cts = new CancellationTokenSource();

            Console.CancelKeyPress += (sender, a) =>
            {
                a.Cancel = true;
                cts.Cancel();
            };

            string configurationFilePath;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                configurationFilePath = @"/share/JAVS.Hypnos.Pi.Detector/PiSettings.json";
            }
            else
            {
                configurationFilePath = @"./PiSettings.json";
            }

            _piSettings = await JSONFile.LoadAsync <PiSettings>(configurationFilePath);

            FaceDetectionService faceDetectionService = new FaceDetectionService(_piSettings);

            await faceDetectionService.Init();

            faceDetectionService.ListenFor <ClientGroupStats>((stats) =>
            {
                foreach (var group in stats.ConnectedClientGroupCounts)
                {
                    Console.WriteLine($"{group.Key}: {group.Value} Clients Connected.");
                    _clientGroupStats = stats;
                }
            });

            faceDetectionService.ListenFor <FaceDetectionConfiguration>((config) =>
            {
                _faceDetectionConfiguration = config;
            });

            await faceDetectionService.Join(new JoinGroupRequest()
            {
                IsDetector = true,
                Password   = "******"
            });

            RunFacialDetection(cts, faceDetectionService);
        }