public async void startConnector()
        {
            if (m_GPIOConnectorEnable && !m_GPIOConnecorInitialized)
            {
                m_GPIOInputServiceConnectorConfig["HostName"]    = HostName;
                m_GPIOInputServiceConnectorConfig["Port"]        = Port;
                m_GPIOInputServiceConnectorConfig["UpdateState"] = PropertyValue.CreateInt32(0);

                //    m_GPIOInputServiceConnectorConfig.Add("UpdateState", PropertyValue.CreateInt32(0));

                for (int i = 0; i < m_ActiveGPIOInOutBanks.InOutBanks.Count; i++)
                {
                    GPIOOBank bank = m_ActiveGPIOInOutBanks.InOutBanks[i];

                    foreach (GPIOObjects OutPuts in bank.GPIOBanks)
                    {
                        foreach (GPIOObject GPIOObj in OutPuts.GPIOs)
                        {
                            UpdateInputPropertySets(GPIOObj);
                        }
                    }
                }
                UpdateState(1);
                await m_GPIOConnector.startProcessingPackagesAsync(m_GPIOInputServiceConnectorConfig, m_GPIOOutPutServiceConnectorConfig);
            }
        }
        /// <summary>
        /// Records an MP4 video to a StorageFile and adds rotation metadata to it
        /// </summary>
        /// <returns></returns>
        private async Task StartRecordingAsync()
        {
            try
            {
                // Create storage file in Pictures Library
                var videoFile = await _captureFolder.CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption.GenerateUniqueName);

                var encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

                // Calculate rotation angle, taking mirroring into account if necessary
                var rotationAngle = 360 - ConvertDeviceOrientationToDegrees(GetCameraOrientation());
                encodingProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle));

                Debug.WriteLine("Starting recording to " + videoFile.Path);

                await _mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile);

                _isRecording = true;

                Debug.WriteLine("Started recording!");
            }
            catch (Exception ex)
            {
                // File I/O errors are reported as exceptions
                Debug.WriteLine("Exception when starting video recording: " + ex.ToString());
            }
        }
        async public void SensorStartConnector()
        {
            if (m_serDev != null)
            {
                if (ConnectorSEN0188Enable)
                {
                    if (!m_Connector_SEN0188.ProcessingPackagesStarted || !m_SensorConnecorInitialized)
                    {
                        TimeSpan _timeOut = TimeSpan.FromMilliseconds(1000);
                        m_serDev.BaudRate     = (uint)57600;
                        m_serDev.WriteTimeout = _timeOut;
                        m_serDev.ReadTimeout  = _timeOut;
                        m_serDev.Parity       = Windows.Devices.SerialCommunication.SerialParity.None;
                        m_serDev.StopBits     = Windows.Devices.SerialCommunication.SerialStopBitCount.One;
                        m_serDev.DataBits     = 8;
                        m_serDev.Handshake    = Windows.Devices.SerialCommunication.SerialHandshake.None;


                        m_SensorInputServiceConnectorConfig["UpdateState"] = PropertyValue.CreateInt32(1);


                        await m_Connector_SEN0188.startProcessingPackagesAsync(m_serDev, m_SensorInputServiceConnectorConfig, m_SensorOutPutServiceConnectorConfig);
                    }
                }
            }
        }
