mod charset;
mod contrast;
mod crnn;
mod crop;
mod ctc;
mod preprocess;
mod recognizer;
pub(crate) use charset::Charset;
pub(crate) use crop::crop_region;
pub(crate) use recognizer::{CrnnRecognizer, RecognizedText, RegionCrop, TextRecognizer};
#[cfg(feature = "bench")]
pub(crate) fn bench_crop_preprocess(
gray: &image::GrayImage,
corners: &[[f32; 2]; 4],
) -> crate::error::Result<crate::inference::Tensor> {
let crop = crop::crop_region(gray, corners, true)?;
preprocess::prepare_batch(std::slice::from_ref(&crop))
}
#[cfg(feature = "bench")]
pub(crate) fn bench_crop_preprocess_reference(
gray: &image::GrayImage,
corners: &[[f32; 2]; 4],
) -> crate::error::Result<crate::inference::Tensor> {
let crop = crop::crop_region(gray, corners, true)?;
preprocess::prepare_batch_reference(std::slice::from_ref(&crop))
}
#[cfg(feature = "bench")]
pub(crate) fn bench_ctc_decode(logits: ndarray::ArrayView2<f32>) -> RecognizedText {
let charset = charset::Charset::for_language(crate::config::Language::English);
ctc::decode_greedy(logits, &charset, &[])
}
#[cfg(feature = "bench")]
pub(crate) fn bench_ctc_decode_reference(logits: ndarray::ArrayView2<f32>) -> RecognizedText {
let charset = charset::Charset::for_language(crate::config::Language::English);
ctc::decode_greedy_reference(logits, &charset, &[])
}