parameters: (img: np.ndarray, xyxybox: np.ndarray, labels: np.ndarray, scores: np.ndarray, is_show=True)
return_statement: return img.astype('uint8')
docstring: draw img and show bbox , set ann = None will not show bbox
docstring_summary: draw img and show bbox , set ann = None will not show bbox
docstring_tokens: draw img and show bbox set ann = None will not show bbox
function: def draw_image(img: np.ndarray, xyxybox: np.ndarray, labels: np.ndarray, scores: np.ndarray, is_show=True) -> np.ndarray:
      """ draw img and show bbox , set ann = None will not show bbox
      """
      for i, a in enumerate(xyxybox):
          label = int(labels[i])
          r_top = tuple(np.maximum(np.minimum(a[0:2], img.shape[1::-1]), 0).astype(int))
          l_bottom = tuple(np.maximum(np.minimum(a[2:], img.shape[1::-1]), 0).astype(int))
          r_bottom = (r_top[0], l_bottom[1])
          org = (np.maximum(np.minimum(r_bottom[0], img.shape[1] - 12), 0),
                 np.maximum(np.minimum(r_bottom[1], img.shape[0] - 12), 0))
          cv2.rectangle(img, r_top, l_bottom, colormap[label])
          cv2.putText(img, f'{label} {scores[i]:.2f}',
                      org, cv2.FONT_HERSHEY_COMPLEX_SMALL,
                      0.5, colormap[label], thickness=1)
  
      if is_show:
          imshow((img).astype('uint8'))
          show()
  
      return img.astype('uint8')
function_tokens: def draw_image ( img : np . ndarray , xyxybox : np . ndarray , labels : np . ndarray , scores : np . ndarray , is_show = True ) -> np . ndarray : for i , a in enumerate ( xyxybox ) : label = int ( labels [ i ] ) r_top = tuple ( np . maximum ( np . minimum ( a [ 0 : 2 ] , img . shape [ 1 : : - 1 ] ) , 0 ) . astype ( int ) ) l_bottom = tuple ( np . maximum ( np . minimum ( a [ 2 : ] , img . shape [ 1 : : - 1 ] ) , 0 ) . astype ( int ) ) r_bottom = ( r_top [ 0 ] , l_bottom [ 1 ] ) org = ( np . maximum ( np . minimum ( r_bottom [ 0 ] , img . shape [ 1 ] - 12 ) , 0 ) , np . maximum ( np . minimum ( r_bottom [ 1 ] , img . shape [ 0 ] - 12 ) , 0 ) ) cv2 . rectangle ( img , r_top , l_bottom , colormap [ label ] ) cv2 . putText ( img , f'{label} {scores[i]:.2f}' , org , cv2 . FONT_HERSHEY_COMPLEX_SMALL , 0.5 , colormap [ label ] , thickness = 1 ) if is_show : imshow ( ( img ) . astype ( 'uint8' ) ) show ( ) return img . astype ( 'uint8' )