예제 #4
0
        private async void InitMediaCapture()
        {
            mediaCapture = new Windows.Media.Capture.MediaCapture();
            await mediaCapture.InitializeAsync(captureInitSettings);

            // Add video stabilization effect during Live Capture
            Windows.Media.Effects.VideoEffectDefinition def = new Windows.Media.Effects.VideoEffectDefinition(Windows.Media.VideoEffects.VideoStabilization);
            await mediaCapture.AddVideoEffectAsync(def, MediaStreamType.VideoRecord);

            profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Qvga);

            // Use MediaEncodingProfile to encode the profile
            System.Guid MFVideoRotationGuild = new System.Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");
            int         MFVideoRotation      = ConvertVideoRotationToMFRotation(VideoRotation.None);

            profile.Video.Properties.Add(MFVideoRotationGuild, PropertyValue.CreateInt32(MFVideoRotation));

            // add the mediaTranscoder
            var transcoder = new Windows.Media.Transcoding.MediaTranscoder();

            transcoder.AddVideoEffect(Windows.Media.VideoEffects.VideoStabilization);

            // wire to preview XAML element
            capturePreview.Source = mediaCapture;
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;
        }
        private async void InitMediaCapture()
        {
            mediaCapture = new Windows.Media.Capture.MediaCapture();
            await mediaCapture.InitializeAsync(captureInitSettings);

            Windows.Media.Effects.VideoEffectDefinition def = new Windows.Media.Effects.VideoEffectDefinition(Windows.Media.VideoEffects.VideoStabilization);
            await mediaCapture.AddVideoEffectAsync(def, MediaStreamType.VideoRecord);

            profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Qvga);
            System.Guid MFVideoRotationGuild = new System.Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");
            int         MFVideoRotation      = ConvertVideoRotationToMFRotation(VideoRotation.None);

            profile.Video.Properties.Add(MFVideoRotationGuild, PropertyValue.CreateInt32(MFVideoRotation));
            var transcoder = new Windows.Media.Transcoding.MediaTranscoder();

            transcoder.AddVideoEffect(Windows.Media.VideoEffects.VideoStabilization);
            capturePreview.Source = mediaCapture;
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;

            var definition = new FaceDetectionEffectDefinition();

            definition.SynchronousDetectionEnabled = false;
            definition.DetectionMode = FaceDetectionMode.HighPerformance;
            faceDetectionEffect      = (FaceDetectionEffect)await mediaCapture.AddVideoEffectAsync(definition, MediaStreamType.VideoPreview);

            faceDetectionEffect.DesiredDetectionInterval = TimeSpan.FromMilliseconds(33);
            faceDetectionEffect.Enabled       = true;
            faceDetectionEffect.FaceDetected += FaceDetectionEffect_FaceDetected;
        }
예제 #6
0
        async Task InitMediaCaptureAsync()
        {
            var captureInitSettings = new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video,
                PhotoCaptureSource   = PhotoCaptureSource.VideoPreview
            };

            if (deviceList.Count > 0)
            {
                captureInitSettings.VideoDeviceId = deviceList[0].Id;
            }

            mediaCapture = new MediaCapture();
            await mediaCapture.InitializeAsync();

            await AddVideoStabilization().ConfigureAwait(false);

            profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Qvga);

            var MFVideoRotationGuild = GetMediaEncodingProfileGUID();

            int MFVideoRotation = ConvertVideoRotationToMFRotation(VideoRotation.None);

            profile.Video.Properties.Add(MFVideoRotationGuild, PropertyValue.CreateInt32(MFVideoRotation));

            var transcoder = new Windows.Media.Transcoding.MediaTranscoder();

            transcoder.AddVideoEffect(Windows.Media.VideoEffects.VideoStabilization);

            DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;
        }
예제 #7
0
        /// <summary>
        /// Records an MP4 video to a StorageFile and adds rotation metadata to it
        /// </summary>
        /// <returns></returns>
        private async Task StartRecordingAsync()
        {
            try
            {
                // Create storage file for the capture
                var videoFile = await localFolder.CreateFileAsync($"Video {DateTime.Now:D}.mp4", CreationCollisionOption.GenerateUniqueName);

                var encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

                // Calculate rotation angle, taking mirroring into account if necessary
                var rotationAngle = CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(rotationHelper.GetCameraCaptureOrientation());
                encodingProfile?.Video?.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle));

                Debug.WriteLine("Starting recording to " + videoFile.Path);

                await mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile);

                isRecording = true;

                Debug.WriteLine("Started recording!");
            }
            catch (Exception ex)
            {
                // File I/O errors are reported as exceptions
                Debug.WriteLine("Exception when starting video recording: " + ex.ToString());
            }
        }
