Esempio n. 1
0
        public Camera(CaptureElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element", "element can't be null");
            }

            _captureElement = element;

            _displayOrientation = _displayInformation.CurrentOrientation;
            _displayInformation.OrientationChanged += DisplayInformation_OrientationChanged;

            if (_orientationSensor != null)
            {
                _deviceOrientation = _orientationSensor.GetCurrentOrientation();
                _orientationSensor.OrientationChanged += OrientationSensor_OrientationChanged;
            }

            if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
            }

            Application.Current.Suspending   += Application_Suspending;
            Application.Current.Resuming     += ApplicationResuming;
            Window.Current.VisibilityChanged += Current_VisibilityChanged;
        }
Esempio n. 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <ICMXamarin.Views.CameraPreview> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                app             = Application.Current;
                app.Suspending += OnAppSuspending;
                app.Resuming   += OnAppResuming;
                HardwareButtons.BackPressed += OnBackButtonPressed;

                cameraOptions          = e.NewElement.Camera;
                PreviewControl         = new CaptureElement();
                PreviewControl.Stretch = Stretch.UniformToFill;

                InitializeAsync();
                SetNativeControl(PreviewControl);
            }
            if (e.OldElement != null)
            {
                // Unsubscribe
                Tapped -= OnCameraPreviewTapped;
            }
            if (e.NewElement != null)
            {
                // Subscribe
                Tapped    += OnCameraPreviewTapped;
                CamPreview = e.NewElement;
            }
        }
Esempio n. 3
0
        public async Task InitAsync(CaptureElement captureElement)
        {
            await _mediaCapture.InitializeAsync();

            captureElement.Source = _mediaCapture;
            await _mediaCapture.StartPreviewAsync();
        }
