@@ -40,22 +40,25 @@ pub unsafe fn dispatch_classifier_functions(ctx: *mut lib_hardsubx_ctx, im: *mut
4040 // function that calls the classifier functions
4141 match ( * ctx) . ocr_mode {
4242 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 ) ;
5044 let text_out_result = ffi:: CString :: from_raw ( ret_char_arr) . into_string ( ) ;
5145 match text_out_result {
5246 Ok ( T ) => T ,
5347 Err ( _E) => "" . to_string ( ) ,
5448 }
5549 }
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+ }
5760 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 ) ;
5962 let text_out_result = ffi:: CString :: from_raw ( ret_char_arr) . into_string ( ) ;
6063 match text_out_result {
6164 Ok ( T ) => T ,
@@ -66,7 +69,6 @@ pub unsafe fn dispatch_classifier_functions(ctx: *mut lib_hardsubx_ctx, im: *mut
6669 _ => {
6770 eprintln ! ( "Invalid OCR Mode" ) ;
6871 exit ( EXIT_MALFORMED_PARAMETER ) ;
69- // "".to_string()
7072 }
7173 }
7274}
@@ -113,7 +115,7 @@ pub unsafe extern "C" fn _process_frame_white_basic(
113115 let mut gray_im: * mut Pix = pixConvertRGBToGray ( im, 0.0 , 0.0 , 0.0 ) ;
114116 let mut sobel_edge_im: * mut Pix =
115117 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 ) ;
117119 let mut edge_im: * mut Pix = pixThresholdToBinary ( dilate_gray_im, 50 ) ;
118120
119121 let mut feat_im: * mut Pix = pixCreate ( width, height, 32 ) ;
0 commit comments