Skip to content

Commit 1a018c2

Browse files
committed
Merge pull request #1243 from sovrasov:eliminate_exit
2 parents 1864cc4 + 1537cbb commit 1a018c2

File tree

4 files changed

+11
-41
lines changed

4 files changed

+11
-41
lines changed

modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,7 @@ class CV_EXPORTS BinaryDescriptor : public Algorithm
747747

748748
/* check parameters */
749749
if( n < 0 || k < 0 || k > n || p <= 0.0 || p >= 1.0 )
750-
{
751-
std::cout << "nfa: wrong n, k or p values." << std::endl;
752-
exit( 0 );
753-
}
750+
CV_Error(Error::StsBadArg, "nfa: wrong n, k or p values.\n");
754751
/* trivial cases */
755752
if( n == 0 || k == 0 )
756753
return -logNT;

modules/plot/src/plot.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,9 @@ namespace cv
6262
Mat _plotData = plotData.getMat();
6363
//if the matrix is not Nx1 or 1xN
6464
if(_plotData.cols > 1 && _plotData.rows > 1)
65-
{
66-
std::cout << "ERROR: Plot data must be a 1xN or Nx1 matrix." << std::endl;
67-
exit(0);
68-
}
65+
CV_Error(Error::StsBadArg, "ERROR: Plot data must be a 1xN or Nx1 matrix.\n");
6966

70-
//if the matrix type is not CV_64F
71-
if(_plotData.type() != CV_64F)
72-
{
73-
std::cout << "ERROR: Plot data type must be double (CV_64F)." << std::endl;
74-
exit(0);
75-
}
67+
CV_Assert(_plotData.type() == CV_64F);
7668

7769
//in case we have a row matrix than needs to be transposed
7870
if(_plotData.cols > _plotData.rows)
@@ -98,17 +90,9 @@ namespace cv
9890
Mat _plotDataY = plotDataY_.getMat();
9991
//f the matrix is not Nx1 or 1xN
10092
if((_plotDataX.cols > 1 && _plotDataX.rows > 1) || (_plotDataY.cols > 1 && _plotDataY.rows > 1))
101-
{
102-
std::cout << "ERROR: Plot data must be a 1xN or Nx1 matrix." << std::endl;
103-
exit(0);
104-
}
93+
CV_Error(Error::StsBadArg, "ERROR: Plot data must be a 1xN or Nx1 matrix.\n");
10594

106-
//if the matrix type is not CV_64F
107-
if(_plotDataX.type() != CV_64F || _plotDataY.type() != CV_64F)
108-
{
109-
std::cout << "ERROR: Plot data type must be double (CV_64F)." << std::endl;
110-
exit(0);
111-
}
95+
CV_Assert(_plotDataX.type() == CV_64F && _plotDataY.type() == CV_64F);
11296

11397
//in case we have a row matrix than needs to be transposed
11498
if(_plotDataX.cols > _plotDataX.rows)

modules/sfm/test/test_common.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ parser_2D_tracks(const string &_filename, std::vector<Mat> &points2d )
8686
ifstream myfile(_filename.c_str());
8787

8888
if (!myfile.is_open())
89-
{
90-
cout << "Unable to read file: " << _filename << endl;
91-
exit(0);
92-
93-
} else {
89+
CV_Error(cv::Error::StsError, string("Unable to read file: ") + _filename + "\n");
90+
else {
9491

9592
double x, y;
9693
string line_str;

modules/surface_matching/src/ppf_helpers.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,8 @@ void writePLY(Mat PC, const char* FileName)
114114
{
115115
std::ofstream outFile( FileName );
116116

117-
if ( !outFile )
118-
{
119-
//cerr << "Error opening output file: " << FileName << "!" << endl;
120-
printf("Error opening output file: %s!\n", FileName);
121-
exit( 1 );
122-
}
117+
if ( !outFile.is_open() )
118+
CV_Error(Error::StsError, String("Error opening output file: ") + String(FileName) + "\n");
123119

124120
////
125121
// Header
@@ -167,12 +163,8 @@ void writePLYVisibleNormals(Mat PC, const char* FileName)
167163
{
168164
std::ofstream outFile(FileName);
169165

170-
if (!outFile)
171-
{
172-
//cerr << "Error opening output file: " << FileName << "!" << endl;
173-
printf("Error opening output file: %s!\n", FileName);
174-
exit(1);
175-
}
166+
if (!outFile.is_open())
167+
CV_Error(Error::StsError, String("Error opening output file: ") + String(FileName) + "\n");
176168

177169
////
178170
// Header

0 commit comments

Comments
 (0)