public void Receiver_OnConnectionChanged(OYOReceiver receiver) { try { this.SetProgressbarState(this.raspCamProgressbar, receiver.Connected); this.raspCamProgressbar.Invoke(new MethodInvoker(delegate() { this.raspCamProgressbar.Value = receiver.Connected ? 15 : 0; this.raspCamProgressbar.ProgressBackColor = receiver.Connected ? Color.Gainsboro : Color.FromArgb(255, 200, 150); })); this.cameraConnectionLabel.Invoke(new MethodInvoker(delegate() { this.cameraConnectionLabel.Text = receiver.Connected ? "연결됨" : "연결 안됨"; })); this.cameraStatePanel.Invoke(new MethodInvoker(delegate() { this.cameraStatePanel.Visible = receiver.Connected; })); } catch (Exception) { } }
public void Receiver_OnError(OYOReceiver receiver, string message) { var mainform = this; this.Invoke(new MethodInvoker(delegate() { var dialog = new MessageDialog(message, System.Drawing.Color.Gainsboro); dialog.ShowDialog(mainform); })); }
public void Receiver_OnConnectionChanged(OYOReceiver receiver) { try { this.streamingFrameBox.Invoke(new MethodInvoker(delegate() { this.streamingFrameBox.SizeMode = PictureBoxSizeMode.CenterImage; this.streamingFrameBox.Image = Properties.Resources.no_image_available; })); this.Cursor = Cursors.Default; } catch (Exception) { } }
public void Receiver_OnConnectionChanged(OYOReceiver receiver) { try { this.connectionCameraProgressbar.Invoke(new MethodInvoker(delegate() { this.connectionCameraProgressbar.animated = receiver.Connected; this.connectionCameraProgressbar.Value = receiver.Connected ? 15 : 0; })); this.connectionLabel.Invoke(new MethodInvoker(delegate() { connectionLabel.Text = receiver.Connected ? "서버와 연결되었습니다." : "서버와 연결되지 않았습니다."; })); this.synchronizeFromConfig(); } catch (Exception) { } }
public void Receiver_OnDisconnected(OYOReceiver receiver) { //this.detectionStateSwitch.Value = false; }
private void Receiver_OnDisconnected(OYOReceiver receiver) { this.Recorder.Release(); }
public void Receiver_OnUpdate(OYOReceiver receiver, StreamingType streamingType) { try { var stopwatch = new Stopwatch(); stopwatch.Start(); // // Get scaled // var scaled = this.Visualizer.Scaled / 10.0f; var baseSize = new OpenCvSharp.Size(640 * scaled, 480 * scaled); // // Get updated frame and store buffer // var updatedFrame = new Mat(); if (streamingType == StreamingType.Infrared) { updatedFrame = receiver.Infrared(baseSize); this.UpdatedDataBuffer.SetInfrared(this.Visualizer.mappingPalette(updatedFrame), receiver.Temperature(baseSize)); this.Recorder.Write(OYORecorder.RecordingStateType.Infrared, updatedFrame); } else { updatedFrame = receiver.Visual(baseSize); this.UpdatedDataBuffer.SetVisual(updatedFrame); this.Recorder.Write(OYORecorder.RecordingStateType.Visual, updatedFrame); } // // Set current frame box size to fix frame and temperature table size // this.Blender.Size = baseSize; var currentDisplaySize = this.GetDisplaySize(streamingType, updatedFrame); updatedFrame = this.UpdatedDataBuffer.SetDisplay(currentDisplaySize); // // Blend if user checked // var blendedFrame = new Mat(); if (this.Blender.Enabled || this.Recorder.IsRecording(OYORecorder.RecordingStateType.Blending)) { var mask = this.UpdatedDataBuffer.Temperature.Threshold(this.Blender.Threshold, 255, ThresholdTypes.Binary); this.Blender.Update(this.UpdatedDataBuffer.Visual); this.Blender.Update(this.UpdatedDataBuffer.Infrared, mask); if (this.Blender.Blendable) { blendedFrame = this.Blender.Blending(); } if (this.Blender.Enabled) { updatedFrame = blendedFrame; } if (this.Recorder.IsRecording(OYORecorder.RecordingStateType.Blending) && streamingType == StreamingType.Infrared) { this.Recorder.Write(OYORecorder.RecordingStateType.Blending, blendedFrame); } } // // Record display frame // var isDisplayRecordable = this.Recorder.IsRecording(OYORecorder.RecordingStateType.Display) && ((this.Blender.Enabled && streamingType == StreamingType.Infrared) || (this.Visualizer.StreamingType == streamingType)); if (isDisplayRecordable) { var currentRecordSize = this.Recorder.GetRecordSize(OYORecorder.RecordingStateType.Display); var displayFrame = updatedFrame.Resize(currentRecordSize); this.UpdatedDataBuffer.SetDisplay(currentRecordSize); // Draw detection boxes if (this.defaultView.sideExpandedBar.droneTab.ShowDetectionBoxes) { var mask = this.UpdatedDataBuffer.Temperature.Threshold(this.defaultView.sideExpandedBar.detectFireTab.desiredTemperatureSlider.Value, 255, ThresholdTypes.Binary); var betweenMin = this.UpdatedDataBuffer.MeanTemperature - this.UpdatedDataBuffer.MinimumTemperature; var betweenMax = this.UpdatedDataBuffer.MaximumTemperature - this.UpdatedDataBuffer.MeanTemperature; this.Detector.Update(mask, delegate(RotatedRect detectedRect) { var center = this.UpdatedDataBuffer.Temperature.Get <float>((int)detectedRect.Center.Y, (int)detectedRect.Center.X); if (center - this.UpdatedDataBuffer.MeanTemperature > betweenMin * DETECTION_ALPHA) { return(true); } return(false); }); displayFrame = this.Detector.DrawDetectedRects(displayFrame); // Draw temperature label foreach (var detectedRect in this.Detector.DetectedRects) { var center = this.UpdatedDataBuffer.Temperature.Get <float>((int)detectedRect.Center.Y, (int)detectedRect.Center.X); this.Visualizer.markTemperature(displayFrame, new Point(detectedRect.Center.X, detectedRect.Center.Y), center, Scalar.Red); } } // Draw google map if (this.defaultView.sideExpandedBar.droneTab.ShowGmap) { displayFrame = this.Overlayer.Overlay(displayFrame, this.Overlayer.GetGmapPadding(displayFrame)); } // Write record frame this.Recorder.Write(OYORecorder.RecordingStateType.Display, displayFrame); // Restore previous size this.UpdatedDataBuffer.SetDisplay(currentDisplaySize); } // // Detect current frame that showing // if (this.Detector.Enabled) { var mask = this.UpdatedDataBuffer.Temperature.Threshold(this.defaultView.sideExpandedBar.detectFireTab.desiredTemperatureSlider.Value, 255, ThresholdTypes.Binary); var betweenMin = this.UpdatedDataBuffer.MeanTemperature - this.UpdatedDataBuffer.MinimumTemperature; var betweenMax = this.UpdatedDataBuffer.MaximumTemperature - this.UpdatedDataBuffer.MeanTemperature; this.Detector.Detect(mask, delegate(RotatedRect detectedRect) { var center = this.UpdatedDataBuffer.Temperature.Get <float>((int)detectedRect.Center.Y, (int)detectedRect.Center.X); if (center - this.UpdatedDataBuffer.MeanTemperature > betweenMin * DETECTION_ALPHA) { return(true); } return(false); }); updatedFrame = this.Detector.DrawDetectedRects(updatedFrame); // Draw temperature label foreach (var detectedRect in this.Detector.DetectedRects) { var center = this.UpdatedDataBuffer.Temperature.Get <float>((int)detectedRect.Center.Y, (int)detectedRect.Center.X); this.Visualizer.markTemperature(updatedFrame, new Point(detectedRect.Center.X, detectedRect.Center.Y), center, Scalar.Red); } // // Post information to central server // this._detectedWatcher.Stop(); if (this._detectedWatcher.ElapsedMilliseconds > 5000 && this.Detector.DetectedRects.Length != 0 && this.Bebop2.GPS.IsValid) { var detectedRect = this.Detector.DetectedRects[0]; var temperature = this.UpdatedDataBuffer.Temperature.Get <float>((int)detectedRect.Center.Y, (int)detectedRect.Center.X); this.PostDetection(this.Detector.DrawDetectedRects(this.UpdatedDataBuffer.Infrared), this.UpdatedDataBuffer.Visual, receiver.Infrared(), this.Bebop2.GPS.lat, this.Bebop2.GPS.lon, this.Bebop2.Altitude, temperature); this._detectedWatcher.Restart(); } else { this._detectedWatcher.Start(); } } if ((this.Blender.Enabled && streamingType == StreamingType.Infrared) || (!this.Blender.Enabled && this.Visualizer.StreamingType == streamingType)) { this._fps++; } if (this._stopwatch.ElapsedMilliseconds > 1000.0f) { this._lastFps = this._fps; this._fps = 0; this._stopwatch.Restart(); } updatedFrame = updatedFrame.Resize(currentDisplaySize); var fontScaled = Math.Min(updatedFrame.Width / 1200.0f, 0.8f); var baseLine = 0; var text = string.Format("fps : {0}", this._lastFps); var font = HersheyFonts.HersheyPlain; var textSize = Cv2.GetTextSize(text, font, fontScaled, 1, out baseLine); Cv2.PutText(updatedFrame, text, new OpenCvSharp.Point(updatedFrame.Width - textSize.Width * 2, textSize.Height * 3), HersheyFonts.HersheyDuplex, fontScaled, Scalar.White); var invalidated = (this.Blender.Enabled || (this.Visualizer.StreamingType == streamingType)); updatedFrame = this.Overlayer.Overlay(updatedFrame); this.OnFrameUpdated.Invoke(this.UpdatedDataBuffer, updatedFrame, invalidated); stopwatch.Stop(); var header = string.Empty; if (this.Blender.Enabled) { header = "Blend"; } else if (this.Visualizer.StreamingType == StreamingType.Infrared) { header = "Infrared"; } else { header = "Visual"; } stopwatch.Restart(); } catch (Exception e) { return; } }