/// <summary>
        /// Triggered when webcam feed loads both for the first time and every time page is navigated to.
        /// If no WebcamHelper has been created, it creates one. Otherwise, simply restarts webcam preview feed on page.
        /// </summary>
        private async void WebcamFeed_Loaded(object sender, RoutedEventArgs e)
        {
            if (webcam == null || !webcam.IsInitialized())
            {
                // Initialize Webcam Helper
                webcam = new WebcamHelper();
                await webcam.InitializeCameraAsync();

                // Set source of WebcamFeed on MainPage.xaml
                WebcamFeed.Source = webcam.mediaCapture;

                // Check to make sure MediaCapture isn't null before attempting to start preview. Will be null if no camera is attached.
                if (WebcamFeed.Source != null)
                {
                    // Start the live feed
                    await webcam.StartCameraPreview();
                }
            }
            else if (webcam.IsInitialized())
            {
                WebcamFeed.Source = webcam.mediaCapture;

                // Check to make sure MediaCapture isn't null before attempting to start preview. Will be null if no camera is attached.
                if (WebcamFeed.Source != null)
                {
                    await webcam.StartCameraPreview();
                }
            }
        }
        private async void Timer_Tick(object sender, object e)
        {
            if (livetemperature() >= 23)
            {
                TestPostMessage(livetemperature().ToString());
                //Take photo and save into Intrusos
                if (webcam == null || !webcam.IsInitialized())
                {
                    // Initialize Webcam Helper
                    webcam = new WebcamHelper();
                    await webcam.InitializeCameraAsync();
                }
                currentIdPhotoFile = await webcam.CapturePhoto();

                // Create or open the folder in which the Whitelist is stored
                StorageFolder whitelistFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync(GeneralConstants.WhiteListFolderName, CreationCollisionOption.OpenIfExists);

                // Create a folder to store this specific user's photos
                StorageFolder currentFolder = await whitelistFolder.CreateFolderAsync("Intrusos", CreationCollisionOption.OpenIfExists);

                // Move the already captured photo the user's folder
                await currentIdPhotoFile.MoveAsync(currentFolder);
            }
            await Task.Run(async() => { await AzureIoTHub.SendTemperatureAsync(livetemperature()); });
        }
Beispiel #3
0
        private static void SetupMessageHandlers()
        {
            connection.AppendIncomingPacketHandler <byte>("GetCameraDevices", (header, connection, data) =>
            {
                string[] names       = WebcamHelper.GetDeviceNames();
                VideoDevices devices = new VideoDevices()
                {
                    videoDevices = new VideoDevice[names.Length]
                };
                for (int i = 0; i < devices.videoDevices.Length; i++)
                {
                    VideoCapabilities[] capabilities = WebcamHelper.GetDeviceCapabilities(i);
                    devices.videoDevices[i]          = new VideoDevice()
                    {
                        name         = names[i],
                        capabilities = new VideoDeviceCapabilities[capabilities.Length]
                    };
                    for (int j = 0; j < capabilities.Length; j++)
                    {
                        devices.videoDevices[i].capabilities[j] = new VideoDeviceCapabilities()
                        {
                            averageFramerate = capabilities[j].AverageFrameRate,
                            maxFramerate     = capabilities[j].MaximumFrameRate,
                            height           = capabilities[j].FrameSize.Height,
                            width            = capabilities[j].FrameSize.Width
                        };
                    }
                }
                connection.SendObject <byte[]>("CameraDevices", Serializer.Serialize <VideoDevices>(devices, encryptionKey));
            });

            connection.AppendIncomingPacketHandler <byte[]>("GetCameraImage", (header, connection, data) =>
            {
                GetImage image = Serializer.Deserialize <GetImage>(data, encryptionKey);
                WebcamHelper.GetWebcamImage(image.deviceIndex, image.width, image.height, (bitmapImage) =>
                {
                    connection.SendObject <byte[]>("CameraImage", Serializer.Serialize <ByteData>(new ByteData()
                    {
                        data = WebcamHelper.GetImagePNGBytes(bitmapImage)
                    }, encryptionKey));
                });
            });

            connection.AppendIncomingPacketHandler <byte>("GetDesktopImage", (header, connection, data) =>
            {
                connection.SendObject <byte[]>("DesktopImage", Serializer.Serialize <ByteData>(new ByteData()
                {
                    data = WebcamHelper.GetImagePNGBytes(WebcamHelper.GetDesktopScreenshot())
                }, encryptionKey));
            });

            connection.AppendIncomingPacketHandler <byte>("GetLocation", (header, connection, data) =>
            {
                LocationHelper.GetPosition((location) =>
                {
                    connection.SendObject <byte[]>("Location", Serializer.Serialize <DeviceLocation>(location, encryptionKey));
                });
            });
        }
Beispiel #4
0
 /// <summary>
 /// Triggered every time the page is navigated to.
 /// </summary>
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     try
     {
         //Sets passed through WecamHelper from MainPage as local webcam object
         webcam = e.Parameter as WebcamHelper;
     }
     catch (Exception exception)
     {
         Debug.WriteLine("Error when navigating to NewUserPage: " + exception.Message);
     }
 }
Beispiel #5
0
        public GPIOService()
        {
            led        = 17;
            pushButton = 22;
            InitGpio();

            webcam = new WebcamHelper();

            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Tick    += Timer_Tick;
            timer.Start();
        }
        /// <summary>
        /// Triggered every time the page is navigated to.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                // Catches the passed UserProfilePage parameters
                UserProfileObject userProfileParameters = e.Parameter as UserProfileObject;

                // Sets current user as the passed through Visitor object
                currentUser = userProfileParameters.Visitor;
                // Sets the VisitorNameBlock as the current user's name
                VisitorNameBlock.Text = currentUser.Name;

                // Sets the local WebcamHelper as the passed through intialized one
                webcam = userProfileParameters.WebcamHelper;
            }
            catch
            {
                // Something went wrong... It's likely the page was navigated to without a Visitor parameter. Navigate back to MainPage
                Frame.Navigate(typeof(MainPage));
            }
        }
        public CardRecognizerViewModel()
        {
            this.CamHelper  = new WebcamHelper();
            this.Recognizer = new CardRecognizer();
            this.ocrEngine  = OcrEngine.TryCreateFromLanguage(new Windows.Globalization.Language("en"));

            this.CannyLowerControl  = new VariableControl("Canny Lower", UpdateCannyParams);
            this.CannyUpperControl  = new VariableControl("Canny Upper", UpdateCannyParams);
            this.CannyKernelControl = new VariableControl("Canny Kernel", UpdateCannyParams);
            this.CannyBlurControl   = new VariableControl("Canny Blur", UpdateCannyParams);
            this.MinContourControl  = new VariableControl("Min Contour", UpdateContourBounds);
            this.MaxContourControl  = new VariableControl("Max Contour", UpdateContourBounds);
            this.MinAreaControl     = new VariableControl("Min Area", UpdateAreaBounds);
            this.MaxAreaControl     = new VariableControl("Max Area", UpdateAreaBounds);

            this.Rotations = Settings.Instance.Get("Rotations");

            UpdateCannyParams();
            UpdateContourBounds();
            UpdateAreaBounds();
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a new UserProfileObject with relevant information
 /// </summary>
 public UserProfileObject(Visitor visitor, WebcamHelper webcamHelper)
 {
     Visitor      = visitor;
     WebcamHelper = webcamHelper;
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a new UserProfileObject with relevant information
 /// </summary>
 public UserProfileObject(Member visitor, WebcamHelper webcamHelper)
 {
     Member       = visitor;
     WebcamHelper = webcamHelper;
 }