utilityfun.py
def quick_rectangle(img, corners, color='green', opacity=0.9,
                    thickness=4, filled=False):
    """Draws a rectangle on the input image."""
    colors = {'green': (30, 255, 120),
              'blue': (20, 104, 229),
              'red': (224, 52, 0),
              'orange': (252, 163, 9),
              'yellow': (252, 228, 10)}

    if color.lower() not in colors:
        color = 'green'
        print('Warning unknown color, using green instead.  Please choose from:\
              green, blue, red, orange and yellow.')
    else:
        color = color.lower()

    thickness = int(thickness)
    outline = np.zeros(img.shape)
    corners = tuple(map(tuple, corners))
    outline = cv2.rectangle(outline, corners[0], corners[1], colors[color],
                            thickness=thickness)

    if filled:
        fill = np.zeros(img.shape)
        fill = cv2.rectangle(fill, corners[0], corners[1], colors[color],
                             thickness=-1)
        img = overlay_image(img, fill, opacity=opacity*0.3)

    return overlay_image(img, outline, opacity=opacity)
Draws a rectangle on the input image.
Draws a rectangle on the input image.
Draws a rectangle on the input image .
def quick_rectangle(img, corners, color='green', opacity=0.9,
                    thickness=4, filled=False):
    colors = {'green': (30, 255, 120),
              'blue': (20, 104, 229),
              'red': (224, 52, 0),
              'orange': (252, 163, 9),
              'yellow': (252, 228, 10)}
    if color.lower() not in colors:
        color = 'green'
        print('Warning unknown color, using green instead.  Please choose from:\
              green, blue, red, orange and yellow.')
    else:
        color = color.lower()
    thickness = int(thickness)
    outline = np.zeros(img.shape)
    corners = tuple(map(tuple, corners))
    outline = cv2.rectangle(outline, corners[0], corners[1], colors[color],
                            thickness=thickness)
    if filled:
        fill = np.zeros(img.shape)
        fill = cv2.rectangle(fill, corners[0], corners[1], colors[color],
                             thickness=-1)
        img = overlay_image(img, fill, opacity=opacity*0.3)
    return overlay_image(img, outline, opacity=opacity)
def quick_rectangle ( img , corners , color = 'green' , opacity = 0.9 , thickness = 4 , filled = False ) : colors = { 'green' : ( 30 , 255 , 120 ) , 'blue' : ( 20 , 104 , 229 ) , 'red' : ( 224 , 52 , 0 ) , 'orange' : ( 252 , 163 , 9 ) , 'yellow' : ( 252 , 228 , 10 ) } if color . lower ( ) not in colors : color = 'green' print ( 'Warning unknown color, using green instead.  Please choose from:\
              green, blue, red, orange and yellow.' ) else : color = color . lower ( ) thickness = int ( thickness ) outline = np . zeros ( img . shape ) corners = tuple ( map ( tuple , corners ) ) outline = cv2 . rectangle ( outline , corners [ 0 ] , corners [ 1 ] , colors [ color ] , thickness = thickness ) if filled : fill = np . zeros ( img . shape ) fill = cv2 . rectangle ( fill , corners [ 0 ] , corners [ 1 ] , colors [ color ] , thickness = - 1 ) img = overlay_image ( img , fill , opacity = opacity * 0.3 ) return overlay_image ( img , outline , opacity = opacity )
Draws a rectangle on the input image.
Draws a rectangle on the input image .
"""Draws a rectangle on the input image."""
img
corners
color
opacity
thickness
filled