Superresolution: how to process only particular sampled frames
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.
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. 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.
But then it's rather
if (not in certain frames)
, right? ;)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.