예제 #8
0
        private async System.Threading.Tasks.Task StartRecordAsync()
        {
            try
            {
                IsRecording = true;
                //if camera does not support lowlag record and lowlag photo at the same time enable TakePhoto button after recording
                IsCaptureEnabled = m_mediaCapture.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported;

                string fileName = "LumiaImagingVideo.mp4";

                var recordStorageFile = await KnownFolders.PicturesLibrary.CreateFileAsync(fileName, Windows.Storage.CreationCollisionOption.GenerateUniqueName);

                MediaEncodingProfile recordProfile = MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);

                // Calculate rotation angle, taking mirroring into account if necessary
                var rotationAngle = 360 - ConvertDeviceOrientationToDegrees(GetCameraOrientation());
                recordProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle));

                Debug.WriteLine("Starting recording...");

                await m_mediaCapture.StartRecordToStorageFileAsync(recordProfile, recordStorageFile);
            }
            catch (Exception exception)
            {
                Debug.Assert(true, string.Format("Failed to start record video. {0}", exception.Message));
                IsRecording = false;
            }
        }
        /// <summary>
        /// Records an MP4 video to a StorageFile and adds rotation metadata to it
        /// </summary>
        /// <returns></returns>
        private async Task StartRecordingAsync()
        {
            try
            {
                // Create storage file in Pictures Library
                var videoFile = await KnownFolders.PicturesLibrary.CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption.GenerateUniqueName);

                // Calculate rotation angle, taking mirroring into account if necessary
                var rotationAngle = 360 - ConvertDeviceOrientationToDegrees(GetCameraOrientation());

                // Add it to the encoding profile, or edit the value if the GUID was already a part of the properties
                _encodingProfile.Video.Properties[RotationKey] = PropertyValue.CreateInt32(rotationAngle);

                Debug.WriteLine("Starting recording...");

                await _mediaCapture.StartRecordToStorageFileAsync(_encodingProfile, videoFile);

                _isRecording = true;

                Debug.WriteLine("Started recording to: " + videoFile.Path);
            }
            catch (Exception ex)
            {
                // File I/O errors are reported as exceptions
                Debug.WriteLine("Exception when starting video recording: {0}", ex.ToString());
            }
        }
        static public void DeleteFingerId(IPropertySet Inputpropertys, UInt16 fingerId)
        {
            Inputpropertys["UpdateState"] = PropertyValue.CreateInt32(0);
            Int32 CMD = Connector_SEN0188_CMDs.getFingerPrintCmd("_doFingerDeleteId");

            Inputpropertys["FingerPrint.CMD"] = PropertyValue.CreateInt32(CMD);

            Inputpropertys["FingerPrint.FingerID"] = PropertyValue.CreateUInt16((UInt16)fingerId);
            Inputpropertys["UpdateState"]          = PropertyValue.CreateInt32(1);
        }
        static public void SetSensorID(IPropertySet Inputpropertys, byte[] SensorID)
        {
            Inputpropertys["UpdateState"] = PropertyValue.CreateInt32(0);
            Int32 CMD = Connector_SEN0188_CMDs.getFingerPrintCmd("_doFingerWriteSensorID");

            Inputpropertys["FingerPrint.CMD"]      = PropertyValue.CreateInt32(CMD);
            Inputpropertys["FingerPrint.SensorID"] = PropertyValue.CreateUInt8Array(SensorID);
            Inputpropertys["FingerPrint.PageID"]   = PropertyValue.CreateUInt8(0);

            Inputpropertys["UpdateState"] = PropertyValue.CreateInt32(1);
        }
        static public void DownloadFingerId(IPropertySet Inputpropertys, UInt16 fingerId, byte[] array)
        {
            Inputpropertys["UpdateState"] = PropertyValue.CreateInt32(0);
            Int32 CMD = Connector_SEN0188_CMDs.getFingerPrintCmd("_doFingerCharDownLoad");

            Inputpropertys["FingerPrint.CMD"] = PropertyValue.CreateInt32(CMD);

            Inputpropertys["FingerPrint.FingerID"]     = PropertyValue.CreateUInt16((UInt16)fingerId);
            Inputpropertys["FingerPrint.CHARDownLoad"] = PropertyValue.CreateUInt8Array(array);

            Inputpropertys["UpdateState"] = PropertyValue.CreateInt32(1);
        }
