Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 322

error handling with imread()

$
0
0
Hello all, i am having a problem with the error handling in terms of the API "imread()". If i pass as command line a false file name, like "foobar" created randomly by "touch foobar" in bash. In my code i wrap the "imread()" into a try-catch block as follows: cv:: Mat src; try { src =imread(argv[1]); } catch( cv::Exception& e ) { //const char* err_msg = e.what(); //std::cout << "exception caught: " << err_msg << std::endl; cout <<"wrong file format, please input the name of an IMAGE file" < this->size() (which is 0) Aborted (core dumped) I know this message comes from c++ standard library and i can't change them, is there still any way to get rid of the error message? the program is aborted now, what i am expecting is that it goes into the catch block and print something that can be specified by the programmer, like "wrong file format, please input the name of an IMAGE file"? Besides, i'm using xubuntu 18.04 and opencv 3.2.0, thanks in advance!

Viewing all articles
Browse latest Browse all 322

Trending Articles