Esempio n. 4
0
        public async Task <VideoEncodingProperties> StartAsync(CaptureElement element)
        {
            if (DefaultManager == null)
            {
                throw new Exception("Not initialized");
            }
            if (Previewing)
            {
                throw new Exception("Already previewing");
            }
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            try
            {
                FaceDetection.Enabled = true;
                PreviewControl        = element;
                PreviewControl.Source = DefaultManager;
                await DefaultManager.StartPreviewAsync();

                Previewing = true;
            }
            catch
            {
                throw;
            }

            var properties = DefaultManager.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);
            var videoEncodingProperties = properties as VideoEncodingProperties;

            return(videoEncodingProperties);
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="autoElement"></param>
        /// <returns></returns>
        private bool SetElementProperties(IElement element, AutomationElement autoElement, Dictionary <string, int> mapUnknowCounter)
        {
            element.Attributes.DesignedId           = autoElement.Current.AutomationId;
            element.Attributes.DesignedName         = autoElement.Current.Name;
            element.Attributes.AcceleratorKey       = autoElement.Current.AcceleratorKey;
            element.Attributes.AccessKey            = autoElement.Current.AccessKey;
            element.Attributes.ClassName            = autoElement.Current.ClassName;
            element.Attributes.FrameworkId          = autoElement.Current.FrameworkId;
            element.Attributes.HasKeyboardFocus     = autoElement.Current.HasKeyboardFocus;
            element.Attributes.HelpText             = autoElement.Current.HelpText;
            element.Attributes.IsContentElement     = autoElement.Current.IsContentElement;
            element.Attributes.IsControlElement     = autoElement.Current.IsControlElement;
            element.Attributes.IsEnabled            = autoElement.Current.IsEnabled;
            element.Attributes.IsKeyboardFocusable  = autoElement.Current.IsKeyboardFocusable;
            element.Attributes.IsOffscreen          = autoElement.Current.IsOffscreen;
            element.Attributes.IsPassword           = autoElement.Current.IsPassword;
            element.Attributes.IsRequiredForForm    = autoElement.Current.IsRequiredForForm;
            element.Attributes.ItemStatus           = autoElement.Current.ItemStatus;
            element.Attributes.ItemType             = autoElement.Current.ItemType;
            element.Attributes.LocalizedControlType = autoElement.Current.LocalizedControlType;
            element.Attributes.NativeWindowHandle   = autoElement.Current.NativeWindowHandle;
            element.Attributes.ProcessId            = autoElement.Current.ProcessId;
            element.Id = GUI_Utils.GenerateUUID();
            element.Attributes.Name = GetNameElement(element, mapUnknowCounter);

            //get element's screenshot, store as encoded base64
            //ignore path to save image
            var rectBound = autoElement.Current.BoundingRectangle;

            element.Attributes.RectBounding = rectBound;
            string strEncoded = CaptureElement.CaptureScreen(rectBound, null);

            element.Attributes.ImageCaptureEncoded = strEncoded;
            return(true);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <CameraPreview> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                _app             = Application.Current;
                _app.Suspending += OnAppSuspending;
                _app.Resuming   += OnAppResuming;

                _captureElement         = new CaptureElement();
                _captureElement.Stretch = Stretch.UniformToFill;

                SetupCamera();
                SetNativeControl(_captureElement);
            }

            if (e.OldElement != null)
            {
                // Unsubscribe
                Tapped -= OnCameraPreviewTapped;
                _displayInformation.OrientationChanged -= OnOrientationChanged;
                _app.Suspending -= OnAppSuspending;
                _app.Resuming   -= OnAppResuming;
            }

            if (e.NewElement != null)
            {
                // Subscribe
                Tapped += OnCameraPreviewTapped;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on and unlocks the UI
        /// </summary>
        /// <returns></returns>
        private async Task StartPreviewAsync()
        {
            Debug.WriteLine("StartPreviewAsync");

            // Prevent the device from sleeping while the preview is running
            _displayRequest.RequestActive();

            // Register to listen for media property changes
            _systemMediaControls.PropertyChanged += SystemMediaControls_PropertyChanged;

            // Set the preview source in the UI and mirror it if necessary
            if (Const.DISPLAY_PREVIEW)
            {
                PreviewControl.Source        = _mediaCapture;
                PreviewControl.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
            }
            else
            {
                PreviewControlFake               = new CaptureElement();
                PreviewControlFake.Source        = _mediaCapture;
                PreviewControlFake.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
            }

            // Start the preview
            await _mediaCapture.StartPreviewAsync();

            _isPreviewing = true;
        }
Esempio n. 8
0
        /// <summary>
        /// Create a CaptureElement for every element on the page, which can be used by the editor.
        /// </summary>
        /// <returns></returns>
        public CaptureElement CreateCaptureElements(Size documentSize)
        {
            LOG.DebugFormat("CreateCaptureElements for {0}", Name);
            IHTMLElement  baseElement  = document3.documentElement as IHTMLElement;
            IHTMLElement2 baseElement2 = baseElement as IHTMLElement2;
            IHTMLRect     htmlRect     = baseElement2.getBoundingClientRect();

            if (Size.Empty.Equals(documentSize))
            {
                documentSize = new Size(ScrollWidth, ScrollHeight);
            }
            Rectangle baseElementBounds = new Rectangle(DestinationLocation.X + htmlRect.left, DestinationLocation.Y + htmlRect.top, documentSize.Width, documentSize.Height);

            if (baseElementBounds.Width <= 0 || baseElementBounds.Height <= 0)
            {
                // not visisble
                return(null);
            }

            CaptureElement captureBaseElement = new CaptureElement(name, baseElementBounds);

            foreach (IHTMLElement bodyElement in baseElement.children)
            {
                if ("BODY".Equals(bodyElement.tagName))
                {
                    captureBaseElement.Children.AddRange(RecurseElements(bodyElement));
                }
            }
            return(captureBaseElement);
        }
Esempio n. 9
0
        void IOverlay.ProcessPointerRelease(PointerEventArgs e)
        {
            // If an element as captured the pointer, send the event to it first
            if (CaptureElement != null)
            {
                e.Handled = CaptureElement.ProcessPointerRelease(e);
            }

            if (e.Handled)
            {
                return;
            }

            //Proceeds with the rest
            foreach (UIElement control in TreeTraversal.PostOrderInteractionVisit(this))
            {
                e.Handled = control.ProcessPointerRelease(e);
                if (e.Handled)
                {
                    break;
                }
            }

            if (e.Handled)
            {
                return;
            }

            ProcessPointerRelease(e);
            e.Handled = true;
        }
Esempio n. 10
0
        public Rect LocatePreviewStreamCoordinates(
            VideoEncodingProperties previewResolution,
            CaptureElement previewControl)
        {
            var uiRectangle       = new Rect();
            var mediaStreamWidth  = previewResolution.Width;
            var mediaStreamHeight = previewResolution.Height;

            uiRectangle.Width  = previewControl.ActualWidth;
            uiRectangle.Height = previewControl.ActualHeight;
            var uiRatio          = previewControl.ActualWidth / previewControl.ActualHeight;
            var mediaStreamRatio = mediaStreamWidth / mediaStreamHeight;

            if (uiRatio > mediaStreamRatio)
            {
                var scaleFactor = previewControl.ActualHeight / mediaStreamHeight;
                var scaledWidth = mediaStreamWidth * scaleFactor;
                uiRectangle.X     = (previewControl.ActualWidth - scaledWidth) / 2.0;
                uiRectangle.Width = scaledWidth;
            }
            else
            {
                var scaleFactor  = previewControl.ActualWidth / mediaStreamWidth;
                var scaledHeight = mediaStreamHeight * scaleFactor;
                uiRectangle.Y      = (previewControl.ActualHeight - scaledHeight) / 2.0;
                uiRectangle.Height = scaledHeight;
            }
            return(uiRectangle);
        }
Esempio n. 11
0
        private async void Initialize()
        {
            var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

            this.Media = new MediaCapture();

            if (devices.Count > 0)
            {
                MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings
                {
                    VideoDeviceId      = devices[0].Id,
                    PhotoCaptureSource = PhotoCaptureSource.VideoPreview
                };

                await this.Media.InitializeAsync(settings);

                var resolutions = this.Media.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview);
                var resolution  = (from r in resolutions
                                   orderby(r as VideoEncodingProperties).Width descending
                                   select r).FirstOrDefault();

                await this.Media.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, resolution);

                this.Element        = new CaptureElement();
                this.Element.Source = this.Media;
                this.Content        = this.Element;
            }

            if (this.PreviewState == Model.PreviewState.Start)
            {
                Start();
            }

            Window.Current.VisibilityChanged += Current_VisibilityChanged;
        }
