Ask Your Question
0

syntax for zooming a video

asked 2013-03-28 09:43:01 -0600

abikala gravatar image

Hi sir, When i select an area in video that part should be zoomed... would u please help me with a syntax

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2013-03-28 10:40:28 -0600

berak gravatar image

i'm using this:

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;

bool down   = false;
bool hasRoi = false;
Point tl,br;
Rect  roi;

void onmouse( int evnt, int x, int y, int d, void *p )
{
    if ( evnt==4 )   
    {
        if ( tl.x<br.x+5)
            roi=Rect(tl,br);   
        down = false; 
    }
    if ( evnt==1 )   { tl = Point(x,y); down = true; }
    if ( d==1 )      { br = Point(x,y); }
}
int main(int argc, char *argv[]) 
{
    namedWindow("win",1);
    setMouseCallback("win",onmouse);
    VideoCapture cap("../HHParticleFilter/recording_mask.avi"); 
    while(cap.isOpened())
    {
        Mat imag, show;
        cap >> imag;

        if ( roi.area()>=32 ) 
            resize(imag(roi),show,imag.size());
        else 
            show = imag;

        if ( down )
            rectangle(show,tl,br,Scalar(0,0,200));

        int k = waitKey(40);
        if ( k==27  ) break;
        if ( k==' ' ) roi.x=roi.y=roi.height=roi.width=0; // revert to original

        imshow("win",show);
    }
    return 0;
}
edit flag offensive delete link more
0

answered 2013-03-28 10:22:57 -0600

Actually superresolution is only interesting if you want to improve the resolution. I guess playing around with the region of interest parameter will get you much further.

Dynamically changing the region of interest on a frame, by hitting buttons, would result in a sort of zoom like function.

Go ahead and try!

edit flag offensive delete link more
0

answered 2013-03-28 09:47:56 -0600

Look at SuperResolution functionalities, or super_resolution.cpp samples in GPU directory if it's what you want.

Otherwise, I think you should implement a zoom yourself (google computer vision paper to find right algorithms).

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-28 09:43:01 -0600

Seen: 2,774 times

Last updated: Mar 28 '13