fix exception being thrown when no arguments are passed

This commit is contained in:
Adrien BAK 2013-11-28 12:09:17 +09:00
parent 094d7c4926
commit 38904c9a11

View File

@ -16,6 +16,7 @@ namespace
const std::string windowName = "Hough Circle Detection Demo";
const std::string cannyThresholdTrackbarName = "Canny threshold";
const std::string accumulatorThresholdTrackbarName = "Accumulator Threshold";
const std::string usage = "Usage : tutorial_HoughCircle_Demo <path_to_input_image>\n";
// initial and max values of the parameters of interests.
const int cannyThresholdInitialValue = 200;
@ -48,17 +49,24 @@ namespace
}
int main(int, char** argv)
int main(int argc, char** argv)
{
Mat src, src_gray;
if (argc < 2)
{
std::cerr<<"No input image specified\n";
std::cout<<usage;
return -1;
}
// Read the image
src = imread( argv[1], 1 );
if( !src.data )
{
std::cerr<<"Invalid input image\n";
std::cout<<"Usage : tutorial_HoughCircle_Demo <path_to_input_image>\n";
std::cout<<usage;
return -1;
}