syntax for zooming a video
Hi sir, When i select an area in video that part should be zoomed... would u please help me with a syntax
Hi sir, When i select an area in video that part should be zoomed... would u please help me with a syntax
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;
}
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!
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).
Asked: 2013-03-28 09:43:01 -0600
Seen: 2,774 times
Last updated: Mar 28 '13