예제 #13
0
        public StationEnvironment()
        {
            m_HostName      = "localhost";
            m_Port          = 3005;
            m_GPIOConnector = new GPIOConnector();
            m_OutPutServiceConnectorConfig = new PropertySet();
            m_InputServiceConnectorConfig  = new PropertySet();
            m_InputServiceConnectorConfig.Add("HostName", PropertyValue.CreateString("WilliRaspiPlus"));
            m_InputServiceConnectorConfig.Add("Port", PropertyValue.CreateInt32(3005));
            m_InputServiceConnectorConfig.Add("UpdateState", PropertyValue.CreateInt32(0));

            m_GPIOOInOutBanks = null;
        }
        //<SnippetStartRecordWithRotation>
        public async void StartRecordWithRotation(Windows.Storage.StorageFile videoFile)
        {
            var mediaEncodingProps = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(
                Windows.Media.MediaProperties.VideoEncodingQuality.Auto);

            System.Guid MFVideoRotationGuid =
                new System.Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1"); // MF_MT_VIDEO_ROTATION in Mfapi.h

            int MFVideoRotation = ConvertVideoRotationToMFRotation(VideoRotation.Clockwise90Degrees);

            mediaEncodingProps.Video.Properties.Add(MFVideoRotationGuid, PropertyValue.CreateInt32(MFVideoRotation));

            await captureMgr.StartRecordToStorageFileAsync(mediaEncodingProps, videoFile);
        }
예제 #15
0
        //Create a profile
        private void CreateProfile()
        {
            profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Qvga);

            // Use MediaEncodingProfile to encode the profile
            System.Guid MFVideoRotationGuild = new System.Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");
            int         MFVideoRotation      = ConvertVideoRotationToMFRotation(VideoRotation.None);

            profile.Video.Properties.Add(MFVideoRotationGuild, PropertyValue.CreateInt32(MFVideoRotation));


            // add the mediaTranscoder
            var transcoder = new Windows.Media.Transcoding.MediaTranscoder();

            transcoder.AddVideoEffect(Windows.Media.VideoEffects.VideoStabilization);
        }
예제 #16
0
        //</SnippetCapturePhotoWithOrientation>

        //<SnippetStartRecordingWithOrientationAsync>
        private async Task StartRecordingWithOrientationAsync()
        {
            try
            {
                var videoFile = await KnownFolders.VideosLibrary.CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption.GenerateUniqueName);

                var encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

                var rotationAngle = CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(
                    _rotationHelper.GetCameraCaptureOrientation());
                Guid RotationKey = new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");
                encodingProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle));

                await mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception when starting video recording: {0}", ex.ToString());
            }
        }