Esempio n. 12
0
 public async Task NextCamera(CaptureElement element)
 {
     this.deviceIndex = (this.deviceIndex + 1) % this.devices.Count;
     await Teardown();
     await Initialize();
     await StartPreview(element);
 }
Esempio n. 13
0
        public async Task Initialize(CaptureElement captureElement)
        {
            if (!IsInitialized)
            {
                var settings = new MediaCaptureInitializationSettings
                {
                    StreamingCaptureMode = StreamingCaptureMode.Video
                };

                try
                {
                    await MediaCapture.InitializeAsync(settings);

                    GetVideoProperties();
                    if (captureElement != null)
                    {
                        captureElement.Source = MediaCapture;
                        IsInitialized         = true;
                    }
                }
                catch (Exception)
                {
                    IsInitialized = false;
                }
            }
        }
Esempio n. 14
0
        void SetupUserInterface()
        {
            takePhotoButton = new AppBarButton
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Icon = new SymbolIcon(Symbol.Camera)
            };

            BeardButton = new AppBarButton
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                //Icon = new SymbolIcon(new Uri("ms-appx:///Assets/BeardButton.png"))
            };

            var commandBar = new CommandBar();

            commandBar.PrimaryCommands.Add(takePhotoButton);

            captureElement         = new CaptureElement();
            captureElement.Stretch = Stretch.UniformToFill;

            var stackPanel = new StackPanel();

            stackPanel.Children.Add(captureElement);

            page = new Page();
            page.BottomAppBar = commandBar;
            page.Content      = stackPanel;
            page.Unloaded    += OnPageUnloaded;
        }
