find() {
        const startX = this.startX;
        const height = this.height;
        const width = this.width;
        const maxJ = startX + width;
        const middleI = this.startY + (height / 2);
        // We are looking for black/white/black modules in 1:1:1 ratio
        // this tracks the number of black/white/black modules seen so far
        const stateCount = new Int32Array(3);
        const image = this.image;
        for (let iGen = 0; iGen < height; iGen++) {
            // Search from middle outwards
            const i = middleI + ((iGen & 0x01) === 0 ? Math.floor((iGen + 1) / 2) : -Math.floor((iGen + 1) / 2));
            stateCount[0] = 0;
            stateCount[1] = 0;
            stateCount[2] = 0;
            let j = startX;
            // Burn off leading white pixels before anything else; if we start in the middle of
            // a white run, it doesn't make sense to count its length, since we don't know if the
            // white run continued to the left of the start point
            while (j < maxJ && !image.get(j, i)) {
                j++;
            }
            let currentState = 0;
            while (j < maxJ) {
                if (image.get(j, i)) {
                    // Black pixel
                    if (currentState === 1) { // Counting black pixels
                        stateCount[1]++;
                    }
                    else { // Counting white pixels
                        if (currentState === 2) { // A winner?
                            if (this.foundPatternCross(stateCount)) { // Yes
                                const confirmed = this.handlePossibleCenter(stateCount, i, j);
                                if (confirmed !== null) {
                                    return confirmed;
                                }
                            }
                            stateCount[0] = stateCount[2];
                            stateCount[1] = 1;
                            stateCount[2] = 0;
                            currentState = 1;
                        }
                        else {
                            stateCount[++currentState]++;
                        }
                    }
                }
                else { // White pixel
                    if (currentState === 1) { // Counting black pixels
                        currentState++;
                    }
                    stateCount[currentState]++;
                }
                j++;
            }
            if (this.foundPatternCross(stateCount)) {
                const confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
                if (confirmed !== null) {
                    return confirmed;
                }
            }
        }
        // Hmm, nothing we saw was observed and confirmed twice. If we had
        // any guess at all, return it.
        if (this.possibleCenters.length !== 0) {
            return this.possibleCenters[0];
        }
        throw new NotFoundException();
    }
/**
     * <p>This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since
     * it's pretty performance-critical and so is written to be fast foremost.</p>
     *
     * @return {@link AlignmentPattern} if found
     * @throws NotFoundException if not found
     */
This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since
it's pretty performance-critical and so is written to be fast foremost.

@return  AlignmentPattern if found
@throws NotFoundException if not found
This method attempts to find the bottom - right alignment pattern in the image . It is a bit messy since it ' s pretty performance - critical and so is written to be fast foremost . @return AlignmentPattern if found @throws NotFoundException if not found
find() {
        const startX = this.startX;
        const height = this.height;
        const width = this.width;
        const maxJ = startX + width;
        const middleI = this.startY + (height / 2);
        const stateCount = new Int32Array(3);
        const image = this.image;
        for (let iGen = 0; iGen < height; iGen++) {
            const i = middleI + ((iGen & 0x01) === 0 ? Math.floor((iGen + 1) / 2) : -Math.floor((iGen + 1) / 2));
            stateCount[0] = 0;
            stateCount[1] = 0;
            stateCount[2] = 0;
            let j = startX;
            while (j < maxJ && !image.get(j, i)) {
                j++;
            }
            let currentState = 0;
            while (j < maxJ) {
                if (image.get(j, i)) {
                    if (currentState === 1) { 
                        stateCount[1]++;
                    }
                    else { 
                        if (currentState === 2) { 
                            if (this.foundPatternCross(stateCount)) { 
                                const confirmed = this.handlePossibleCenter(stateCount, i, j);
                                if (confirmed !== null) {
                                    return confirmed;
                                }
                            }
                            stateCount[0] = stateCount[2];
                            stateCount[1] = 1;
                            stateCount[2] = 0;
                            currentState = 1;
                        }
                        else {
                            stateCount[++currentState]++;
                        }
                    }
                }
                else { 
                    if (currentState === 1) { 
                        currentState++;
                    }
                    stateCount[currentState]++;
                }
                j++;
            }
            if (this.foundPatternCross(stateCount)) {
                const confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
                if (confirmed !== null) {
                    return confirmed;
                }
            }
        }
        if (this.possibleCenters.length !== 0) {
            return this.possibleCenters[0];
        }
        throw new NotFoundException();
    }
find ( ) { const startX = this . startX ; const height = this . height ; const width = this . width ; const maxJ = startX + width ; const middleI = this . startY + ( height / 2 ) ; const stateCount = new Int32Array ( 3 ) ; const image = this . image ; for ( let iGen = 0 ; iGen < height ; iGen ++ ) { const i = middleI + ( ( iGen & 0x01 ) === 0 ? Math . floor ( ( iGen + 1 ) / 2 ) : - Math . floor ( ( iGen + 1 ) / 2 ) ) ; stateCount [ 0 ] = 0 ; stateCount [ 1 ] = 0 ; stateCount [ 2 ] = 0 ; let j = startX ; while ( j < maxJ && ! image . get ( j , i ) ) { j ++ ; } let currentState = 0 ; while ( j < maxJ ) { if ( image . get ( j , i ) ) { if ( currentState === 1 ) { stateCount [ 1 ] ++ ; } else { if ( currentState === 2 ) { if ( this . foundPatternCross ( stateCount ) ) { const confirmed = this . handlePossibleCenter ( stateCount , i , j ) ; if ( confirmed !== null ) { return confirmed ; } } stateCount [ 0 ] = stateCount [ 2 ] ; stateCount [ 1 ] = 1 ; stateCount [ 2 ] = 0 ; currentState = 1 ; } else { stateCount [ ++ currentState ] ++ ; } } } else { if ( currentState === 1 ) { currentState ++ ; } stateCount [ currentState ] ++ ; } j ++ ; } if ( this . foundPatternCross ( stateCount ) ) { const confirmed = this . handlePossibleCenter ( stateCount , i , maxJ ) ; if ( confirmed !== null ) { return confirmed ; } } } if ( this . possibleCenters . length !== 0 ) { return this . possibleCenters [ 0 ] ; } throw new NotFoundException ( ) ; }
<p>This method attempts to find the bottom-right alignment pattern in the image.
<p > This method attempts to find the bottom - right alignment pattern in the image .
// We are looking for black/white/black modules in 1:1:1 ratio // this tracks the number of black/white/black modules seen so far // Search from middle outwards // Burn off leading white pixels before anything else; if we start in the middle of // a white run, it doesn't make sense to count its length, since we don't know if the // white run continued to the left of the start point // Black pixel // Counting black pixels // Counting white pixels // A winner? // Yes // White pixel // Counting black pixels // Hmm, nothing we saw was observed and confirmed twice. If we had // any guess at all, return it.