Saturday 22 June 2013

OpenCV Tutorial Section 1.9 demo program testing OK












































Now I have also tested the demo program in Section 1.9.  Everything went smoothly.  Now I don't need the BenQ monitor at the RPi anymore.  I used SSH PuTTY to do the cmake and make.  Then set up the tightVNC server, and use Ultra VNC Viewer's LXTerminal to run the DisplayImage program.

.END

pi@raspberrypi ~ $ cd fongvision
pi@raspberrypi ~/fongvision $ ls
DisplayImage  OpenCV-2.3.1  scripts

pi@raspberrypi ~/fongvision $ cd DisplayImage
pi@raspberrypi ~/fongvision/DisplayImage $ ls
CMakeLists.txt  DisplayImage.cpp  TestImage.jpg

pi@raspberrypi ~/fongvision/DisplayImage $ cat DisplayImage.cpp
#include <cv.h>
#include <highgui.h>

using namespace cv;

int main( int argc, char** argv )
{
char* imageName = argv[1];

Mat image;
image = imread( imageName, 1 );

if( argc != 2 || !image.data )
{
printf( " No image data \n " );
return -1;
}

Mat gray_image;
cvtColor( image, gray_image, CV_RGB2GRAY );

imwrite( "../../images/Gray_Image.jpg", gray_image );

namedWindow( imageName, CV_WINDOW_AUTOSIZE );
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );

imshow( imageName, image );
imshow( "Gray image", gray_image );

waitKey(0);

return 0;

pi@raspberrypi ~/fongvision/DisplayImage $ cmake .
...
-- Build files have been written to: /home/pi/fongvision/DisplayImage

pi@raspberrypi ~/fongvision/DisplayImage $ make
...
[100%] Built target DisplayImage

pi@raspberrypi ~/fongvision/DisplayImage $ vncserver :1

New 'X' desktop is raspberrypi:1

Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

****

In Ultra VNC Viewer LXTerminal

pi@raspberrypi ~/fongvision/DisplayImage $./DisplayImage TestImage.jpg

.END

















No comments:

Post a Comment