Esempio n. 15
0
        public FaceTrackerProxy(Canvas canvas, MainPage page, CaptureElement capture, MediaCapture mediacapture)
        {
            if (this.faceTracker == null)
            {
                this.faceTracker = FaceTracker.CreateAsync().AsTask().Result;
            }

            rootPage            = page;
            VisualizationCanvas = canvas;

            this.VisualizationCanvas.Children.Clear();

            mediaCapture = mediacapture;

            var deviceController = mediaCapture.VideoDeviceController;

            this.videoProperties = deviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;
            currentState         = ScenarioState.Streaming;

            // Ensure the Semaphore is in the signalled state.
            this.frameProcessingSemaphore.Release();

            // Use a 66 milisecond interval for our timer, i.e. 15 frames per second
            TimeSpan timerInterval = TimeSpan.FromMilliseconds(200);

            this.frameProcessingTimer = Windows.System.Threading.ThreadPoolTimer.CreatePeriodicTimer(new Windows.System.Threading.TimerElapsedHandler(ProcessCurrentVideoFrame), timerInterval);
        }
Esempio n. 16
0
        public async Task Initialize(CaptureElement captureElement)
        {
            if (!IsInitialized)
            {
                var settings = new MediaCaptureInitializationSettings()
                {
                    StreamingCaptureMode = StreamingCaptureMode.Video
                };

                try
                {
                    await MediaCapture.InitializeAsync(settings);

                    GetVideoProperties();

                    captureElement.Source = MediaCapture;
                    IsInitialized         = true;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);

                    IsInitialized = false;
                }
            }
        }
Esempio n. 17
0
        protected override void OnElementChanged(ElementChangedEventArgs <CameraView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                app             = Application.Current;
                app.Suspending += OnAppSuspending;
                app.Resuming   += OnAppResuming;

                cameraOptions          = e.NewElement.Camera;
                captureElement         = new CaptureElement();
                captureElement.Stretch = Stretch.UniformToFill;

                SetupCamera();
                SetNativeControl(captureElement);
            }
            if (e.OldElement != null)
            {
                // Unsubscribe
                Tapped -= OnCameraPreviewTapped;
            }
            if (e.NewElement != null)
            {
                // Subscribe
                Tapped += OnCameraPreviewTapped;
            }
        }
Esempio n. 18
0
        protected override void OnElementChanged(ElementChangedEventArgs <CameraPreview> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                app             = Windows.UI.Xaml.Application.Current;
                app.Suspending += OnAppSuspending;
                app.Resuming   += OnAppResuming;

                element                = e.NewElement;
                cameraOptions          = element.Camera;
                captureElement         = new CaptureElement();
                captureElement.Stretch = Stretch.UniformToFill;

                SetupCamera();
                SetNativeControl(captureElement);
            }
            if (e.OldElement != null)
            {
                capturePathCallbackAction = null;
                element.Capture           = null;
                element.StartCamera       = null;
                element.StopCamera        = null;
                captureFilename           = "temp";
            }
            if (e.NewElement != null)
            {
                capturePathCallbackAction = element.CapturePathCallback;
                element.Capture           = new Command(() => CaptureToFile());
                element.StartCamera       = new Command(async() => await StartPreviewAsync());
                element.StopCamera        = new Command(async() => await StopPreviewAsync());
                captureFilename           = element.Filename;
            }
        }
        public async Task InitializePreview(CaptureElement captureElement)
        {
            captureManager = new MediaCapture();

            var cameraID = await GetCameraID(Panel.Back);

            if (cameraID == null)
            {
                return;
            }

            await captureManager.InitializeAsync(new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video,
                PhotoCaptureSource   = PhotoCaptureSource.Photo,
                AudioDeviceId        = string.Empty,
                VideoDeviceId        = cameraID.Id
            });

            await
            captureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo,
                                                                               maxResolution());

            captureManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);

            StartPreview(captureElement);
        }
