コード例 #1
0
        static void Main()
        {
            // initialize application
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // set up the game form
            form             = new GameForm();
            form.OnGazeMove += new OnGazeMoveDelegate(OnGazeMove);

            // grab the first camera
            var baseFolder = AppDomain.CurrentDomain.BaseDirectory;
            var camera     = SequenceReader.GetCameras(baseFolder).First();

            // set up a sequence reader
            reader = new SequenceReader(camera.Item1, 640, 400);

            // set up the face model
            String root = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\");

            faceModel = new FaceModelParameters(root, false);
            faceModel.optimiseForVideo();

            // set up a face detector, a landmark detector, and a gaze analyser
            faceDetector     = new FaceDetector();
            landmarkDetector = new CLNF(faceModel);
            gazeAnalyser     = new GazeAnalyserManaged();

            // run the game
            Application.Run(form);
        }
コード例 #2
0
ファイル: CameraLister.cs プロジェクト: gavazquez/GazeTracker
        public static IEnumerable <Camera> GetAvailableCameras()
        {
            //Only list PS3Eye cameras
            foreach (var device in new FilterInfoCollection(FilterCategory.VideoInputDevice).Cast <FilterInfo>().Where(d => d.Name.StartsWith("PS3")))
            {
                VideoCaptureDevice videoSource = new VideoCaptureDevice(device.MonikerString);
                videoSource.NewFrame += NewFrame;
                videoSource.Start();

                var resolutions = new List <Tuple <int, int> >();
                foreach (var cap in videoSource.VideoCapabilities)
                {
                    resolutions.Add(new Tuple <int, int>(cap.FrameSize.Width, cap.FrameSize.Height));
                }

                while (bitmap == null)
                {
                    Thread.Sleep(50);
                }

                videoSource.SignalToStop();
                videoSource.WaitForStop();

                var camera = new Camera(device.MonikerString, device.Name, resolutions, new RawImage(new Bitmap(bitmap)), CameraType.Ps3Eye);
                bitmap = null;

                yield return(camera);
            }

            //Do not list PS3Eye camera with OpenFace as it's limited to 30FPS
            foreach (var camera in SequenceReader.GetCameras(AppDomain.CurrentDomain.BaseDirectory).Where(d => !d.Item2.StartsWith("PS3"))
                     .Select(c => new Camera(c.Item1.ToString(), c.Item2, c.Item3, c.Item4, CameraType.Webcam)))
            {
                yield return(camera);
            }
        }