Click here to Skip to main content
15,887,966 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
I'm trying to perform super-resolution in EMGU. I have a microscope USB camera where I can acquire sequential frames to files (or memory). I'm pretty new to C# but have reasonable working knowledge. I do have Emgu working well in VS .Net where I'm acquiring and saving images.

I want to perform super-resolution but can't find any decent example code or just examples. There's one example (link below), but I'm using VS .Net and I'm having a hard time understanding.

Please any help is GREATLY appreciated.

emgucv/SuperResolution.cs at master · neutmute/emgucv · GitHub[^]

What I have tried:

Searched everything. Tried to implement short example from link but not working at all. Need example in VS.net to get me going.
Posted
Updated 17-Jun-16 9:10am
Comments
Sergey Alexandrovich Kryukov 13-Feb-16 14:29pm    
Can you see the difference between searching for an example and searching for a solution? Not the same things.
—SA
todd doehring 14-Feb-16 1:18am    
Not sure what you mean. Solution, example; similar terms. Whatever is best.
BillWoodruff 14-Feb-16 1:26am    
Why aren't you asking this question on the EMBU forum:

http://www.emgu.com/forum/
todd doehring 14-Feb-16 14:13pm    
Did that, but not a single response.

This is not a solution. This is what I tried so far, but it is not working yet using EmguCv 3.1:

C#
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.Util;
using Emgu.CV.UI;
using Emgu.CV.Superres;


...

C#
public void SuperReosultionTest()
 {

     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 fs = new FrameSource("video.avi",false); // input frames are read from a file
     _frameSource.NextFrame(frame); // input frames are obtained from WebCam or USB Camera

     ImageViewer viewer = new ImageViewer();
     viewer.Image = frame;
     viewer.ShowDialog();  // display a sample input frame

     SuperResolution _superResolution = new SuperResolution(Emgu.CV.Superres.SuperResolution.OpticalFlowType.Btvl, _frameSource);
     _superResolution.NextFrame(result); // output super resolution image

     viewer.Image = result;
     viewer.ShowDialog(); // display sample output superresolution image

 }



For some reason it always hangs up on

C#
SuperResolution _superResolution = new SuperResolution(Emgu.CV.Superres.SuperResolution.OpticalFlowType.Btvl, _frameSource);



I am still looking for a solution.

After I added
C#
try{...} catch(){...}


I get the following:
"OpenCV: The called functionality is disabled for current build or platform."

So I will try again with another version of OpenCV.
 
Share this answer
 
v2
My solution is working with CPU as my OpenCV is not a GPU build.
It super-slow about 15 seconds per frame. Most likely you can speed this up with working in OpenCV/EmguCV GPU build.

Initially I thought it was not working because of the long delay in SuperRes call, but I compiled and ran the OpenCV sample in VC++ it was also slow.

If you want to do this real-time it will be a issue.

Here is the final solution that worked for me using EmguCV 3.1.0

You might need other class for file I/O etc:

C#
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.Util;
using Emgu.CV.UI;
using Emgu.CV.Superres;
using Emgu.CV.Cuda;




C#
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("video.avi", false); // input frames are read from a file
      _frameSource.NextFrame(frame); // input frames are obtained from WebCam or USB Camera

      for (int i = 0; i < 5; i++)
      {
          frame.Save(@"c:\Dev\superres\inputFrame" + i.ToString("00") + ".png");
          SuperResolution _superResolution = new SuperResolution(Emgu.CV.Superres.SuperResolution.OpticalFlowType.Btvl, _frameSource);
          _superResolution.NextFrame(result); // output super resolution image

          result.Save(@"c:\Dev\superres\outputFrame"+i.ToString("00")+".png");
      }

  }





This program will use an video file stream read 5 frames and generate 5 super resolution images using default EmguCV/superres parameters. With the VC++/OpenCV sample version of the code you can control most of the parameters for super resolution.

Simple but it works!
 
Share this answer
 
Comments
Daciod 2-Jan-17 12:00pm    
I have the same problem, application hangs on creating SuperReslution resolver, what was the reason of it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900