private void OnAutomaticModeSelected() { DialogResult messageBoxResult = MessageBox.Show( "Do you want to calibrate the detection?", "Detection choice", MessageBoxButtons.YesNo); if (messageBoxResult == DialogResult.Yes) { //pictureBox1.Image = new Bitmap(@"C: \Users\tomasz123456\Desktop\Muka1.png"); //pictureBox1.Image = new Bitmap(@"D:\OneDrive\Szczur\Zdjecia Testy\Test2\116.jpeg"); if (pictureBox1.Image is null) { MessageBox.Show(@"There is no image in the PictureBox. Make sure you started streaming the video", "Calibration error"); return; } else { Bitmap img = new Bitmap(pictureBox1.Image); udpServer.ImageBitMap = img; DetectionCalibrator calibrator = new DetectionCalibrator(udpServer.ImageBitMap); CalibrationForm calibrationForm = new CalibrationForm(calibrator); DialogResult formResult = calibrationForm.ShowDialog(); if (formResult == DialogResult.OK) { //ratTracker = new RatTracker(calibrator.LowerHSVLimit, calibrator.UpperHSVLimit); ratTracker.LowerHSVLimit = calibrator.LowerHSVLimit; ratTracker.UpperHSVLimit = calibrator.UpperHSVLimit; } } } robotData.Mode = RobotData.RobotMode.Automatic; }
public CalibrationForm(DetectionCalibrator calibrator) : this() { this.calibrator = calibrator; pictureBoxOriginal.Image = calibrator.GetOriginalImage(); pictureBoxHSV.Image = calibrator.GetHsvBitmap(); ScrollBarValueChanged(); }