private void createPositionPatternGraph ( ) { // Add items to NN search nn . setPoints ( ( List ) positionPatterns . toList ( ) , false ) ; for ( int i = 0 ; i < positionPatterns . size ( ) ; i ++ ) { PositionPatternNode f = positionPatterns . get ( i ) ; // The QR code version specifies the number of "modules"/blocks across the marker is // A position pattern is 7 blocks. A version 1 qr code is 21 blocks. Each version past one increments // by 4 blocks. The search is relative to the center of each position pattern, hence the - 7 double maximumQrCodeWidth = f . largestSide * ( 17 + 4 * maxVersionQR - 7.0 ) / 7.0 ; double searchRadius = 1.2 * maximumQrCodeWidth ; // search 1/2 the width + some fudge factor searchRadius *= searchRadius ; // Connect all the finder patterns which are near by each other together in a graph search . findNearest ( f , searchRadius , Integer . MAX_VALUE , searchResults ) ; if ( searchResults . size > 1 ) { for ( int j = 0 ; j < searchResults . size ; j ++ ) { NnData < SquareNode > r = searchResults . get ( j ) ; if ( r . point == f ) continue ; // skip over if it's the square that initiated the search considerConnect ( f , r . point ) ; } } } }
Connects together position patterns . For each square finds all of its neighbors based on center distance . Then considers them for connections