@@ -54,8 +54,7 @@ bool FacemarkKazemiImpl::setTrainingParameters(String filename){
54
54
fs.open (filename, FileStorage::READ);
55
55
if (!fs.isOpened ())
56
56
{ 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);
59
58
}
60
59
int cascade_depth_;
61
60
int tree_depth_;
@@ -105,8 +104,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
105
104
if (meanshape.empty ()) {
106
105
// throw error if no data (or simply return -1?)
107
106
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);
110
108
}
111
109
float dist=float (INT_MAX);
112
110
unsigned long index =0 ;
@@ -122,8 +120,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
122
120
bool FacemarkKazemiImpl :: getRelativePixels(vector<Point2f> sample,vector<Point2f>& pixel_coordinates,std::vector<int > nearest){
123
121
if (sample.size ()!=meanshape.size ()){
124
122
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);
127
124
}
128
125
Mat transform_mat;
129
126
transform_mat = estimateRigidTransform (meanshape,sample,false );
@@ -146,8 +143,7 @@ bool FacemarkKazemiImpl :: getRelativePixels(vector<Point2f> sample,vector<Point
146
143
bool FacemarkKazemiImpl::getPixelIntensities (Mat img,vector<Point2f> pixel_coordinates,vector<int >& pixel_intensities,Rect face){
147
144
if (pixel_coordinates.size ()==0 ){
148
145
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);
151
147
}
152
148
Mat transform_mat;
153
149
convertToActual (face,transform_mat);
@@ -259,13 +255,11 @@ bool FacemarkKazemiImpl :: saveModel(String filename){
259
255
ofstream f (filename.c_str (),ios::binary);
260
256
if (!f.is_open ()){
261
257
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);
264
259
}
265
260
if (loaded_forests.size ()!=loaded_pixel_coordinates.size ()){
266
261
String error_message = " Incorrect training data. Aborting...." ;
267
- CV_ErrorNoReturn (Error::StsBadArg, error_message);
268
- return false ;
262
+ CV_Error (Error::StsBadArg, error_message);
269
263
}
270
264
string s (" cascade_depth" );
271
265
uint64_t len = s.size ();
@@ -306,23 +300,20 @@ void FacemarkKazemiImpl::training(String imageList, String groundTruth){
306
300
imageList.clear ();
307
301
groundTruth.clear ();
308
302
String error_message = " Less arguments than required" ;
309
- CV_ErrorNoReturn (Error::StsBadArg, error_message);
310
- return ;
303
+ CV_Error (Error::StsBadArg, error_message);
311
304
}
312
305
bool FacemarkKazemiImpl::training (vector<Mat>& images, vector< vector<Point2f> >& landmarks,string filename,Size scale,string modelFilename){
313
306
if (!setTrainingParameters (filename)){
314
307
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);
317
309
}
318
310
vector<Rect> rectangles;
319
311
scaleData (landmarks,images,scale);
320
312
calcMeanShape (landmarks,images,rectangles);
321
313
if (images.size ()!=landmarks.size ()){
322
314
// throw error if no data (or simply return -1?)
323
315
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);
326
317
}
327
318
vector<training_sample> samples;
328
319
getTestCoordinates ();
0 commit comments