int selectCorner( GridInfo info ) {

		info.lookupGridCorners(cornerList);

		int bestCorner = -1;
		double bestScore = Double.MAX_VALUE;
		boolean bestIsCornerSquare = false;

		for (int i = 0; i < cornerList.size(); i++) {
			Node n = cornerList.get(i);

			boolean corner = isCornerValidOrigin(n);

			// If there are no corner points which are valid corners, then any corner can be the origin if
			// allowNoCorner is true
			if( corner || (allowNoCorner && !bestIsCornerSquare) ) {
				// sanity check the shape
				if( checkShape != null ) {
					if( i%2==0 ) {
						if( !checkShape.isValidShape(info.rows,info.cols)) {
							continue;
						}
					} else {
						if( !checkShape.isValidShape(info.cols,info.rows)) {
							continue;
						}
					}
				}

				// If the distance is to (0,0) pixel is smaller or this is a corner square and the other best
				// is not a corner square
				double distance = n.normSq();
				if( distance < bestScore || (!bestIsCornerSquare && corner )) {
					bestIsCornerSquare |= corner;
					bestScore = distance;
					bestCorner = i;
				}
			}
		}
		info.hasCornerSquare = bestIsCornerSquare;
		return bestCorner;
	}
int selectCorner ( GridInfo info ) { info . lookupGridCorners ( cornerList ) ; int bestCorner = - 1 ; double bestScore = Double . MAX_VALUE ; boolean bestIsCornerSquare = false ; for ( int i = 0 ; i < cornerList . size ( ) ; i ++ ) { Node n = cornerList . get ( i ) ; boolean corner = isCornerValidOrigin ( n ) ; if ( corner || ( allowNoCorner && ! bestIsCornerSquare ) ) { if ( checkShape != null ) { if ( i % 2 == 0 ) { if ( ! checkShape . isValidShape ( info . rows , info . cols ) ) { continue ; } } else { if ( ! checkShape . isValidShape ( info . cols , info . rows ) ) { continue ; } } } double distance = n . normSq ( ) ; if ( distance < bestScore || ( ! bestIsCornerSquare && corner ) ) { bestIsCornerSquare |= corner ; bestScore = distance ; bestCorner = i ; } } } info . hasCornerSquare = bestIsCornerSquare ; return bestCorner ; }
Selects a corner to be the grid's origin. 0 = top-left, 1 = top-right, 2 = bottom-right, 3 = bottom-left.

Looks at each grid and see if it can be valid. Out of the valid list