@@ -135,22 +135,26 @@ def __parse_text_file(self, path: str):
135135
136136        with  open (path , mode = "rb" ) as  f :
137137            data  =  tomllib .load (f )
138+         try :
139+             self .texts  =  [text .lower ().strip () for  text  in  data ["texts" ]]
140+             self .__rect  =  (data ["left" ], data ["right" ], data ["top" ], data ["bottom" ])
141+         except  KeyError  as  exception :
142+             error_messages .ocr_missing_key (path , exception .args [0 ])
143+             return 
138144
139-         self .texts  =  [text .lower ().strip () for  text  in  data ["texts" ]]
140-         self .__rect  =  (data ["left" ], data ["right" ], data ["top" ], data ["bottom" ])
141145        self .__ocr_comparison_methods  =  data .get ("methods" , [0 ])
142146        self .__fps_limit  =  data .get ("fps_limit" , 0 )
143147
144-         if  self .__validate_ocr ():
148+         if  not   self .__validate_ocr ():
145149            error_messages .wrong_ocr_values (path )
146150            return 
147151
148152    def  __validate_ocr (self ):
149153        values  =  [* self .__rect , * self .__ocr_comparison_methods , self .__fps_limit ]
150154        return  (
151155            all (value  >=  0  for  value  in  values )  # Check for invalid negative values 
152-             and  self .__rect [1 ]  >  self .__rect [0 ]
153-             and  self .__rect [3 ]  >  self .__rect [2 ]
156+             and  self .__rect [0 ]  <  self .__rect [1 ]
157+             and  self .__rect [2 ]  <  self .__rect [3 ]
154158        )
155159
156160    def  __read_image_bytes (self , path : str ):
0 commit comments