diff options
author | Florian Jung <florian.a.jung@web.de> | 2012-12-04 22:54:18 +0100 |
---|---|---|
committer | Florian Jung <florian.a.jung@web.de> | 2012-12-04 22:54:18 +0100 |
commit | cff7fa7d82dba5d25190dac3181734f36d5156a8 (patch) | |
tree | 784a191b85e2f032f0bebdcab873059221fff044 /horizon_steerer.cpp | |
parent | 7a75768ce2f730cbbbcc98c4b204a30ceb0b7e71 (diff) |
horizonsteerer segfaultet nicht mehr
Diffstat (limited to 'horizon_steerer.cpp')
-rw-r--r-- | horizon_steerer.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/horizon_steerer.cpp b/horizon_steerer.cpp index f15be84..7627c10 100644 --- a/horizon_steerer.cpp +++ b/horizon_steerer.cpp @@ -81,10 +81,12 @@ int HorizonSteerer::find_intersection_index(int x0, int y0, int x1, int y1, int* for(;;) { + if (x0<0 || x0>=xlen || y0<0 || y0>=ylen) break; + //setPixel(x0,y0); if (contour_map[x0][y0]>0) return contour_map[x0][y0]; // found intersection? - if (contour_map[x0][y0+1]>0) return contour_map[x0][y0+1]; - if (contour_map[x0+1][y0]>0) return contour_map[x0+1][y0]; + if (y0+1<ylen && contour_map[x0][y0+1]>0) return contour_map[x0][y0+1]; + if (x0+1<xlen && contour_map[x0+1][y0]>0) return contour_map[x0+1][y0]; @@ -408,7 +410,9 @@ int HorizonSteerer::find_bestquality_index(const vector<Point>& contour, double* // ang_deriv[i] >= MAX_HYST * max_deriv \forall i \in [a,b] and // ang_deriv[a-1,2,3], ang_deriv[b+1,2,3] < MAX_HYST * max_deriv // where max_deriv = max_{i \in [a,b]} ang_deriv[i]; - for (int j=3; j<contour.size()-3; j++) + + // TODO BUG: better assert contour.size()>3 somewhere + for (int j=3; j<(int)contour.size()-3; j++) { // search forward for a maximum, and the end of a maximum region. if (angle_derivative[j] > lastmax) lastmax=angle_derivative[j]; |