예제 #17
0
        private async Task ExecuteStart()
        {
            // Create storage file for the capture
            var videoFile = await _captureFolder.CreateFileAsync($"Video {DateTime.Now:yy-MM-dd HH-mm-ss}.mp4", CreationCollisionOption.GenerateUniqueName);

            var encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

            // Calculate rotation angle, taking mirroring into account if necessary
            var rotationAngle = 360 - ConvertDeviceOrientationToDegrees(GetCameraOrientation());

            encodingProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle));

            Debug.WriteLine("Starting recording to " + videoFile.Path);

            await _mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile);

            _isRecording = true;

            Debug.WriteLine("Started recording!");
        }
        public StationEnvironment()
        {
            m_HostName             = "localhost";
            m_Port                 = 3005;
            m_serDev               = new SerDevice("COM1");
            m_Connector_SEN0188    = new Connector_SEN0188();
            m_SEN0188SQLite        = new SEN0188SQLite();
            m_FingertEventDatabase = new FingertEventDatabase();
            m_SensorOutPutServiceConnectorConfig = new PropertySet();
            m_SensorInputServiceConnectorConfig  = new PropertySet();

            m_GPIOOutPutServiceConnectorConfig = new PropertySet();
            m_GPIOInputServiceConnectorConfig  = new PropertySet();



            m_GPIOInputServiceConnectorConfig.Add("HostName", PropertyValue.CreateString("WilliRaspiPlus"));
            m_GPIOInputServiceConnectorConfig.Add("Port", PropertyValue.CreateInt32(3005));
            m_GPIOInputServiceConnectorConfig.Add("UpdateState", PropertyValue.CreateInt32(0));
            m_GPIOInOutBanks = null;

            m_ConnectorSEN0188Enable = false;

            m_GPIOEnvironmentConnectors = new GPIOEnvironmentConnectors();


            m_ConfigProcessItems  = new ConfigProcessItems(m_GPIOEnvironmentConnectors);
            m_ProcessorGPIOEvents = new ProcessorGPIOEvents(this);

            m_SensorConnecorInitialized = false;
            m_GPIOConnecorInitialized   = false;
            m_SensorInitialized         = false;
            m_IsLoggedIn   = false;
            m_isAuthorized = false;
            m_user         = null;
            m_PeriodicTimerDelFingerEvents = null;
            m_EventHistoryinDays           = 14; // 14 Tage
        }
예제 #19
0
        async Task initMediaCaptureAsync()
        {
            var captureInitSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings();

            captureInitSettings.AudioDeviceId        = DeviceInfo.Instance.Id;
            captureInitSettings.VideoDeviceId        = DeviceInfo.Instance.Id;
            captureInitSettings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.AudioAndVideo;
            captureInitSettings.PhotoCaptureSource   = Windows.Media.Capture.PhotoCaptureSource.VideoPreview;

            if (deviceList.Count > 0)
            {
                captureInitSettings.VideoDeviceId = deviceList[0].Id;
            }

            mediaCapture = new Windows.Media.Capture.MediaCapture();
            await mediaCapture.InitializeAsync(captureInitSettings);

            // Add video stabilization effect during Live Capture
            Windows.Media.Effects.VideoEffectDefinition def = new Windows.Media.Effects.VideoEffectDefinition(Windows.Media.VideoEffects.VideoStabilization);
            await mediaCapture.AddVideoEffectAsync(def, MediaStreamType.VideoRecord);

            profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Qvga);

            // Use MediaEncodingProfile to encode the profile
            System.Guid MFVideoRotationGuild = new System.Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");

            int MFVideoRotation = convertVideoRotationToMFRotation(VideoRotation.None);

            profile.Video.Properties.Add(MFVideoRotationGuild, PropertyValue.CreateInt32(MFVideoRotation));

            // add the mediaTranscoder
            var transcoder = new Windows.Media.Transcoding.MediaTranscoder();

            transcoder.AddVideoEffect(Windows.Media.VideoEffects.VideoStabilization);

            // wire to preview XAML element
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;
        }
