Skip to content

Commit f09b6ff

Browse files
authored
fix: ocrlang argument not working (#1742)
1 parent 8c23447 commit f09b6ff

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/rust/lib_ccxr/src/common/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ pub struct Options {
452452
/// The name of the language stream for DVB
453453
pub dvblang: Option<Language>,
454454
/// The name of the .traineddata file to be loaded with tesseract
455-
pub ocrlang: PathBuf,
455+
pub ocrlang: Option<Language>,
456456
/// The Tesseract OEM mode, could be 0 (default), 1 or 2
457457
pub ocr_oem: i8,
458458
/// The Tesseract PSM mode, could be between 0 and 13. 3 is tesseract default

src/rust/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ pub unsafe fn copy_from_rust(ccx_s_options: *mut ccx_s_options, options: Options
150150
if let Some(dvblang) = options.dvblang {
151151
(*ccx_s_options).dvblang = string_to_c_char(dvblang.to_ctype().as_str());
152152
}
153-
if options.ocrlang.try_exists().unwrap_or_default() {
154-
(*ccx_s_options).ocrlang = string_to_c_char(options.ocrlang.to_str().unwrap());
153+
if let Some(ocrlang) = options.ocrlang {
154+
(*ccx_s_options).ocrlang = string_to_c_char(ocrlang.to_ctype().as_str());
155155
}
156156
(*ccx_s_options).ocr_oem = options.ocr_oem as _;
157157
(*ccx_s_options).ocr_quantmode = options.ocr_quantmode as _;

src/rust/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ impl OptionsExt for Options {
767767
}
768768

769769
if let Some(ref ocrlang) = args.ocrlang {
770-
self.ocrlang = PathBuf::from_str(ocrlang.as_str()).unwrap_or_default();
770+
self.ocrlang = Some(Language::from_str(ocrlang.as_str()).unwrap());
771771
}
772772

773773
if let Some(ref quant) = args.quant {

0 commit comments

Comments
 (0)