private async void ButtonVideo_OnClick(object sender, RoutedEventArgs e) { //Play video await CameraPreviewControl.StartAsync(); CameraPreviewControl.CameraHelper.FrameArrived += CameraPreviewControl_FrameArrived; }
private async Task CleanupCameraAsync() { UnsubscribeFromEvents(); if (CameraPreviewControl != null) { CameraPreviewControl.Stop(); await CameraPreviewControl.CameraHelper?.CleanUpAsync(); } }
private async Task InitCameraAsync() { UnsubscribeFromEvents(); dispatcherQueue = DispatcherQueue.GetForCurrentThread(); if (CameraPreviewControl != null) { CameraPreviewControl.PreviewFailed += CameraPreviewControl_PreviewFailed; await CameraPreviewControl.StartAsync(); CameraPreviewControl.CameraHelper.FrameArrived += CameraPreviewControl_FrameArrived; barcodeReader = new BarcodeReader(); } }
private async void initCamera() { if (_model == null) { await initModel(); } resultsList.Clear(); CameraPreviewControl.Visibility = Visibility.Visible; ImagePreview.Visibility = Visibility.Collapsed; StopAll(); await CameraPreviewControl.StartAsync(); CameraPreviewControl.CameraHelper.FrameArrived += CameraPreviewControl_FrameArrived; }
private async void ButtonVideoClose_OnClick(object sender, RoutedEventArgs e) { //Stop video CameraPreviewControl.CameraHelper.FrameArrived -= CameraPreviewControl_FrameArrived; CameraPreviewControl.Stop(); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { try { m_faceDetector = await FaceDetector.CreateAsync(); MaskDetect = new Helpers.CustomVision.MaskDetection(new string[] { "mask", "no-mask" }); // Load and create the model var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/facemask.onnx")); await MaskDetect.Init(modelFile); } catch (Exception ex) { Debug.WriteLine($"error: {ex.Message}"); MaskDetect = null; } for (int i = 0; i < 4; i++) { LastSaved[i] = DateTime.MinValue; } if (Sounds.Count <= 0) { //Sounds.Add("wengi.mp3"); //Sounds.Add("setan.wav"); //Sounds.Add("setan2.wav"); //Sounds.Add("zombie.wav"); //Sounds.Add("zombie2.wav"); //Sounds.Add("scream.mp3"); //Sounds.Add("monster.mp3"); } m_processedBitmapSource[0] = new SoftwareBitmapSource(); CCTV1.Source = m_processedBitmapSource[0]; // Initialize helper class used to render the skill results on screen m_bboxRenderer[0] = new BoundingBoxRenderer(UIOverlayCanvas1); m_lock.Wait(); { NotifyUser("Initializing skill..."); m_descriptor = new ObjectDetectorDescriptor(); m_availableExecutionDevices = await m_descriptor.GetSupportedExecutionDevicesAsync(); await InitializeObjectDetectorAsync(); await UpdateSkillUIAsync(); } m_lock.Release(); // Ready to begin, enable buttons NotifyUser("Skill initialized. Select a media source from the top to begin."); //Loop(); var availableFrameSourceGroups = await CameraHelper.GetFrameSourceGroupsAsync(); if (availableFrameSourceGroups != null) { CameraHelper cameraHelper = new CameraHelper() { FrameSourceGroup = availableFrameSourceGroups.FirstOrDefault() }; CameraPreviewControl.PreviewFailed += CameraPreviewControl_PreviewFailed; await CameraPreviewControl.StartAsync(cameraHelper); CameraPreviewControl.CameraHelper.FrameArrived += CameraPreviewControl_FrameArrived; } }
public async void OpenCamera() { await CameraPreviewControl.StartAsync(); CameraPreviewControl.CameraHelper.FrameArrived += CameraHelper_FrameArrived; }