Example #1
0
 internal static extern IntPtr cvSuperResolutionCreate(SuperResolution.OpticalFlowType type, IntPtr frameSource, ref IntPtr frameSourceOut);
Example #2
0
 public static void TestSuperres()
 {
    ImageViewer viewer = new ImageViewer();
    //using (Capture capture = new Capture("car.avi"))
    using (Superres.FrameSource frameSource = new Superres.FrameSource("car.avi", false))
    using (Superres.SuperResolution sr = new Superres.SuperResolution(Superres.SuperResolution.OpticalFlowType.Btvl, frameSource))
    //using (Superres.SuperResolution sr = new Superres.SuperResolution(Superres.SuperResolution.OpticalFlowType.BTVL1_OCL, frameSource))
    {
       Stopwatch watch = new Stopwatch();
       int counter = 0;
       Application.Idle += delegate(object sender, EventArgs e)
       {
          watch.Reset();
          watch.Start();
          
          //Image<Bgr, byte> frame = frameSource.NextFrame();
          Mat frame = new Mat(); 
          sr.NextFrame(frame);
          //Image<Gray, Byte> frame = capture.QueryGrayFrame();
          watch.Stop();
          if (watch.ElapsedMilliseconds < 200)
          {
             Thread.Sleep(200 - (int)watch.ElapsedMilliseconds);
          }
          if (!frame.IsEmpty)
          {
             viewer.Image = frame;
             viewer.Text = String.Format("Frame {0}: {1} milliseconds.", counter++, watch.ElapsedMilliseconds);
          } else
          {
             viewer.Text = String.Format("{0} frames processed", counter);
          }
       };
       viewer.ShowDialog();
    }
 }
Example #3
0
 /// <summary>
 /// Create a super resolution solver for the given frameSource
 /// </summary>
 /// <param name="type">The type of optical flow algorithm to use</param>
 /// <param name="frameSource">The frameSource</param>
 public SuperResolution(SuperResolution.OpticalFlowType type, FrameSource frameSource)
    : base()
 {
    _ptr = SuperresInvoke.cvSuperResolutionCreate(type, frameSource, ref _frameSourcePtr);
 }