display many images in single window in opencv
I am new to opencv. I want to display many images in a single window currently i m showing each image in new window and old window get destroyed.I don't know number of images before hand. below is my code
// newproject.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "highgui.h"
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <conio.h>
#include <opencv2/imgproc/imgproc.hpp> // Gaussian Blur
#include <opencv2/core/core.hpp> // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <conio.h>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//Image Reading
IplImage* img = cvLoadImage( "index.jpg" );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey(0);
cvDestroyWindow( "Example1" );
cout<<img->height<<endl;
cout<<img->width<<endl;
//Summarize by sampling
CvCapture* capture = 0;
capture = cvCreateFileCapture( "video.avi" );
if(!capture){
return -1;
}
IplImage *bgr_frame=cvQueryFrame(capture);//Init the video read
double fps = cvGetCaptureProperty (capture,CV_CAP_PROP_FPS);
CvSize size = cvSize((int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter *writer = cvCreateVideoWriter("ayesh.avi",-1,10,size);
IplImage* logpolar_frame = cvCreateImage(size,IPL_DEPTH_8U,3);
cout<<size.height<<endl;
cout<<size.width<<endl;
int x=0;
while(1){
x++;
bgr_frame = cvQueryFrame( capture );
if(!bgr_frame)
break;
if(x==19||x==21||x==18||x==17||x==22){
cvShowImage("Example2",bgr_frame);
cvWriteFrame( writer, bgr_frame );
}
if(x==20){
cvShowImage("Example2",bgr_frame);
cvShowImage ("Example2",img);
cvWriteFrame( writer, bgr_frame );
cvWriteFrame( writer , img);
x=0;
}
}
cvReleaseVideoWriter( &writer );
cvReleaseCapture( &capture );
cvDestroyWindow( "Example2" );
}
http://answers.opencv.org/question/13876/read-multiple-images-from-folder-and-concat/
http://answers.opencv.org/question/13682/opencv-display-multiple-images-in-single-window/
(why don't you search this page a bit ?)
I searched it but didn't found these answers sorry and thanks for your help