opencvResize() problem
I am trying to use opencv2, built on ubuntu 10.04 to get a simple program going which reads a exisitng image, creates another image from it and resize that original image by 2(both width and height). Below is the code. Upon execution, I don't see the resized image window.
# include "stdio.h"
#include "opencv2/highgui/highgui_c.h"
#include <opencv2/imgproc/types_c.h>
int main( int argc, char** argv ) {
IplImage* img = 0;
IplImage* dst_img = 0;
if( argc < 2 ) {
printf( "Usage: Accepts one image as argument\n" );
exit( EXIT_SUCCESS );
}
img = cvLoadImage( argv[1],1);
if( !img ) {
printf( "Error loading image file %s\n", argv[1]);
exit( EXIT_SUCCESS );
}
dst_img = cvCreateImage(cvSize(img->width*2,img->height*2),img->depth,img->nChannels);
if( !dst_img ) {
printf( "Error loading output image file \n");
exit( EXIT_SUCCESS );
}
cvResize(img,dst_img,CV_INTER_LINEAR);
cvNamedWindow( "Original Image", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "RescaledImage", CV_WINDOW_AUTOSIZE );
cvMoveWindow( "Original Image", 720, 515 );
cvMoveWindow( "RescaledImage", 1500,1200 );
cvShowImage( "Original Image", img );
cvShowImage( "RescaledImage", dst_img );
cvWaitKey( 0 );
cvReleaseImage( &img );
cvReleas开发者_JAVA百科eImage( &dst_img );
cvDestroyWindow( "Original Image" );
cvDestroyWindow( "RescaledImage" );
return EXIT_SUCCESS;
}
I am using cvCreateImage(), & cvResize() correctly above?
How can I resize the input image by 2 in both directions?
Any pointers on web(blogs,tutorials) , books for OpenCV which has lot of sample code which one can use to study opencv hands-on?
cvMoveWindow( "RescaledImage", 1500,1200 );
My mistake. I thought this was the dimension of window/image. But this is the position of the window on screen. changed it to -
cvMoveWindow( "RescaledImage", 100,100 );
Both windows are fine now!
精彩评论