Skip to content

Commit d6bbcd6

Browse files
committed
Merge pull request #1621 from alalek:replace_cv_errornoreturn
2 parents a4e8622 + 1248ebe commit d6bbcd6

22 files changed

+29
-67
lines changed

modules/datasets/src/or_pascal.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ Ptr<Object> OR_pascalImp::parseAnnotation(const string &path, const string &id)
143143
case XML_ERROR_FILE_NOT_FOUND:
144144
error_message = "XML file not found! " + error_message;
145145
CV_Error(Error::StsParseError, error_message);
146-
return annotation;
147146
default:
148147
CV_Error(Error::StsParseError, error_message);
149148
break;

modules/face/src/face_alignment.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ bool FacemarkKazemiImpl::convertToUnit(Rect r,Mat &warp){
7979
bool FacemarkKazemiImpl::setMeanExtreme(){
8080
if(meanshape.empty()){
8181
String error_message = "Model not loaded properly.No mean shape found.Aborting...";
82-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
83-
return false;
82+
CV_Error(Error::StsBadArg, error_message);
8483
}
8584
for(size_t i=0;i<meanshape.size();i++){
8685
if(meanshape[i].x>maxmeanx)
@@ -98,7 +97,7 @@ bool FacemarkKazemiImpl::calcMeanShape (vector< vector<Point2f> >& trainlandmark
9897
//clear the loaded meanshape
9998
if(trainimages.empty()||trainlandmarks.size()!=trainimages.size()) {
10099
// throw error if no data (or simply return -1?)
101-
CV_ErrorNoReturn(Error::StsBadArg, "Number of images is not equal to corresponding landmarks. Aborting...");
100+
CV_Error(Error::StsBadArg, "Number of images is not equal to corresponding landmarks. Aborting...");
102101
}
103102
meanshape.clear();
104103
vector<Mat> finalimages;
@@ -165,7 +164,7 @@ bool FacemarkKazemiImpl::scaleData( vector< vector<Point2f> > & trainlandmarks,
165164
{
166165
if(trainimages.empty()||trainimages.size()!=trainlandmarks.size()){
167166
// throw error if no data (or simply return -1?)
168-
CV_ErrorNoReturn(Error::StsBadArg, "The data is not loaded properly by train function. Aborting...");
167+
CV_Error(Error::StsBadArg, "The data is not loaded properly by train function. Aborting...");
169168
}
170169
float scalex,scaley;
171170
//scale all images and their landmarks according to input size

modules/face/src/facemark.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ bool loadTrainingData(vector<String> filename,vector< vector<Point2f> >
228228
f1.open(filename[j].c_str(),ios::in);
229229
if(!f1.is_open()){
230230
cout<<filename[j]<<endl;
231-
CV_ErrorNoReturn(Error::StsError, "File can't be opened for reading!");
232-
return false;
231+
CV_Error(Error::StsError, "File can't be opened for reading!");
233232
}
234233
//get the path of the image whose landmarks have to be detected
235234
getline(f1,img);

modules/face/src/lbph_faces.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,8 @@ static Mat histc(InputArray _src, int minVal, int maxVal, bool normed)
307307
case CV_32FC1:
308308
return histc_(src, minVal, maxVal, normed);
309309
break;
310-
default:
311-
CV_Error(Error::StsUnmatchedFormats, "This type is not implemented yet."); break;
312310
}
313-
return Mat();
311+
CV_Error(Error::StsUnmatchedFormats, "This type is not implemented yet.");
314312
}
315313

316314

modules/face/src/regtree.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ bool FacemarkKazemiImpl:: getBestSplit(vector<Point2f> pixel_coordinates, vector
113113
{
114114
if(samples[0].shapeResiduals.size()!=samples[0].current_shape.size()){
115115
String error_message = "Error while generating split.Residuals are not complete.Aborting....";
116-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
117-
return false;
116+
CV_Error(Error::StsBadArg, error_message);
118117
}
119118
//This vector stores the matrices where each matrix represents
120119
//sum of the residuals of shapes of samples which go to the left
@@ -222,13 +221,11 @@ bool FacemarkKazemiImpl :: generateSplit(queue<node_info>& curr,vector<Point2f>
222221
bool FacemarkKazemiImpl :: buildRegtree(regtree& tree,vector<training_sample>& samples,vector<Point2f> pixel_coordinates){
223222
if(samples.size()==0){
224223
String error_message = "Error while building regression tree.Empty samples. Aborting....";
225-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
226-
return false;
224+
CV_Error(Error::StsBadArg, error_message);
227225
}
228226
if(pixel_coordinates.size()==0){
229227
String error_message = "Error while building regression tree.No pixel coordinates. Aborting....";
230-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
231-
return false;
228+
CV_Error(Error::StsBadArg, error_message);
232229
}
233230
queue<node_info> curr;
234231
node_info parent;
@@ -291,8 +288,7 @@ unsigned long FacemarkKazemiImpl::divideSamples (splitr split,vector<training_sa
291288
{
292289
if(samples.size()==0){
293290
String error_message = "Error while dividing samples. Sample array empty. Aborting....";
294-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
295-
return 0;
291+
CV_Error(Error::StsBadArg, error_message);
296292
}
297293
unsigned long i = start;
298294
training_sample temp;

modules/face/src/trainFacemark.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ bool FacemarkKazemiImpl::setTrainingParameters(String filename){
5454
fs.open(filename, FileStorage::READ);
5555
if (!fs.isOpened())
5656
{ String error_message = "Error while opening configuration file.Aborting..";
57-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
58-
return false;
57+
CV_Error(Error::StsBadArg, error_message);
5958
}
6059
int cascade_depth_;
6160
int tree_depth_;
@@ -105,8 +104,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
105104
if(meanshape.empty()) {
106105
// throw error if no data (or simply return -1?)
107106
String error_message = "The data is not loaded properly by train function. Aborting...";
108-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
109-
return false;
107+
CV_Error(Error::StsBadArg, error_message);
110108
}
111109
float dist=float(INT_MAX);
112110
unsigned long index =0;
@@ -122,8 +120,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
122120
bool FacemarkKazemiImpl :: getRelativePixels(vector<Point2f> sample,vector<Point2f>& pixel_coordinates,std::vector<int> nearest){
123121
if(sample.size()!=meanshape.size()){
124122
String error_message = "Error while finding relative shape. Aborting....";
125-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
126-
return false;
123+
CV_Error(Error::StsBadArg, error_message);
127124
}
128125
Mat transform_mat;
129126
transform_mat = estimateRigidTransform(meanshape,sample,false);
@@ -146,8 +143,7 @@ bool FacemarkKazemiImpl :: getRelativePixels(vector<Point2f> sample,vector<Point
146143
bool FacemarkKazemiImpl::getPixelIntensities(Mat img,vector<Point2f> pixel_coordinates,vector<int>& pixel_intensities,Rect face){
147144
if(pixel_coordinates.size()==0){
148145
String error_message = "No pixel coordinates found. Aborting.....";
149-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
150-
return false;
146+
CV_Error(Error::StsBadArg, error_message);
151147
}
152148
Mat transform_mat;
153149
convertToActual(face,transform_mat);
@@ -259,13 +255,11 @@ bool FacemarkKazemiImpl :: saveModel(String filename){
259255
ofstream f(filename.c_str(),ios::binary);
260256
if(!f.is_open()){
261257
String error_message = "Error while opening file to write model. Aborting....";
262-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
263-
return false;
258+
CV_Error(Error::StsBadArg, error_message);
264259
}
265260
if(loaded_forests.size()!=loaded_pixel_coordinates.size()){
266261
String error_message = "Incorrect training data. Aborting....";
267-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
268-
return false;
262+
CV_Error(Error::StsBadArg, error_message);
269263
}
270264
string s("cascade_depth");
271265
uint64_t len = s.size();
@@ -306,23 +300,20 @@ void FacemarkKazemiImpl::training(String imageList, String groundTruth){
306300
imageList.clear();
307301
groundTruth.clear();
308302
String error_message = "Less arguments than required";
309-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
310-
return ;
303+
CV_Error(Error::StsBadArg, error_message);
311304
}
312305
bool FacemarkKazemiImpl::training(vector<Mat>& images, vector< vector<Point2f> >& landmarks,string filename,Size scale,string modelFilename){
313306
if(!setTrainingParameters(filename)){
314307
String error_message = "Error while loading training parameters";
315-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
316-
return false;
308+
CV_Error(Error::StsBadArg, error_message);
317309
}
318310
vector<Rect> rectangles;
319311
scaleData(landmarks,images,scale);
320312
calcMeanShape(landmarks,images,rectangles);
321313
if(images.size()!=landmarks.size()){
322314
// throw error if no data (or simply return -1?)
323315
String error_message = "The data is not loaded properly. Aborting training function....";
324-
CV_ErrorNoReturn(Error::StsBadArg, error_message);
325-
return false;
316+
CV_Error(Error::StsBadArg, error_message);
326317
}
327318
vector<training_sample> samples;
328319
getTestCoordinates();

modules/line_descriptor/src/binary_descriptor.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,8 @@ int BinaryDescriptor::descriptorSize() const
337337
/* power function with error management */
338338
static inline int get2Pow( int i )
339339
{
340-
if( i >= 0 && i <= 7 )
341-
return 1 << i;
342-
else
343-
{
344-
CV_Error( Error::StsBadArg, "Invalid power argument" );
345-
return -1;
346-
}
340+
CV_DbgAssert(i >= 0 && i <= 7);
341+
return 1 << i;
347342
}
348343

349344
/* compute Gaussian pyramids */

modules/rgbd/src/linemod.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ static inline int getLabel(int quantized)
6666
case 128: return 7;
6767
default:
6868
CV_Error(Error::StsBadArg, "Invalid value of quantized parameter");
69-
return -1; //avoid warning
7069
}
7170
}
7271

modules/tracking/src/gtrTracker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Ptr<TrackerGOTURN> TrackerGOTURN::create(const TrackerGOTURN::Params &parameters
5858
return Ptr<gtr::TrackerGOTURNImpl>(new gtr::TrackerGOTURNImpl(parameters));
5959
#else
6060
(void)(parameters);
61-
CV_ErrorNoReturn(cv::Error::StsNotImplemented , "to use GOTURN, the tracking module needs to be built with opencv_dnn !");
61+
CV_Error(cv::Error::StsNotImplemented , "to use GOTURN, the tracking module needs to be built with opencv_dnn !");
6262
#endif
6363
}
6464
Ptr<TrackerGOTURN> TrackerGOTURN::create()

modules/tracking/src/tracker.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ bool Tracker::init( InputArray image, const Rect2d& boundingBox )
7373
if( model == 0 )
7474
{
7575
CV_Error( -1, "The model is not initialized" );
76-
return false;
7776
}
7877

7978
if( initTracker )

0 commit comments

Comments
 (0)