Ask Your Question
0

Superresolution: how to process only particular sampled frames

asked 2013-07-10 10:35:54 -0600

student gravatar image

Hi

I have hours-long video and I want to enlarge some frames (of my own choosing) of the video by using super resolution. I'm not interested in processing all the frames (and it'd too slow to process all of them). How can I achieve this?

Note: I've tried the following approach but it doesn't work.

Ptr<SuperResolution> srobj = createSuperResolution_BTVL1();
Ptr<FrameSource> frameSource = createFrameSource_Video("video.mpg");
srobj->setInput(frameSource);

for(;;)
{
 if(certain frames)
 {
  // if certain frame numbers, skip the frame
  frameSource->nextFrame(someMatfile);
  continue;
 }

 // perform super resolution
 srobj->nextFrame(frame_super);

}

Thanks.

edit retag flag offensive close merge delete

Comments

I don't know how your 'certain frames' is implemented, but it looks like you have to specify all frames you don't want???

Ben gravatar imageBen ( 2013-07-10 10:45:56 -0600 )edit

@Ben. Well, I could just have a list/array of frame numbers which I want to keep and skip the current frame if the current frame number is not amongst the list.

student gravatar imagestudent ( 2013-07-10 11:12:34 -0600 )edit

But then it's rather if (not in certain frames), right? ;)

Ben gravatar imageBen ( 2013-07-11 04:08:49 -0600 )edit

A simple solution extend cv::superres::FrameSource with a setFrame member

class MyFrameSource : public cv::superres::FrameSource cv::Mat origFrame_; void MyFrameSource::setFrame(Mat & frame) { frame.copyTo(origFrame_); } void MyFrameSource::nextFrame(cv::OutputArray frame) { origFrame_.copyTo(frame); }

then cv::Ptr<myframesource> lowresSource(new MyFrameSource(cv::superres::createFrameSource_Empty(), scale));

and superRes->setInput(lowresSource);

then, in a i-loop, first copy your i-frame with setFrame then you call superRes->nextFrame(dest) and you will be using that frame. But you will get a TemporalAreaRadius*2+1 frames latency for superres begin to work as it should. You can, for example, loop your frameslist to use the first umprocesed frames.

MikeSZ gravatar imageMikeSZ ( 2016-09-06 11:32:42 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-09-07 09:27:01 -0600

MikeSZ gravatar image

updated 2016-09-07 09:30:36 -0600

A simple solution I'm using right now. Extend cv::superres::FrameSource with a setFrame member

class MyFrameSource : public cv::superres::FrameSource { cv::Mat origFrame_; void MyFrameSource::setFrame(Mat & frame) { frame.copyTo(origFrame_); } void MyFrameSource::nextFrame(cv::OutputArray frame) { origFrame_.copyTo(frame); } } then cv::Ptr<myframesource> lowresSource(new MyFrameSource(cv::superres::createFrameSource_Empty(), scale)); and superRes->setInput(lowresSource);

then, in the process loop, first copy your nput frame to framesource with setFrame(), then call superRes->nextFrame(dest) and you will be using that frame. But you will get a TemporalAreaRadius*2+1 frames latency for superres to begin to work as it should. You can, for example, loop your frameslist to use the first umprocesed frames. is not the best but it works.

edit flag offensive delete link more
0

answered 2013-07-10 10:48:57 -0600

Vladislav Vinogradov gravatar image

You should skip frames before you pass frameSource to srobj:

Ptr<FrameSource> frameSource = createFrameSource_Video("video.mpg");
Mat frame;
for(int i = 0; i < skip; ++i)
{
    frameSource->nextFrame(frame);
}

Ptr<SuperResolution> srobj = createSuperResolution_BTVL1();
srobj->setInput(frameSource);
edit flag offensive delete link more

Comments

Thanks but not only I want to skip the beginning, I also want to skip certain frames. Putting together you've just said, do you think it's ok for me to add one line (calling srobj->setInput method before calling srobj->next frame in the loop) and do it something like:

Ptr<SuperResolution> srobj = createSuperResolution_BTVL1(); Ptr<FrameSource> frameSource = createFrameSource_Video("video.mpg"); srobj->setInput(frameSource);

for(;;) { if(certain frames) { // if certain frame numbers, skip the frame frameSource->nextFrame(someMatfile); continue; }

// perform super resolution srobj->setInput(frameSource); srobj->nextFrame(frame_super);

}

student gravatar imagestudent ( 2013-07-10 11:09:40 -0600 )edit

For the first call srobj->nextFrame() will read several frames from sources. If you change frame source with setInput method srobj will be reinitialized and it will read several frames again.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-07-11 23:37:47 -0600 )edit

Question Tools

Stats

Asked: 2013-07-10 10:35:54 -0600

Seen: 1,156 times

Last updated: Sep 07 '16