Commit bacc2106 authored by David Carlier's avatar David Carlier Committed by David Carlier

fixing segfaults occuring when launching those unit tests

parent 0d10eb51
...@@ -1570,7 +1570,8 @@ void CV_StereoCalibrationTest::run( int ) ...@@ -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->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 ); 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; return;
} }
......
...@@ -138,6 +138,9 @@ bool LogisticRegressionImpl::train(const Ptr<TrainData>& trainData, int) ...@@ -138,6 +138,9 @@ bool LogisticRegressionImpl::train(const Ptr<TrainData>& trainData, int)
// return value // return value
bool ok = false; bool ok = false;
if (trainData.empty()) {
return false;
}
clear(); clear();
Mat _data_i = trainData->getSamples(); Mat _data_i = trainData->getSamples();
Mat _labels_i = trainData->getResponses(); Mat _labels_i = trainData->getResponses();
......
...@@ -618,6 +618,7 @@ protected: ...@@ -618,6 +618,7 @@ protected:
{ {
ts->printf(cvtest::TS::LOG, "File with spambase dataset cann't be read.\n"); 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); ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
return;
} }
Mat samples = data->getSamples(); Mat samples = data->getSamples();
......
...@@ -95,6 +95,11 @@ void CV_LRTest::run( int /*start_from*/ ) ...@@ -95,6 +95,11 @@ void CV_LRTest::run( int /*start_from*/ )
string dataFileName = ts->get_data_path() + "iris.data"; string dataFileName = ts->get_data_path() + "iris.data";
Ptr<TrainData> tdata = TrainData::loadFromCSV(dataFileName, 0); 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 // run LR classifier train classifier
Ptr<LogisticRegression> p = LogisticRegression::create(); Ptr<LogisticRegression> p = LogisticRegression::create();
p->setLearningRate(1.0); p->setLearningRate(1.0);
......
...@@ -83,6 +83,9 @@ protected: ...@@ -83,6 +83,9 @@ protected:
vector<PointType> convertContourType(const Mat& currentQuery) const vector<PointType> convertContourType(const Mat& currentQuery) const
{ {
if (currentQuery.empty()) {
return vector<PointType>();
}
vector<vector<Point> > _contoursQuery; vector<vector<Point> > _contoursQuery;
findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE); findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment