Thursday, February 13, 2014

Displaying the Image with Open CV and C

This is the second post in Image processing. In previous post I explained the very basic code written with Open CV in C language which is useful for loading the image into the program and displaying it.

In this post I will elaborate the steps involved in displaying the image with Open CV and C.

void main()
{
IplImage* image=cvLoadImage("E:\\Capture.jpg");
cvNamedWindow("Image",WINDOW_AUTOSIZE);
cvShowImage("Image",image);
if(cvWaitKey(1000)==27)
{
cvDestroyWindow("Image");
}
}

This is same as the program in previous post. only change is you explicitly created the window to show the image. and you changed the integer passed to the cvWaitKey function. I guess you know that the ASCII value of the escape is 27. To close the window we compared the ASCII value of the escape key with the ASCII value returned by the waitkey function. If those are equal you are destroying the window so image no longer visible to you.

The cvNamedWindow function takes the two arguments first one is the name of the window and second is the parameter which controls the behavior of the window.

WINDOW_NORMAL If this is set, the user can resize the window (no constraint).
WINDOW_AUTOSIZE If this is set, the window size is automatically adjusted to fit the displayed image (see imshow() ), and you cannot change the window size manually.
WINDOW_OPENGL If this is set, the window will be created with OpenGL support.

In next post I will explain the enhanced version of the code.

                                                                                                                                         

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...