/// Try the measure the timing pattern for a given QR code. This does
/// not require the global perspective to have been set up, but it
/// does require that the capstone corners have been set to their
/// canonical rotation.
///
/// For each capstone, we find a point in the middle of the ring band
/// which is nearest the centre of the code. Using these points, we do
/// a horizontal and a vertical timing scan.
Try the measure the timing pattern for a given QR code. This does
not require the global perspective to have been set up, but it
does require that the capstone corners have been set to their
canonical rotation.

For each capstone, we find a point in the middle of the ring band
which is nearest the centre of the code. Using these points, we do
a horizontal and a vertical timing scan.
Try the measure the timing pattern for a given QR code . This does not require the global perspective to have been set up but it does require that the capstone corners have been set to their canonical rotation . For each capstone we find a point in the middle of the ring band which is nearest the centre of the code . Using these points we do a horizontal and a vertical timing scan .
fn measure_timing_pattern(image: &Image, capstones: &[Capstone], qr: &mut Grid) -> i32 {
    let mut tpep = [Default::default(); 3];
    for i in 0..3 {
        const US: [f64; 3] = [6.5, 6.5, 0.5];
        const VS: [f64; 3] = [0.5, 6.5, 6.5];
        let cap = capstones[qr.caps[i] as usize];
        tpep[i] = perspective_map(&cap.c, US[i], VS[i]);
    }
    let hscan = timing_scan(image, tpep[1], tpep[2]);
    let vscan = timing_scan(image, tpep[1], tpep[0]);
    qr.hscan = hscan;
    qr.vscan = vscan;
    qr.tpep = tpep;
    let scan = max(qr.hscan, qr.vscan);
    // If neither scan worked, we can't go any further.
    if scan < 0 {
        return -1;
    }
    // Choose the nearest allowable grid size
    let size = scan * 2 + 13;
    let ver = (size - 15) / 4;
    qr.grid_size = ver * 4 + 17;
    0
}
fn measure_timing_pattern ( image : & Image , capstones : & [ Capstone ] , qr : & mut Grid ) -> i32 { let mut tpep = [ Default :: default ( ) ; 3 ] ; for i in 0 .. 3 { const US : [ f64 ; 3 ] = [ 6.5 , 6.5 , 0.5 ] ; const VS : [ f64 ; 3 ] = [ 0.5 , 6.5 , 6.5 ] ; let cap = capstones [ qr . caps [ i ] as usize ] ; tpep [ i ] = perspective_map ( & cap . c , US [ i ] , VS [ i ] ) ; } let hscan = timing_scan ( image , tpep [ 1 ] , tpep [ 2 ] ) ; let vscan = timing_scan ( image , tpep [ 1 ] , tpep [ 0 ] ) ; qr . hscan = hscan ; qr . vscan = vscan ; qr . tpep = tpep ; let scan = max ( qr . hscan , qr . vscan ) ; // If neither scan worked, we can't go any further. if scan < 0 { return - 1 ; } // Choose the nearest allowable grid size let size = scan * 2 + 13 ; let ver = ( size - 15 ) / 4 ; qr . grid_size = ver * 4 + 17 ; 0 }
Try the measure the timing pattern for a given QR code.
Try the measure the timing pattern for a given QR code .
image
&Image
capstones
&[Capstone]
qr
&mut Grid