Fixed errors if not enough corners were found!
This commit is contained in:
parent
f76a5dd73d
commit
ce6fc0db72
@ -17,7 +17,7 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector<Part*>* partAr
|
||||
|
||||
if(!analyse.getImages())
|
||||
{
|
||||
cerr << "Error: No pictures found!" << endl;
|
||||
cerr << "Error occured in getImages!" << endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -373,6 +373,11 @@ bool analyseParts::getImages(){
|
||||
mask.setContour(contours);
|
||||
mask.setHierarchy(hierarchy);
|
||||
corners = findCorners(contours[0],mask.getCenter());
|
||||
if((corners.empty()) || (corners.size() < 4))
|
||||
{
|
||||
cerr << "Error occured in findCorners" << endl;
|
||||
return false;
|
||||
}
|
||||
mask.setCorners(corners);
|
||||
mask.setTabs(analyseContour(corners,contours[0]));
|
||||
masks.push_back(mask);
|
||||
@ -413,6 +418,13 @@ vector<Point> analyseParts::findCorners(vector<Point> contour, Point center){
|
||||
buf3.push_back(contour[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if((buf0.empty()) || (buf1.empty()) || (buf2.empty()) || (buf3.empty()))
|
||||
{
|
||||
// return an empty vector if not all corners were found!
|
||||
return vector<Point>();
|
||||
}
|
||||
|
||||
quad_contour.push_back(buf0);
|
||||
quad_contour.push_back(buf1);
|
||||
quad_contour.push_back(buf2);
|
||||
|
Loading…
Reference in New Issue
Block a user