From 6752f28a08d6c0ac56c92aa3225a5c2e2dd9cd04 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Thu, 8 Nov 2012 00:20:43 +0100 Subject: kann halbwegs anständig den linken und rechten rand erkennen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- detect_road_borders.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/detect_road_borders.cpp b/detect_road_borders.cpp index 2e2ad07..5e10769 100644 --- a/detect_road_borders.cpp +++ b/detect_road_borders.cpp @@ -317,6 +317,7 @@ int main(int argc, char* argv[]) } #define ANG_SMOOTH 9 + double* angle_derivative = new double[contours[i].size()]; for (j=init_j+ANG_SMOOTH;j lastmax) lastmax=angle_derivative[j]; + if (angle_derivative[j] < MAX_HYST*lastmax && angle_derivative[j+1] < MAX_HYST*lastmax && angle_derivative[j+2] < MAX_HYST*lastmax) + { + int j0=-1; + for (j0=j-1; j0>=0; j0--) + if (angle_derivative[j0] < MAX_HYST*lastmax && angle_derivative[j0-1] < MAX_HYST*lastmax && angle_derivative[j0-2] < MAX_HYST*lastmax) + break; + + if (lastmax > 5) + { + // the maximum area goes from j0 to j + cout << "max from "<bestquality) + { + bestquality=quality; + bestquality_j=(j+j0)/2; + bestquality_width=j-j0; + } + + line(drawing, Point(x,25+40-3*quality), Point(x, 25+40), Scalar(0,255,0)); + circle(drawing, contours[i][(j+j0)/2], 1, Scalar(128,0,0)); + } + lastmax=-999999; + } + } + + for (int j=0;j