@@ -40,22 +40,25 @@ pub unsafe fn dispatch_classifier_functions(ctx: *mut lib_hardsubx_ctx, im: *mut
40
40
// function that calls the classifier functions
41
41
match ( * ctx) . ocr_mode {
42
42
0 => {
43
- let ret_char_arr = get_ocr_text_wordwise_threshold ( ctx, im, ( * ctx) . conf_thresh ) ;
44
- ffi:: CStr :: from_ptr ( ret_char_arr)
45
- . to_string_lossy ( )
46
- . into_owned ( )
47
- }
48
- 1 => {
49
- let ret_char_arr = get_ocr_text_letterwise_threshold ( ctx, im, ( * ctx) . conf_thresh ) ;
43
+ let ret_char_arr = get_ocr_text_simple_threshold ( ctx, im, ( * ctx) . conf_thresh ) ;
50
44
let text_out_result = ffi:: CString :: from_raw ( ret_char_arr) . into_string ( ) ;
51
45
match text_out_result {
52
46
Ok ( T ) => T ,
53
47
Err ( _E) => "" . to_string ( ) ,
54
48
}
55
49
}
56
-
50
+ 1 => {
51
+ let ret_char_arr = get_ocr_text_wordwise_threshold ( ctx, im, ( * ctx) . conf_thresh ) ;
52
+ if ret_char_arr. is_null ( ) {
53
+ "" . to_string ( )
54
+ } else {
55
+ ffi:: CStr :: from_ptr ( ret_char_arr)
56
+ . to_string_lossy ( )
57
+ . into_owned ( )
58
+ }
59
+ }
57
60
2 => {
58
- let ret_char_arr = get_ocr_text_simple_threshold ( ctx, im, ( * ctx) . conf_thresh ) ;
61
+ let ret_char_arr = get_ocr_text_letterwise_threshold ( ctx, im, ( * ctx) . conf_thresh ) ;
59
62
let text_out_result = ffi:: CString :: from_raw ( ret_char_arr) . into_string ( ) ;
60
63
match text_out_result {
61
64
Ok ( T ) => T ,
@@ -66,7 +69,6 @@ pub unsafe fn dispatch_classifier_functions(ctx: *mut lib_hardsubx_ctx, im: *mut
66
69
_ => {
67
70
eprintln ! ( "Invalid OCR Mode" ) ;
68
71
exit ( EXIT_MALFORMED_PARAMETER ) ;
69
- // "".to_string()
70
72
}
71
73
}
72
74
}
@@ -113,7 +115,7 @@ pub unsafe extern "C" fn _process_frame_white_basic(
113
115
let mut gray_im: * mut Pix = pixConvertRGBToGray ( im, 0.0 , 0.0 , 0.0 ) ;
114
116
let mut sobel_edge_im: * mut Pix =
115
117
pixSobelEdgeFilter ( gray_im, L_VERTICAL_EDGES . try_into ( ) . unwrap ( ) ) ;
116
- let mut dilate_gray_im: * mut Pix = pixDilateGray ( sobel_edge_im, 21 , 1 ) ;
118
+ let mut dilate_gray_im: * mut Pix = pixDilateGray ( sobel_edge_im, 21 , 11 ) ;
117
119
let mut edge_im: * mut Pix = pixThresholdToBinary ( dilate_gray_im, 50 ) ;
118
120
119
121
let mut feat_im: * mut Pix = pixCreate ( width, height, 32 ) ;
0 commit comments