예제 #20
0
        public static object Parse(AppDataType.Type type, string s)
        {
            object obj = null;

            switch (type)
            {
            case AppDataType.Type.Empty: obj = PropertyValue.CreateEmpty();; break;

            case AppDataType.Type.UInt8: obj = PropertyValue.CreateUInt8(s.IsEmpty() ? (byte)0 : Byte.Parse(s)); break;

            case AppDataType.Type.Int16: obj = PropertyValue.CreateInt16(s.IsEmpty() ? (short)0 : Int16.Parse(s)); break;

            case AppDataType.Type.UInt16: obj = PropertyValue.CreateUInt16(s.IsEmpty() ? (ushort)0 : UInt16.Parse(s)); break;

            case AppDataType.Type.Int32: obj = PropertyValue.CreateInt32(s.IsEmpty() ? 0 : Int32.Parse(s)); break;

            case AppDataType.Type.UInt32: obj = PropertyValue.CreateUInt32(s.IsEmpty() ? 0 : UInt32.Parse(s)); break;

            case AppDataType.Type.Int64: obj = PropertyValue.CreateInt64(s.IsEmpty() ? 0 : Int64.Parse(s)); break;

            case AppDataType.Type.UInt64: obj = PropertyValue.CreateUInt64(s.IsEmpty() ? 0 : UInt64.Parse(s)); break;

            case AppDataType.Type.Single: obj = PropertyValue.CreateSingle(s.IsEmpty() ? 0 : Single.Parse(s)); break;

            case AppDataType.Type.Double: obj = PropertyValue.CreateDouble(s.IsEmpty() ? 0 : Double.Parse(s)); break;

            case AppDataType.Type.Char16: obj = PropertyValue.CreateChar16(Char.Parse(s)); break;

            case AppDataType.Type.Boolean: obj = PropertyValue.CreateBoolean(s.IsEmpty() ? false : Boolean.Parse(s)); break;

            case AppDataType.Type.String: obj = s; break;

            default: break;
            }
            return(obj);
        }
        static public void InitSensor(IPropertySet Inputpropertys)
        {
            Int32 CMD = Connector_SEN0188_CMDs.getFingerPrintCmd("_doFingerSensorInitialize");

            Inputpropertys["FingerPrint.CMD"] = PropertyValue.CreateInt32(CMD);
        }
예제 #22
0
        AdapterAttribute NewAttribute(string name, int value, E_ACCESS_TYPE access)
        {
            object data = PropertyValue.CreateInt32(value);

            return(NewAttribute(name, data, access));
        }
예제 #23
0
        private async void VideoButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                VideoButton.IsEnabled = false;
                //playbackElement.Source = null;

                if (isRecording == false)
                {
                    captureImage.Visibility = Visibility.Collapsed;
                    PhotoButton.Visibility  = Visibility.Collapsed;
                    appBarButton.Visibility = Visibility.Collapsed;
                    status.Text             = "Initialize video recording";
                    String fileName;
                    fileName = VIDEO_FILE_NAME;

                    recordStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName);

                    status.Text = "Video storage file preparation successful";

                    MediaEncodingProfile recordProfile = null;
                    recordProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

                    var rotationAngle = 180;
                    recordProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle));

                    await mediaCapture.StartRecordToStorageFileAsync(recordProfile, recordStorageFile);

                    VideoButton.IsEnabled = true;

                    isRecording = true;
                    status.Text = "Video recording in progress... press \'Stop Video Record\' to stop";
                }
                else
                {
                    captureImage.Visibility = Visibility.Visible;
                    PhotoButton.Visibility  = Visibility.Visible;
                    appBarButton.Visibility = Visibility.Visible;
                    status.Text             = "Stopping video recording...";
                    await mediaCapture.StopRecordAsync();

                    isRecording = false;

                    var stream = await recordStorageFile.OpenReadAsync();

                    //playbackElement.AutoPlay = true;
                    //playbackElement.SetSource(stream, recordStorageFile.FileType);
                    //playbackElement.Play();
                    status.Text = "Playing recorded video" + recordStorageFile.Path;
                }
            }
            catch (Exception ex)
            {
                if (ex is System.UnauthorizedAccessException)
                {
                    status.Text = "Unable to play recorded video; video recorded successfully to: " + recordStorageFile.Path;
                }
                else
                {
                    status.Text = ex.Message;
                    Cleanup();
                }
            }
            finally
            {
                VideoButton.IsEnabled = true;
            }

            // After starting or stopping video recording, update the UI to reflect the MediaCapture state
            UpdateCaptureControls();
        }
