Exemple #1
0
        public FaceTrackerReceiver(IMessageReceiver receiver, FaceTracker faceTracker)
        {
            _faceTracker = faceTracker;

            receiver.AssignCommandHandler(
                VmmCommands.SetCameraDeviceName,
                message => SetCameraDeviceName(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.EnableFaceTracking,
                message => SetEnableFaceTracking(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.ExTrackerEnable,
                message => SetEnableExTracker(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.CalibrateFace,
                message => _faceTracker.StartCalibration()
                );
            receiver.AssignCommandHandler(
                VmmCommands.SetCalibrateFaceData,
                message => _faceTracker.SetCalibrateData(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.DisableFaceTrackingHorizontalFlip,
                message => _faceTracker.DisableHorizontalFlip = message.ToBoolean()
                );

            receiver.AssignQueryHandler(
                VmmQueries.CameraDeviceNames,
                query => query.Result = string.Join("\t", GetCameraDeviceNames())
                );
        }
Exemple #2
0
        private void Start()
        {
            _faceTracker = GetComponent <FaceTracker>();

            handler.Commands.Subscribe(message =>
            {
                switch (message.Command)
                {
                case MessageCommandNames.SetCameraDeviceName:
                    SetCameraDeviceName(message.Content);
                    break;

                case MessageCommandNames.EnableFaceTracking:
                    EnableFaceTracking(message.ToBoolean());
                    break;

                case MessageCommandNames.CalibrateFace:
                    _faceTracker.StartCalibration();
                    break;

                case MessageCommandNames.SetCalibrateFaceData:
                    _faceTracker.SetCalibrateData(message.Content);
                    break;

                case MessageCommandNames.DisableFaceTrackingHorizontalFlip:
                    _faceTracker.DisableHorizontalFlip = message.ToBoolean();
                    break;
                }
            });

            handler.QueryRequested += query =>
            {
                if (query.Command == MessageQueryNames.CameraDeviceNames)
                {
                    query.Result = string.Join("\t", GetCameraDeviceNames());
                }
            };
        }