(img, detections, classes=None, thresh=0.6)
return img
visualize detection on image using cv2, this is the standard way to visualize detections
    :param img:
    :param detections: ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...])
            each row is one object
    :param classes:
    :param thresh:
    :return:
visualize detection on image using cv2, this is the standard way to visualize detections
    :param img:
    :param detections: ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...])
            each row is one object
    :param classes:
    :param thresh:
    :return:
visualize detection on image using cv2 this is the standard way to visualize detections : param img : : param detections : ssd detections numpy . array ( [[ id score x1 y1 x2 y2 ] ... ] ) each row is one object : param classes : : param thresh : : return :
def visualize_det_cv2(img, detections, classes=None, thresh=0.6):
    """
    visualize detection on image using cv2, this is the standard way to visualize detections
    :param img:
    :param detections: ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...])
            each row is one object
    :param classes:
    :param thresh:
    :return:
    """
    assert classes, 'from visualize_det_cv2, classes must be provided, each class in a list with' \
                    'certain order.'
    assert isinstance(img, np.array), 'from visualize_det_cv2, img must be a numpy array object.'

    height = img.shape[0]
    width = img.shape[1]

    for i in range(detections.shape[0]):
        cls_id = int(detections[i, 0])
        if cls_id >= 0:
            score = detections[i, 1]
            if score > thresh:
                unique_color = _create_unique_color_uchar(cls_id)

                x1 = int(detections[i, 2] * width)
                y1 = int(detections[i, 3] * height)
                x2 = int(detections[i, 4] * width)
                y2 = int(detections[i, 5] * height)

                cv2.rectangle(img, (x1, y2), (x2-x1, y2-y1), unique_color, 2)

                text_label = '{} {}'.format(classes[cls_id], score)
                (ret_val, base_line) = cv2.getTextSize(text_label, cv2.FONT_HERSHEY_COMPLEX, 1, 1)
                text_org = (x1, y2 - 0)

                cv2.rectangle(img, (text_org[0] - 5, text_org[1] + base_line - 5),
                              (text_org[0] + ret_val[0] + 5, text_org[1] - ret_val[1] + 5), unique_color, 2)
                # this rectangle for fill text rect
                cv2.rectangle(img, (text_org[0] - 5, text_org[1] + base_line - 5),
                              (text_org[0] + ret_val[0] + 5, text_org[1] - ret_val[1] + 5),
                              unique_color, -1)
                cv2.putText(img, text_label, text_org, cv2.FONT_HERSHEY_DUPLEX, 0.6, (255, 255, 255), 1)
    return img
def visualize_det_cv2 ( img , detections , classes = None , thresh = 0.6 ) : assert classes , 'from visualize_det_cv2, classes must be provided, each class in a list with' 'certain order.' assert isinstance ( img , np . array ) , 'from visualize_det_cv2, img must be a numpy array object.' height = img . shape [ 0 ] width = img . shape [ 1 ] for i in range ( detections . shape [ 0 ] ) : cls_id = int ( detections [ i , 0 ] ) if cls_id >= 0 : score = detections [ i , 1 ] if score > thresh : unique_color = _create_unique_color_uchar ( cls_id ) x1 = int ( detections [ i , 2 ] * width ) y1 = int ( detections [ i , 3 ] * height ) x2 = int ( detections [ i , 4 ] * width ) y2 = int ( detections [ i , 5 ] * height ) cv2 . rectangle ( img , ( x1 , y2 ) , ( x2 - x1 , y2 - y1 ) , unique_color , 2 ) text_label = '{} {}' . format ( classes [ cls_id ] , score ) ( ret_val , base_line ) = cv2 . getTextSize ( text_label , cv2 . FONT_HERSHEY_COMPLEX , 1 , 1 ) text_org = ( x1 , y2 - 0 ) cv2 . rectangle ( img , ( text_org [ 0 ] - 5 , text_org [ 1 ] + base_line - 5 ) , ( text_org [ 0 ] + ret_val [ 0 ] + 5 , text_org [ 1 ] - ret_val [ 1 ] + 5 ) , unique_color , 2 ) # this rectangle for fill text rect cv2 . rectangle ( img , ( text_org [ 0 ] - 5 , text_org [ 1 ] + base_line - 5 ) , ( text_org [ 0 ] + ret_val [ 0 ] + 5 , text_org [ 1 ] - ret_val [ 1 ] + 5 ) , unique_color , - 1 ) cv2 . putText ( img , text_label , text_org , cv2 . FONT_HERSHEY_DUPLEX , 0.6 , ( 255 , 255 , 255 ) , 1 ) return img