Esempio n. 20
0
    private static async void onVideoSourcePropertyChanged(
        DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        Debug.Assert(d is CaptureElement);
        Debug.Assert(e.Property == VideoSourceBinding.VideoSourceProperty);
        CaptureElement preview = d as CaptureElement;

        if (d != null)
        {
            if (preview.Source != null)
            {
                // If another camera was attached before, stop it.
                await preview.Source.StopPreviewAsync();
            }
            try {
                preview.Source = (MediaCapture)e.NewValue;
            } catch {
                // The property change occurred before the the video source
                // was properly initialised. In this case, we ignore the
                // change and wait for the source to fire the event again
                // once the initialisation was completed.
                // Important: The source must actually change in order for
                // the event to be fired (the attached property will detect
                // if the same object was re-set) and ignore this.
                preview.Source = null;
            }
            if (preview.Source != null)
            {
                // Start the preview stream.
                await preview.Source.StartPreviewAsync();
            }
        }
    }
        void SetupUserInterface()
        {
            _takePhotoButton = new AppBarButton
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Icon  = new SymbolIcon(Symbol.Camera),
                Label = "Take Photo"
            };

            var commandBar = new CommandBar();

            commandBar.PrimaryCommands.Add(_takePhotoButton);

            _captureElement         = new CaptureElement();
            _captureElement.Stretch = Stretch.UniformToFill;

            var grid = new Grid();

            grid.Children.Add(_captureElement);

            _page = new Windows.UI.Xaml.Controls.Page();
            _page.BottomAppBar = commandBar;
            _page.Content      = grid;
            _page.Unloaded    += OnPageUnloaded;
        }
Esempio n. 22
0
 private ShutterinoLogic(CoreDispatcher dispatcher, CaptureElement cameraPreviewControl, Func <Task> photoTakenCallback)
 {
     Instance             = this;
     Dispatcher           = dispatcher;
     CameraPreviewControl = cameraPreviewControl;
     PhotoTakenCallback   = photoTakenCallback;
 }
