FIX segfault in find_longest_line
This commit is contained in:
parent
22d6af3eb7
commit
d1ba152d62
1 changed files with 9 additions and 4 deletions
13
cvutils.cpp
13
cvutils.cpp
|
@ -119,12 +119,17 @@ find_longest_line(std::vector<cv::Point> hull, unsigned begin, unsigned end) //t
|
||||||
{
|
{
|
||||||
std::vector<cv::Point> bestline, thisline;
|
std::vector<cv::Point> bestline, thisline;
|
||||||
int bestdistance = 0;
|
int bestdistance = 0;
|
||||||
thisline.push_back(hull[begin++]);
|
thisline.push_back(hull[(begin)%hull.size()]);
|
||||||
thisline.push_back(hull[(begin++)%hull.size()]);
|
thisline.push_back(hull[(begin+1)%hull.size()]);
|
||||||
for(unsigned i=begin; i!=end; i++)
|
for(unsigned i=(begin+2)%hull.size(); i!=end; i++)
|
||||||
{
|
{
|
||||||
if(unlikely(i==hull.size()))
|
assert(2<=thisline.size());
|
||||||
|
std::cerr << "prima" << i << " hullsize " << hull.size() << std::endl;
|
||||||
|
if(i==hull.size()) {
|
||||||
i=0;
|
i=0;
|
||||||
|
}
|
||||||
|
std::cerr << "dopo " << i << " hullsize " << hull.size() << std::endl;
|
||||||
|
assert(i < hull.size());
|
||||||
if(similar_fit(thisline, hull[i])) {
|
if(similar_fit(thisline, hull[i])) {
|
||||||
thisline.push_back(hull[i]);
|
thisline.push_back(hull[i]);
|
||||||
} else { // considering if the just-finished line is the best
|
} else { // considering if the just-finished line is the best
|
||||||
|
|
Loading…
Reference in a new issue