@@ -44,18 +44,16 @@ impl NodeRunner for OcrRunner {
4444 ctx : & Context ,
4545 param : Self :: ParamType ,
4646 ) -> Result < Option < HashMap < String , serde_json:: Value > > , String > {
47- let handle = ctx. app_handle . clone ( ) . unwrap ( ) ;
47+ let mut resource_path_prefix = ctx. resource_path ( ) . to_string_lossy ( ) . replace ( r"\\?\" , "" ) . to_string ( ) ;
4848
49- let resource_path = if ctx. resource_path ( ) . to_string_lossy ( ) . to_string ( ) != "" {
50- format ! ( "{}/" , ctx. resource_path( ) . to_string_lossy( ) . to_string( ) )
51- } else {
52- String :: new ( )
53- } ;
49+ if resource_path_prefix != "" {
50+ resource_path_prefix = format ! ( "{}/" , resource_path_prefix) ;
51+ }
5452
5553 let ocr = OAROCRBuilder :: new (
56- format ! ( "{}{}" , resource_path , "ocr/pp-ocrv5_mobile_det.onnx" ) . as_str ( ) ,
57- format ! ( "{}{}" , resource_path , "ocr/pp-ocrv5_mobile_rec.onnx" ) . as_str ( ) ,
58- format ! ( "{}{}" , resource_path , "ocr/ppocrv5_dict.txt" ) . as_str ( ) ,
54+ format ! ( "{}{}" , resource_path_prefix , "ocr/pp-ocrv5_mobile_det.onnx" ) . as_str ( ) ,
55+ format ! ( "{}{}" , resource_path_prefix , "ocr/pp-ocrv5_mobile_rec.onnx" ) . as_str ( ) ,
56+ format ! ( "{}{}" , resource_path_prefix , "ocr/ppocrv5_dict.txt" ) . as_str ( ) ,
5957 )
6058 . build ( )
6159 . map_err ( |e| {
0 commit comments