I am running a OpenCV tutorial where I am stuck at a problem displaying a message ! The program intention is to modify the image into gray image.
Here is the screenshot of the error.
Debug assertion Failed!
Program:..ments\Visual Studio 2008\Projects\new_demo\Debug\new_demo.exe
File:f:\dd\vctools\crt_bld\self_x86\crt\src\xstring
Line:1094
Expression: Invalid null pointer
Abort Retry Ignore
and this is my code new_demo.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( "new.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;
}
Help me with the solution?