1. Each slide is presented for a duration of T where T is settable from 0.5 seconds to 5 seconds with a slide bar that is in the viewer window.
2. Slides are shown in endless loop such that after the last slide has been presented the first slide is shown again.
3. There must be a gradual transition between showing successive slides as shown in the timing diagram below:
#include <cv.h>
#include <stdafx.h>
#include <highgui.h>
#include <cxcore.h>
using namespace cv;
int g_slider_position = 0;
CvCapture* g_capture = NULL;
void onTrackbarSlide(int pos) {
}
int main( ) {
IplImage* src1 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right01.jpg" );
IplImage* src2 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right02.jpg" );
IplImage* src3 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right03.jpg" );
IplImage* src4 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right04.jpg" );
IplImage* src5 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right05.jpg" );
IplImage* src6 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right06.jpg" );
IplImage* src7 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right07.jpg" );
IplImage* src8 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right08.jpg" );
IplImage* src9 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right09.jpg" );
IplImage* src10 = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right11.jpg" );
IplImage* src[] ={src1,src2,src3,src4,src5,src6,src7,src8,src9,src10};
IplImage* dst = cvLoadImage( "C:\\ENEL\\OpenCV2.1\\samples\\c\\right01.jpg" );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvCreateTrackbar(
"T",
"Example1",
&g_slider_position,
5,
onTrackbarSlide
);
for(int b=0; ;b++)
{
if(b==9){// transition from last slide to the first one
for(double a=1;a>=0;)
{
cvAddWeighted(src10,a,src1,(1-a),0,dst);
cvShowImage( "Example1", dst );
cvWaitKey(10);
a = a - 0.01;
}
b=0;
cvWaitKey(1000*g_slider_position+1);}
for(double a=1;a>=0;)//gradual transition
{
cvAddWeighted(src[b],a,src[b+1],(1-a),0,dst);
cvShowImage( "Example1", dst );
cvWaitKey(10);
a = a - 0.01;
}
cvWaitKey(1000*g_slider_position+1);//lenth of displaying a picture
}
cvWaitKey(0);
cvReleaseImage( src );
cvReleaseImage( &dst );
cvDestroyWindow( "Example1" );
}
No comments:
Post a Comment