Esempio n. 23
0
        public static SoftwareBitmap CameraImage(CaptureElement previewControl, int width = 0, int height = 0) //sample from https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/get-a-preview-frame
        {
            while (true)
            {
                try
                {
                    if (width == 0)
                    {
                        width = (int)previewControl.Width;
                    }

                    if (height == 0)
                    {
                        height = (int)previewControl.Height;
                    }

                    // Create a video frame in the desired format for the preview frame
                    VideoFrame     videoFrame   = new VideoFrame(BitmapPixelFormat.Bgra8, width, height);
                    VideoFrame     previewFrame = _mediaCapture.GetPreviewFrameAsync(videoFrame).GetAwaiter().GetResult();
                    SoftwareBitmap bitmap       = previewFrame.SoftwareBitmap;
                    //System.Diagnostics.Debug.WriteLine("Captured frame OK");
                    return(bitmap);
                }
                catch (Exception e)
                {
                    //error occured (e.g. trying to capture too fast), skip frame
                    System.Diagnostics.Debug.WriteLine("Skiping frame: " + e.Message);
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Returns a
        /// </summary>
        /// <param name="delayTime"></param>
        /// <returns></returns>
        public static IEnumerable <SoftwareBitmap> Snapshots(CaptureElement previewControl, int width, int height, Func <bool> stop = null)
        {
            _mediaCapture         = new MediaCapture();
            _mediaCapture.Failed += _mediaCapture_Failed;
            _mediaCapture.InitializeAsync().GetAwaiter().GetResult();

            previewControl.Dispatcher.TryRunAsync(CoreDispatcherPriority.Normal, () => {
                previewControl.Source = _mediaCapture;
            }).GetAwaiter().GetResult();

            _mediaCapture.StartPreviewAsync().GetAwaiter().GetResult();

            _previewProperties = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;
            width  = (int)_previewProperties.Width; //ignore passed-in width and height and get the ones from the preview
            height = (int)_previewProperties.Height;

            while (true)
            {
                if ((stop != null) && stop())
                {
                    //cleanup
                    _mediaCapture.StopPreviewAsync().GetAwaiter().GetResult();
                    _mediaCapture = null;
                    previewControl.Dispatcher.TryRunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        previewControl.Source = null;
                    }).GetAwaiter().GetResult();

                    yield break;
                }

                yield return(CameraImage(previewControl, width, height));
            }
        }
Esempio n. 25
0
        void SetupUserInterface()
        {
            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
            _takePhotoButton = new AppBarButton
            {
                Icon = new SymbolIcon(Symbol.Camera)
            };

            _cancelButton = new AppBarButton
            {
                Icon = new SymbolIcon(Symbol.Cancel)
            };

            var commandBar = new CommandBar();

            commandBar.PrimaryCommands.Add(_takePhotoButton);
            commandBar.PrimaryCommands.Add(_cancelButton);

            _captureElement         = new CaptureElement();
            _captureElement.Stretch = Stretch.UniformToFill;

            var stackPanel = new StackPanel();

            stackPanel.Children.Add(_captureElement);

            _page = new Page();
            _page.BottomAppBar = commandBar;
            _page.Content      = stackPanel;
        }
Esempio n. 26
0
        /// <summary>
        /// Sets up the application and initializes the camera.
        /// </summary>
        public async void Setup(CaptureElement captureElement)
        {
            Windows.System.Display.DisplayRequest _displayRequest = null;
            //create the request instance if needed
            if (_displayRequest == null)
            {
                _displayRequest = new Windows.System.Display.DisplayRequest();
            }

            //make request to put in active state
            _displayRequest.RequestActive();



            StorageFolder storageFolder = ApplicationData.Current.LocalFolder;

            if (await FileExists("config.json"))
            {
                StorageFile sampleFile = await storageFolder.GetFileAsync("config.json");

                string file = await FileIO.ReadTextAsync(sampleFile);

                ConfigurationSettings = JsonConvert.DeserializeObject <ConfigModel>(file);
            }
            else
            {
                StorageFile sampleFile = await storageFolder.CreateFileAsync("config.json", CreationCollisionOption.ReplaceExisting);

                string settingsJson = "{\"smtpSettings\":{\"smtpRelay\":\"\",\"smtpPort\":465,\"useSSL\":true,\"smtpUserName\":\"\",\"smtpPassword\":\"\",\"recipient\":\"\",},\"appConfig\":{\"sendEmails\":false,\"captureDelay\":500,\"alertDelay\":2,\"alertThreshold\":2,\"pixelDelta\":.3,\"imageDelta\":7,}}";
                await FileIO.WriteTextAsync(sampleFile, settingsJson);

                ConfigurationSettings = JsonConvert.DeserializeObject <ConfigModel>(settingsJson);
            }

            Sensitivity = ConfigurationSettings.AppConfig.ImageDelta;

            ConfigurationSettings.SmtpSettings.PropertyChanged += SmtpSettings_PropertyChanged;

            await MediaCaptureElement.InitializeAsync();

            try
            {
                captureElement.Source = MediaCaptureElement;
            }
            catch (Exception)
            {
            }

            displayRequest.RequestActive();

            await MediaCaptureElement.StartPreviewAsync();

            baselineTimer.Interval = new TimeSpan(0, 0, 10);
            baselineTimer.Tick    += OnBaselineTimerTick;
            baselineTimer.Start();

            captureTimer.Interval = new TimeSpan(0, 0, 0, 0, ConfigurationSettings.AppConfig.CaptureDelay);
            captureTimer.Tick    += OnCaptureTimerTick;
        }
Esempio n. 27
0
 public FPVView()
 {
     _captureElement            = new CaptureElement();
     _captureElement.Width      = 640;
     _captureElement.Height     = 480;
     _captureElement.Visibility = Visibility.Collapsed;
     Children.Add(_captureElement);
 }
    private async void InitializeCamera()
    {
        // media capture creation

        _captureElement        = new CaptureElement();
        _captureElement.Source = mediaCapture;
        await _cameraService.StartPreviewAsync();
    }
        //CaptureElement previewControl;

        public PosjetilacRegistracijaViewModel(CaptureElement previewControl)
        {
            Dodaj = new RelayCommand<object>(unosPosjetioca);
            Uslikaj = new RelayCommand<object>(uslikaj, (object parametar) => true);
            DatumRodjenja = DateTime.Now;
            Camera = new CameraHelper(previewControl);
            Camera.InitializeCameraAsync();
        }
Esempio n. 30
0
        public async Task StartPreviewAsync(CaptureElement captureElement)
        {
            _captureElement        = captureElement;
            _captureElement.Source = null;
            _captureElement.Source = _mediaCapture;
            await _mediaCapture.StartPreviewAsync();

            _isPreviewing = true;
        }