Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to insert a small size image on to a big image

I have been successful in inserting text on to the big image but when it comes to inserting an image on to the big image, i am failing again and again. Here is my code of inserting text on to the big image:

int fr=1,i=1;
char name[20],s[20],smiley[20];
Mat image;
while(fr<=751)
{
sprintf(name,"images/img%u.jpg",i);

image = imread(name,CV_LOAD_IMAGE_COLOR);   // Read the file

if(! image.data )                              // Check for invalid input   
{
cout <<  "Could not open or find the image" << std::endl ;
return -1;
}
if((i>=1 && i<=100)||(i>=201 && i<=300) || (i>=401 && i<=500)||(i>=601&& i<=700))
{
putText(image, "HAPPY", cvPoint(80,80), 
FONT_HERSHEY_COMPLEX_SMALL, 1, cvScalar(800,800,950), 1, CV_AA);
}
if((i>=101 && i<=200)||(i>=301 && i<=400) || (i>=501 && i<=600)||(i>=701&& i<=800))
{
putText(image, "SAD", cvPoint(80,80), 
FONT_HERSHEY_COMPLEX_SMALL, 1, cvScalar(800,800,950), 1, CV_AA);    
}
sprintf(s,"pic/img%u.jpg",i);
imwrite(s,image);
fr++;
i++;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );                   // Show our image inside it.

waitKey(0);                                          // Wait for a keystroke in the window           
return 0;

}

Please help in inserting an image on to the big image.

how to insert a small size image on to a big image

I have been successful in inserting text on to the big image but when it comes to inserting an image on to the big image, i am failing again and again. Here is my code of inserting text on to the big image:

int fr=1,i=1;
char name[20],s[20],smiley[20];
Mat image;
while(fr<=751)
{
sprintf(name,"images/img%u.jpg",i);

image = imread(name,CV_LOAD_IMAGE_COLOR);   // Read the file

if(! image.data )                              // Check for invalid input   
{
cout <<  "Could not open or find the image" << std::endl ;
return -1;
}
if((i>=1 && i<=100)||(i>=201 && i<=300) || (i>=401 && i<=500)||(i>=601&& i<=700))
{
putText(image, "HAPPY", cvPoint(80,80), 
FONT_HERSHEY_COMPLEX_SMALL, 1, cvScalar(800,800,950), 1, CV_AA);
}
if((i>=101 && i<=200)||(i>=301 && i<=400) || (i>=501 && i<=600)||(i>=701&& i<=800))
{
putText(image, "SAD", cvPoint(80,80), 
FONT_HERSHEY_COMPLEX_SMALL, 1, cvScalar(800,800,950), 1, CV_AA);    
}
sprintf(s,"pic/img%u.jpg",i);
imwrite(s,image);
fr++;
i++;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );                   // Show our image inside it.

waitKey(0);                                          // Wait for a keystroke in the window           
return 0;

}

Please help in inserting an image on to the big image.