Arbeitsgruppe KI, Instituts für Informatik, Universität Freiburg


Objekt-Erkennung á la Thilo Weigel



Um mit der RoboCup Software Objekte auf dem Spielfeld zu erkennen, benötigen Sie aus dem Scanstudio die folgenden Funktionen: Ausserdem werden noch die beiden folgenden Funktionen ScanLineScanDifferencefilter und ScanClusterFilter benötigt: /* ** remove all clusters from scan which aren't made of at least ** 'min_cluster_points' scan points */ void ScanClusterReduceFilter(struct Scan *scan, int min_cluster_points) { int i, j = 0; for(i = 0; i < scan->sc_Num; i++) { if(scan->sc_Points[i].sp_Weight >= min_cluster_points) { scan->sc_Points[j] = scan->sc_Points[i]; j++; } } scan->sc_Num = j; } /* ** cluster scan points of 'scan' with distance less than 'reduce_radius' */ void ScanClusterFilter(struct Scan *scan, double reduce_radius) { if(scan && scan->sc_Num > 0) { struct ScanPoint *sp = scan->sc_Points; long num, weight, i, j; double x, y; double sx, sy, sa; GetScanPosition(scan, &sx, &sy, &sa); x = sp[0].sp_X; y = sp[0].sp_Y; j = 0; num = 1; weight = sp[0].sp_Weight; for(i=1; i < scan->sc_Num; i++) { if(DistancePointToPoint(&sp[i-1], &sp[i]) < 2.0 * reduce_radius) { x += sp[i].sp_X; y += sp[i].sp_Y; num++; weight += sp[i].sp_Weight; } else { x /= (double)num; y /= (double)num; sp[j].sp_X = x; sp[j].sp_Y = y; x -= sx; y -= sy; sp[j].sp_A = NormAngle(atan2(y, x) - sa); sp[j].sp_D = sqrt(x*x + y*y); sp[j].sp_Weight = weight; sp[j].sp_LineNum = sp[i-num].sp_LineNum; j++; x = sp[i].sp_X; y = sp[i].sp_Y; weight = sp[i].sp_Weight; num = 1; } } x /= (double)num; y /= (double)num; sp[j].sp_X = x; sp[j].sp_Y = y; x -= sx; y -= sy; sp[j].sp_A = NormAngle(atan2(y, x) - sa); sp[j].sp_D = sqrt(x*x + y*y); sp[j].sp_Weight = weight; sp[j].sp_LineNum = sp[i-num].sp_LineNum; j++; scan->sc_Num = j; } } Hier nun ein Beispiel, wie man aus einem Scan Objekte extrahiert: /* work on duplicate of scan */ dscan = DuplicateScan(scan); % aus 'scan' sollen die Objekte extrahiert werden % if(dscan == NULL) { fprintf(stderr,"Error\n"); return; } ScanLineScanDifferenceFilter(dscan, lineScan, MAX_LINE_DISTANCE); % 'lineScan' enthaelt die Modellinien ScanMedianFilter(dscan); % "glaettet" Scan % old_sc_Num = 0; while(old_sc_Num != dscan->sc_Num) { old_sc_Num = dscan->sc_Num; ScanClusterFilter(dscan, MAX_CLUSTER_RADIUS); % } ScanClusterReduceFilter(dscan, MIN_CLUSTER_POINTS); Voila: dscan enthaelt nun als "Scanpunkte" die geschaetzten Mittelpunkte extrahierter Objekte...
Wolfgang Hatzack
Last modified: Mon Feb 8 09:20:22 MET 1999