Skip to content

Commit

Permalink
refacto(preprocess) useless Result in process_images_for_ocr return
Browse files Browse the repository at this point in the history
  • Loading branch information
gwen-lg committed Jul 18, 2024
1 parent 87e13c2 commit 5cf12e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn run(opt: &Opt) -> anyhow::Result<()> {
.unzip()
};

let images_for_ocr = preprocessor::process_images_for_ocr(idx, images, opt.border)?;
let images_for_ocr = preprocessor::process_images_for_ocr(idx, images, opt.border);

// Dump images if requested.
if opt.dump {
Expand Down
12 changes: 3 additions & 9 deletions src/preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ use rayon::prelude::*;
use subtile::{
image::{ToOcrImage, ToOcrImageOpt},
vobsub::{self, VobSubIndexedImage, VobSubOcrImage},
SubtileError,
};

/// Return a vector of processed images for OCR.
#[profiling::function]
pub fn process_images_for_ocr<I>(
idx: vobsub::Index,
images: I,
border: u32,
) -> Result<Vec<GrayImage>, SubtileError>
pub fn process_images_for_ocr<I>(idx: vobsub::Index, images: I, border: u32) -> Vec<GrayImage>
where
I: IntoParallelIterator<Item = VobSubIndexedImage>,
{
Expand All @@ -21,14 +16,13 @@ where
..Default::default()
};
let palette = rgb_palette_to_luminance(idx.palette());
let result = images
images
.into_par_iter()
.map(|vobsub_img| {
let converter = VobSubOcrImage::new(&vobsub_img, &palette);
converter.image(&opt)
})
.collect();
Ok(result)
.collect()
}

/// Convert an sRGB palette to a luminance palette.
Expand Down

0 comments on commit 5cf12e4

Please sign in to comment.