fn fitness_all(image: &Image, qr: &mut Grid) -> i32 {
    let version: i32 = (qr.grid_size - 17) / 4;
    let mut score: i32 = 0;

    // Check the timing pattern
    for i in 0..qr.grid_size - 14 {
        let expect: i32 = if i & 1 != 0 { 1 } else { -1 };
        score += fitness_cell(image, qr, i + 7, 6) * expect;
        score += fitness_cell(image, qr, 6, i + 7) * expect;
    }

    // Check capstones
    score += fitness_capstone(image, qr, 0, 0);
    score += fitness_capstone(image, qr, qr.grid_size - 7, 0);
    score += fitness_capstone(image, qr, 0, qr.grid_size - 7);

    if version < 0 || version > QUIRC_MAX_VERSION as i32 {
        score
    } else {
        let info: &VersionInfo = &VERSION_DB[version as usize];

        // Check alignment patterns
        let mut ap_count: usize = 0;
        while ap_count < QUIRC_MAX_ALIGNMENT && (info.apat[ap_count] != 0) {
            ap_count += 1;
        }

        for i in 1..ap_count as i32 - 1 {
            score += fitness_apat(image, qr, 6, info.apat[i as usize]);
            score += fitness_apat(image, qr, info.apat[i as usize], 6);
        }

        for i in 1..ap_count {
            for j in 1..ap_count {
                score += fitness_apat(image, qr, info.apat[i], info.apat[j]);
            }
        }
        score
    }
}
/// Compute a fitness score for the currently configured perspective
/// transform, using the features we expect to find by scanning the
/// grid.
Compute a fitness score for the currently configured perspective
transform, using the features we expect to find by scanning the
grid.
Compute a fitness score for the currently configured perspective transform using the features we expect to find by scanning the grid .
fn fitness_all(image: &Image, qr: &mut Grid) -> i32 {
    let version: i32 = (qr.grid_size - 17) / 4;
    let mut score: i32 = 0;
    // Check the timing pattern
    for i in 0..qr.grid_size - 14 {
        let expect: i32 = if i & 1 != 0 { 1 } else { -1 };
        score += fitness_cell(image, qr, i + 7, 6) * expect;
        score += fitness_cell(image, qr, 6, i + 7) * expect;
    }
    // Check capstones
    score += fitness_capstone(image, qr, 0, 0);
    score += fitness_capstone(image, qr, qr.grid_size - 7, 0);
    score += fitness_capstone(image, qr, 0, qr.grid_size - 7);
    if version < 0 || version > QUIRC_MAX_VERSION as i32 {
        score
    } else {
        let info: &VersionInfo = &VERSION_DB[version as usize];
        // Check alignment patterns
        let mut ap_count: usize = 0;
        while ap_count < QUIRC_MAX_ALIGNMENT && (info.apat[ap_count] != 0) {
            ap_count += 1;
        }
        for i in 1..ap_count as i32 - 1 {
            score += fitness_apat(image, qr, 6, info.apat[i as usize]);
            score += fitness_apat(image, qr, info.apat[i as usize], 6);
        }
        for i in 1..ap_count {
            for j in 1..ap_count {
                score += fitness_apat(image, qr, info.apat[i], info.apat[j]);
            }
        }
        score
    }
}
fn fitness_all ( image : & Image , qr : & mut Grid ) -> i32 { let version : i32 = ( qr . grid_size - 17 ) / 4 ; let mut score : i32 = 0 ; // Check the timing pattern for i in 0 .. qr . grid_size - 14 { let expect : i32 = if i & 1 != 0 { 1 } else { - 1 } ; score += fitness_cell ( image , qr , i + 7 , 6 ) * expect ; score += fitness_cell ( image , qr , 6 , i + 7 ) * expect ; } // Check capstones score += fitness_capstone ( image , qr , 0 , 0 ) ; score += fitness_capstone ( image , qr , qr . grid_size - 7 , 0 ) ; score += fitness_capstone ( image , qr , 0 , qr . grid_size - 7 ) ; if version < 0 || version > QUIRC_MAX_VERSION as i32 { score } else { let info : & VersionInfo = & VERSION_DB [ version as usize ] ; // Check alignment patterns let mut ap_count : usize = 0 ; while ap_count < QUIRC_MAX_ALIGNMENT && ( info . apat [ ap_count ] != 0 ) { ap_count += 1 ; } for i in 1 .. ap_count as i32 - 1 { score += fitness_apat ( image , qr , 6 , info . apat [ i as usize ] ) ; score += fitness_apat ( image , qr , info . apat [ i as usize ] , 6 ) ; } for i in 1 .. ap_count { for j in 1 .. ap_count { score += fitness_apat ( image , qr , info . apat [ i ] , info . apat [ j ] ) ; } } score } }
Compute a fitness score for the currently configured perspective
transform, using the features we expect to find by scanning the
grid.
Compute a fitness score for the currently configured perspective transform using the features we expect to find by scanning the grid .
image
&Image
qr
&mut Grid
image
&Image
qr
&mut Grid