1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#![allow(unused_variables, dead_code)]
extern crate image;
extern crate ndarray;
extern crate structopt;

pub mod cli;
pub mod error;
pub mod hough_transform;

use cli::Config;
use error::HougseErr;
// use hough_transform::hough_transform;
use hough_transform::image::ImageLumaArray;

/// Function that runs the program in the appropriate order.
pub fn run() -> Result<(), HougseErr> {
    // This is the checked config... All the files exist and are of supported types
    let conf = Config::parse()?;

    // SAFETY: The absence or Err value is already checked by parse()
    let circles = match ImageLumaArray::new(conf.image_path.unwrap())? {
        ImageLumaArray::ImageLumaU8(u8_array) => {
            println!("Image: \n{}", u8_array);
            hough_transform::hough_transform::<u8>(&u8_array, conf.circle_limits.unwrap())?
        }
        ImageLumaArray::ImageLumaU16(u16_array) => {
            println!("Image: \n{}", u16_array);
            hough_transform::hough_transform::<u16>(&u16_array, conf.circle_limits.unwrap())?
        }
    };

    println!("Circles in the image: \n{:?}", circles.0);

    Ok(())
}