예제 #24
0
        private async void RecordButtonChanged(object sender, RoutedEventArgs e)
        {
            var mediaCapture = _cameraInfoService.MediaCapture;

            if (!_isRecording)
            {
                RecordedLengthText.Text       = "00:00";
                RecordedLengthText.Visibility = Visibility.Visible;

                _isRecording = true;

                _displayRequest.Request();

                _fileName = string.Format("Viddi-{0}.mp4", DateTime.Now.ToString("yyyy-M-dd-HH-mm-ss"));
                var folder = ApplicationData.Current.LocalCacheFolder;
                var file   = await folder.CreateFileAsync(_fileName, CreationCollisionOption.ReplaceExisting);

                var profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

                var mfVideoRotationGuid = new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1"); // MF_MT_VIDEO_ROTATION in Mfapi.h
                var rotation            = _cameraInfoService.MediaCapture.GetPreviewRotation();
                int mfVideoRotation     = ConvertVideoRotationToMFRotation(rotation);

                profile.Video.Properties.Add(mfVideoRotationGuid, PropertyValue.CreateInt32(mfVideoRotation));

                mediaCapture.StartRecordToStorageFileAsync(profile, file);
                _recordingTimer.Start();
            }
            else
            {
                _recordingTimer.Stop();
                _isRecording = false;
                _displayRequest.Release();
                _recordedDuration = TimeSpan.MinValue;

                await mediaCapture.StopRecordAsync();

                if (string.IsNullOrEmpty(_fileName))
                {
                    return;
                }

                var folder = ApplicationData.Current.LocalCacheFolder;
                try
                {
                    var file = await folder.GetFileAsync(_fileName);

                    if (file != null)
                    {
                        var cameraRoll = KnownFolders.CameraRoll;
                        await file.MoveAsync(cameraRoll);

                        var movedFile = await cameraRoll.GetFileAsync(_fileName);

                        var vm = DataContext as VideoRecordViewModel;
                        if (vm != null)
                        {
                            vm.FinishedRecording(movedFile);
                            RecordedLengthText.Visibility = Visibility.Collapsed;
                        }
                    }
                }
                catch (FileNotFoundException)
                {
                }
            }
        }
예제 #25
0
                public async Task StartAsync()
                {
                    if (m_isVideo)
                    {
                        var profile       = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
                        var rotationAngle = CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(Windows.Devices.Sensors.SimpleOrientation.NotRotated); // _rotationHelper.GetCameraCaptureOrientation());
                        profile.Video.Properties.Add(new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1"), PropertyValue.CreateInt32(rotationAngle));

                        m_lowLag = await m_mediaCapture.PrepareLowLagRecordToStorageFileAsync(profile, m_file);

                        await m_lowLag.StartAsync();
                    }
                    else
                    {
                        var wavEncodingProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.High);
                        wavEncodingProfile.Audio.BitsPerSample = 16;
                        wavEncodingProfile.Audio.SampleRate    = 48000;
                        wavEncodingProfile.Audio.ChannelCount  = 1;

                        m_opusSink = await OpusCodec.CreateMediaSinkAsync(m_file);

                        await m_mediaCapture.StartRecordToCustomSinkAsync(wavEncodingProfile, m_opusSink);
                    }
                }
        static public void VerifyFingerId(IPropertySet Inputpropertys)
        {
            Int32 CMD = Connector_SEN0188_CMDs.getFingerPrintCmd("_doFingerAutoVerifiying");

            Inputpropertys["FingerPrint.CMD"] = PropertyValue.CreateInt32(CMD);
        }