pub fn oriented_fast(
    image: &GrayImage,
    threshold: Option<u8>,
    target_num_corners: usize,
    edge_radius: u32,
    seed: Option<u64>,
) -> Vec<OrientedFastCorner> {
    let (width, height) = image.dimensions();
    let (min_x, max_x) = (edge_radius, width - edge_radius);
    let (min_y, max_y) = (edge_radius, height - edge_radius);
    let mut corners = vec![];

    let local_threshold = if let Some(t) = threshold {
        t
    } else {
        // Take a sample of random pixels, compute their FAST scores, and set the
        // threshold for the full image accordingly.
        const NUM_SAMPLE_POINTS: usize = 1000;
        let mut rng = if let Some(s) = seed {
            StdRng::seed_from_u64(s)
        } else {
            StdRng::from_entropy()
        };
        let dist_x = rand::distributions::Uniform::new(min_x, max_x);
        let dist_y = rand::distributions::Uniform::new(min_y, max_y);
        let sample_size = NUM_SAMPLE_POINTS.min((width * height) as usize);
        let sample_coords: Vec<Point<u32>> = (0..sample_size)
            .map(|_| Point::new(dist_x.sample(&mut rng), dist_y.sample(&mut rng)))
            .collect();
        let mut fast_scores: Vec<u8> = sample_coords
            .iter()
            .map(|c| fast_corner_score(image, 0, c.x, c.y, Fast::Nine))
            .collect();
        fast_scores.sort();
        let target_corner_fraction = (target_num_corners as f32) / ((width * height) as f32);
        let fraction_idx = (NUM_SAMPLE_POINTS as f32 * (1. - target_corner_fraction)) as usize;

        fast_scores[fraction_idx]
    };

    // Iterate over every pixel in the image and find potential corners.
    for y in edge_radius..height - edge_radius {
        for x in edge_radius..width - edge_radius {
            if is_corner_fast9(image, local_threshold, x, y) {
                let score = fast_corner_score(image, local_threshold, x, y, Fast::Nine);
                corners.push(Corner::new(x, y, score as f32));
            }
        }
    }

    // Sort descending by Harris corner measure.
    corners.sort_by(|a, b| b.score.partial_cmp(&a.score).unwrap());

    // Keep the top corners and discard the rest.
    let top_corners = if corners.len() < target_num_corners {
        &corners
    } else {
        &corners[..target_num_corners]
    };

    // Compute intensity centroids and return oriented FAST corners.
    top_corners
        .iter()
        .map(|c| OrientedFastCorner {
            corner: *c,
            orientation: intensity_centroid(image, c.x, c.y, 15),
        })
        .collect()
}
Finds oriented FAST-9 corners as presented in [Rublee et. al. (2012)][rublee].

[rublee]: http://www.gwylab.com/download/ORB_2012.pdf
src/corners.rs