void removeDuplicates ( GrowQueue_I32 corners ) { // remove duplicates for ( int i = 0 ; i < corners . size ( ) ; i ++ ) { Point2D_I32 a = contour . get ( corners . get ( i ) ) ; // start from the top so that removing a corner doesn't mess with the for loop for ( int j = corners . size ( ) - 1 ; j > i ; j -- ) { Point2D_I32 b = contour . get ( corners . get ( j ) ) ; if ( a . x == b . x && a . y == b . y ) { // this is still ok if j == 0 because it wrapped around. 'i' will now be > size corners . remove ( j ) ; } } } }
Look for two corners which point to the same point and removes one of them from the corner list