public void SuperResolutionTest() { Mat frame = new Mat(); // input video frame Mat result = new Mat(); // output superresolution image //FrameSource _frameSource = new FrameSource(0); // input frames are obtained from WebCam or USB Camera FrameSource _frameSource = new FrameSource(@"C:\Users\Samantha\Documents\University\Fourth Year\METR4810\Data\Backlight\vi_0004_20180430_015632.mp4", false); // input frames are read from a file _frameSource.NextFrame(frame); // input frames are obtained from WebCam or USB Camera try { for (int i = 0; i < 5; i++) { frame.Save(@"C:\Users\Samantha\Documents\University\Fourth Year\METR4810\Data\SuperresTest\In" + i.ToString("00i") + ".png"); SuperResolution _superResolution = new SuperResolution(Emgu.CV.Superres.SuperResolution.OpticalFlowType.Btvl, _frameSource); _superResolution.NextFrame(result); // output super resolution image result.Save(@"C:\Users\Samantha\Documents\University\Fourth Year\METR4810\Data\SuperresTest\Out" + i.ToString("00i") + ".png"); } } catch (Exception ex) { Console.Write(ex); } }
public override void RunTest() { var capture = new VideoCapture(); capture.Set(VideoCaptureProperties.FrameWidth, 640); capture.Set(VideoCaptureProperties.FrameHeight, 480); capture.Open(-1); if (!capture.IsOpened()) { throw new Exception("capture initialization failed"); } var fs = FrameSource.CreateFrameSource_Camera(-1); var sr = SuperResolution.CreateBTVL1(); sr.SetInput(fs); using var normalWindow = new Window("normal"); using var srWindow = new Window("super resolution"); var normalFrame = new Mat(); var srFrame = new Mat(); while (true) { capture.Read(normalFrame); sr.NextFrame(srFrame); if (normalFrame.Empty() || srFrame.Empty()) { break; } normalWindow.ShowImage(normalFrame); srWindow.ShowImage(srFrame); Cv2.WaitKey(100); } }
void Start() { superResolution = new SuperResolution(fileName, compute); superResolution.Invoke(inputTex); outputImage.texture = superResolution.GetResult(); }
private void btnProcess_Click(object sender, EventArgs e) { SaveSettings(); var input = new Bitmap(Path.Combine(((ComboBoxItem)cmbInputImages.SelectedItem).Value.ToString())); pbOutputInterpolation.Image = null; pbOutputSuperResolution.Image = null; Stopwatch = Stopwatch.StartNew(); var superResoultion = new SuperResolution(input) { BlockWidth = (int)nudBlockSize.Value, BlockHeight = (int)nudBlockSize.Value, DecLevelsCount = (int)nudDecLevelsCount.Value, DecZoomCoef = double.Parse(tbDecreaseRatio.Text), DecBlockWidth = (int)nudBlockSize.Value, DecBlockHeight = (int)nudBlockSize.Value, IncLevelsCount = (int)nudIncLevelsCount.Value, ZoomCoef = double.Parse(tbIncreaseRatio.Text), DecBlockIncXRatio = double.Parse(tbDecIncrementRatio.Text), DecBlockIncYRatio = double.Parse(tbDecIncrementRatio.Text), ReplaceDistance = double.Parse(tbReplaceDistance.Text), BlockIncRatioX = double.Parse(tbOrigIncrement.Text), BlockIncRatioY = double.Parse(tbOrigIncrement.Text), Parallelization = cbParallel.Checked, Blur = cbBlur.Checked, BlurKernelSize = int.Parse(tbBlurKernelSize.Text), BlurSigma = double.Parse(tbBlurSigma.Text) }; progress.Value = 0; superResoultion.FragmentFounded += superResoultion_FragmentFounded; var output = superResoultion.Process(); progress.Value = progress.Maximum; Stopwatch.Stop(); tbTime.Text = Stopwatch.Elapsed.ToString(); /*pbOutputInterpolation.Image = new Bitmap(input, * (int)Math.Round(input.Width * superResoultion.ZoomCoef), * (int)Math.Round(input.Height * superResoultion.ZoomCoef));*/ pbOutputInterpolation.Image = Utils.ChangeSize(input, (int)Math.Round(input.Width * superResoultion.ZoomCoef), (int)Math.Round(input.Height * superResoultion.ZoomCoef)); pbOutputSuperResolution.Image = output.Image; tbMinDistance.Text = output.MinDistance.ToString(); tbMaxDistance.Text = output.MaxDistance.ToString(); tbAvgDistance.Text = output.AvgDistance.ToString(); var extension = Path.GetExtension(cmbInputImages.SelectedItem.ToString()); var fileName = cmbInputImages.SelectedItem.ToString(); pbOutputInterpolation.Image.Save(fileName + " Interpolation (" + tbIncreaseRatio.Text + ").png", ImageFormat.Png); pbOutputSuperResolution.Image.Save(string.Format("{0} SR ({1}{2}).png", fileName, tbIncreaseRatio.Text, cbBlur.Checked ? ", Blur" : "", ImageFormat.Png)); }
public void Run() { var capture = new VideoCapture(); //var capture = new VideoCapture("rtsp://*****:*****@192.168.0.69:554/Streaming/Channels/101"); capture.Set(CaptureProperty.FrameWidth, 640); capture.Set(CaptureProperty.FrameHeight, 480); //capture.Open(-1); capture.Open(-1); if (!capture.IsOpened()) { throw new Exception("capture initialization failed"); } var fs = FrameSource.CreateCameraSource(-1); var sr = SuperResolution.CreateBTVL1(); sr.SetInput(fs); using (var normalWindow = new Window("normal")) using (var srWindow = new Window("super resolution")) { var normalFrame = new Mat(); var srFrame = new Mat(); while (true) { capture.Read(normalFrame); sr.NextFrame(srFrame); if (normalFrame.Empty() || srFrame.Empty()) { break; } normalWindow.ShowImage(normalFrame); srWindow.ShowImage(srFrame); Cv2.WaitKey(100); } } }
private void btnProcess_Click(object sender, EventArgs e) { var input = new Bitmap(tbInputImage.Text); pbInput.Image = input; var stopwatch = Stopwatch.StartNew(); var superResoultion = new SuperResolution(input) { BlockWidth = (int)nudBlockSize.Value, BlockHeight = (int)nudBlockSize.Value, DecLevelsCount = (int)nudDecLevelsCount.Value, DecZoomCoef = double.Parse(tbDecreaseRatio.Text), DecBlockWidth = (int)nudBlockSize.Value, DecBlockHeight = (int)nudBlockSize.Value, IncLevelsCount = (int)nudIncLevelsCount.Value, ZoomCoef = double.Parse(tbIncreaseRatio.Text), DecBlockIncX = (int)nudDecIncrement.Value, DecBlockIncY = (int)nudDecIncrement.Value, ReplaceDistance = double.Parse(tbReplaceDistance.Text), Parallelization = cbParallel.Checked }; var restored = superResoultion.Process(); stopwatch.Stop(); tbTime.Text = stopwatch.Elapsed.ToString(); pbOutputInterpolation.Image = new Bitmap(input, (int)Math.Round(input.Width * superResoultion.ZoomCoef), (int)Math.Round(input.Height * superResoultion.ZoomCoef)); pbOutputSuperResolution.Image = restored; var extension = Path.GetExtension(tbInputImage.Text); var fileName = Path.GetFileNameWithoutExtension(tbInputImage.Text); pbOutputInterpolation.Image.Save(fileName + " Interpolation (" + tbIncreaseRatio.Text + ").png", ImageFormat.Png); pbOutputSuperResolution.Image.Save(fileName + " SR (" + tbIncreaseRatio.Text + ").png", ImageFormat.Png); }
/// <summary> /// Create Bilateral TV-L1 Super Resolution. /// </summary> /// <returns></returns> public static SuperResolution CreateSuperResolution_BTVL1_CUDA() { return(SuperResolution.CreateBTVL1_CUDA()); }