parameters: (self,bb0,bb,text)
return_statement: return is_good
docstring: Ensure that bounding-boxes are not too distorted
          after perspective distortion.
  
          bb0 : 2x4xn martrix of BB coordinates before perspective
          bb  : 2x4xn matrix of BB after perspective
          text: string of text -- for excluding symbols/punctuations.
docstring_summary: Ensure that bounding-boxes are not too distorted
          after perspective distortion.
docstring_tokens: Ensure that bounding - boxes are not too distorted after perspective distortion .
function: def bb_filter(self,bb0,bb,text):
          """
          Ensure that bounding-boxes are not too distorted
          after perspective distortion.
  
          bb0 : 2x4xn martrix of BB coordinates before perspective
          bb  : 2x4xn matrix of BB after perspective
          text: string of text -- for excluding symbols/punctuations.
          """
          h0 = np.linalg.norm(bb0[:,3,:] - bb0[:,0,:], axis=0)
          w0 = np.linalg.norm(bb0[:,1,:] - bb0[:,0,:], axis=0)
          hw0 = np.c_[h0,w0]
  
          h = np.linalg.norm(bb[:,3,:] - bb[:,0,:], axis=0)
          w = np.linalg.norm(bb[:,1,:] - bb[:,0,:], axis=0)
          hw = np.c_[h,w]
  
          # remove newlines and spaces:
          text = ''.join(text.split())
          assert len(text)==bb.shape[-1]
  
          alnum = np.array([ch.isalnum() for ch in text])
          hw0 = hw0[alnum,:]
          hw = hw[alnum,:]
  
          min_h0, min_h = np.min(hw0[:,0]), np.min(hw[:,0])
          asp0, asp = hw0[:,0]/hw0[:,1], hw[:,0]/hw[:,1]
          asp0, asp = np.median(asp0), np.median(asp)
  
          asp_ratio = asp/asp0
          is_good = ( min_h > self.min_char_height
                      and asp_ratio > self.min_asp_ratio
                      and asp_ratio < 1.0/self.min_asp_ratio)
          return is_good
function_tokens: def bb_filter ( self , bb0 , bb , text ) : h0 = np . linalg . norm ( bb0 [ : , 3 , : ] - bb0 [ : , 0 , : ] , axis = 0 ) w0 = np . linalg . norm ( bb0 [ : , 1 , : ] - bb0 [ : , 0 , : ] , axis = 0 ) hw0 = np . c_ [ h0 , w0 ] h = np . linalg . norm ( bb [ : , 3 , : ] - bb [ : , 0 , : ] , axis = 0 ) w = np . linalg . norm ( bb [ : , 1 , : ] - bb [ : , 0 , : ] , axis = 0 ) hw = np . c_ [ h , w ] # remove newlines and spaces: text = '' . join ( text . split ( ) ) assert len ( text ) == bb . shape [ - 1 ] alnum = np . array ( [ ch . isalnum ( ) for ch in text ] ) hw0 = hw0 [ alnum , : ] hw = hw [ alnum , : ] min_h0 , min_h = np . min ( hw0 [ : , 0 ] ) , np . min ( hw [ : , 0 ] ) asp0 , asp = hw0 [ : , 0 ] / hw0 [ : , 1 ] , hw [ : , 0 ] / hw [ : , 1 ] asp0 , asp = np . median ( asp0 ) , np . median ( asp ) asp_ratio = asp / asp0 is_good = ( min_h > self . min_char_height and asp_ratio > self . min_asp_ratio and asp_ratio < 1.0 / self . min_asp_ratio ) return is_good