Created
November 1, 2012 18:48
-
-
Save nikhil9/3995679 to your computer and use it in GitHub Desktop.
Sample code to load GrayScale image using Opencv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cv.h> | |
#include <highgui.h> | |
using namespace std; | |
char key; | |
int main() | |
{ | |
IplImage* frame=cvLoadImage("img1.png",CV_LOAD_IMAGE_GRAYSCALE); //Load image in IplImage frame. | |
cvNamedWindow("window1", CV_WINDOW_AUTOSIZE); //Create window of name 'Window1' | |
if(frame == NULL){ //if image file not found then print this message | |
printf("the file doesnot exist"); | |
exit(0); | |
} | |
cvShowImage("window1",frame); //Display image in Window1 | |
cvWaitKey(); //Wait for keyboard input | |
cvDestroyWindow( "window1" ); //destroy window | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment