private void CloseVideoSource() { Cursor = Cursors.WaitCursor; VideoPlayer.SignalToStop(); for (int i = 0; (i < 50) && (VideoPlayer.IsRunning); i++) { Thread.Sleep(100); } if (VideoPlayer.IsRunning) { VideoPlayer.Stop(); } FPSTimer.Stop(); motionHistory.Clear(); if (detector != null) { detector.Reset(); } VideoPlayer.BorderColor = Color.Black; Cursor = Cursors.Default; }
private void OpenVideoSource(IVideoSource source) { Cursor = Cursors.WaitCursor; CloseVideoSource(); FPSTimer.Start(); VideoPlayer.VideoSource = new AsyncVideoSource(source); VideoPlayer.Start(); Cursor = Cursors.Default; }
public void SimplePipeline() { bool sts = true; PXCMSenseManager pp = form.session.CreateSenseManager(); if (pp == null) throw new Exception("Failed to create sense manager"); disconnected = false; /* Set Source & Profile Index */ PXCMCapture.DeviceInfo info = null; if (this.form.GetRecordState()) { pp.captureManager.SetFileName(this.form.GetFileName(), true); form.PopulateDeviceMenu(); if (this.form.Devices.TryGetValue(this.form.GetCheckedDevice(), out info)) { pp.captureManager.FilterByDeviceInfo(info); } } else if (this.form.GetPlaybackState()) { pp.captureManager.SetFileName(this.form.GetFileName(), false); } else { if (this.form.Devices.TryGetValue(this.form.GetCheckedDevice(), out info)) { pp.captureManager.FilterByDeviceInfo(info); } } /* Set Module */ pp.EnableEmotion(form.GetCheckedModule()); /* Initialization */ form.UpdateStatus("Init Started"); PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler() { //GZ onModuleQueryProfile = OnModuleQueryProfile }; if (pp.Init(handler) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { form.UpdateStatus("Streaming"); this.timer = new FPSTimer(form); PXCMCaptureManager captureManager = pp.QueryCaptureManager(); if (captureManager == null) throw new Exception("Failed to query capture manager"); PXCMCapture.Device device = captureManager.QueryDevice(); if (device != null && !this.form.GetPlaybackState()) device.SetDepthConfidenceThreshold(7); //GZ device.SetProperty(PXCMCapture.Device.Property.PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, 7); while (!form.stop) { if (pp.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR) break; if (!DisplayDeviceConnection(!pp.IsConnected())) { /* Display Results */ PXCMEmotion ft = pp.QueryEmotion(); if (ft == null) { pp.ReleaseFrame(); continue; } //GZ DisplayPicture(pp.QueryImageByType(PXCMImage.ImageType.IMAGE_TYPE_COLOR)); PXCMCapture.Sample sample = pp.QueryEmotionSample(); if (sample == null) { pp.ReleaseFrame(); continue; } DisplayPicture(sample.color); DisplayLocation(ft); form.UpdatePanel(); } pp.ReleaseFrame(); } } else { form.UpdateStatus("Init Failed"); sts = false; } pp.Close(); pp.Dispose(); if (sts) form.UpdateStatus("Stopped"); }
public VisualizationBase() { _timer = new FPSTimer(60); _timer.Start(); EnableRendering = true; }