Debug Assertion Failed

Hi, I'm getting this error when i'm trying to start my program:

Debug Assertion Failed!

Program C:\Windows\system32\MSVCP110D.dll
File: c:\program files(x86)\microsoft visual studio 11.0\vc\include\xstring
Line: 1143

Expression: invalid null pointer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  #include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv; using namespace std;
double alpha=1.0;  int beta=10;  /* contrast and brightness control */

int main( int argc, char** argv )
{
    Mat image = imread( argv[1] ); // read in image file
	imshow("Original Image", image);
    Mat new_image = Mat::zeros( image.size(), image.type() );
    //std::cout<<"* Enter alpha brighten factor [1.0-3.0]: ";std::cin>>alpha;
    std::cout<<"* Enter beta contrast increase value [0-100]: "; std::cin>>beta;

    // Do the operation new_image(i,j) = alpha*image(i,j) + beta
    for( int y = 0; y < image.rows; y++ )
    {
        for( int x = 0; x < image.cols; x++ )
        { 
            for( int c = 0; c < 3; c++ )
                new_image.at<Vec3b>(y,x)[c] =
                    saturate_cast<uchar>( ( image.at<Vec3b>(y,x)[c] ) + beta );
        }
    }

    namedWindow("Original Image", 1); namedWindow("New Image", 1);
    imshow("Original Image", image); imshow("New Image", new_image);
    waitKey(); return 0;
}
> invalid null pointer

argv[1] is probably a nullptr.

1
2
3
4
5
6
7
8
9
10
11
int main( int argc, char** argv )
{
     /////////////////  add this //////////////////////////
     if( argc < 2 ) 
     {
          std::cerr << "usage: " << arv[0] << " path_to_image_file\n" ;
          return 1 ; 
     }
    /////////////////////////////////////////////////////
    Mat image = imread( argv[1] ); // read in image file
    // ... 
So, what i have to do?
Because, when I read image like this:
 
Mat image = imread("Blabla.jpg");
everything is ok.
But how can i read image by argv?
Thanks a lot.
Topic archived. No new replies allowed.