fixing segfaults occuring when launching those unit tests

This commit is contained in:
David Carlier 2017-04-17 11:28:14 +00:00 committed by David Carlier
parent 0d10eb5173
commit bacc210606
5 changed files with 14 additions and 1 deletions

View File

@ -1570,7 +1570,8 @@ void CV_StereoCalibrationTest::run( int )
{
ts->printf( cvtest::TS::LOG, "The file %s can not be opened or has invalid content\n", filepath.c_str() );
ts->set_failed_test_info( f ? cvtest::TS::FAIL_INVALID_TEST_DATA : cvtest::TS::FAIL_MISSING_TEST_DATA );
fclose(f);
if (f)
fclose(f);
return;
}

View File

@ -138,6 +138,9 @@ bool LogisticRegressionImpl::train(const Ptr<TrainData>& trainData, int)
// return value
bool ok = false;
if (trainData.empty()) {
return false;
}
clear();
Mat _data_i = trainData->getSamples();
Mat _labels_i = trainData->getResponses();

View File

@ -618,6 +618,7 @@ protected:
{
ts->printf(cvtest::TS::LOG, "File with spambase dataset cann't be read.\n");
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
return;
}
Mat samples = data->getSamples();

View File

@ -95,6 +95,11 @@ void CV_LRTest::run( int /*start_from*/ )
string dataFileName = ts->get_data_path() + "iris.data";
Ptr<TrainData> tdata = TrainData::loadFromCSV(dataFileName, 0);
if (tdata.empty()) {
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
return;
}
// run LR classifier train classifier
Ptr<LogisticRegression> p = LogisticRegression::create();
p->setLearningRate(1.0);

View File

@ -83,6 +83,9 @@ protected:
vector<PointType> convertContourType(const Mat& currentQuery) const
{
if (currentQuery.empty()) {
return vector<PointType>();
}
vector<vector<Point> > _contoursQuery;
findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE);