Spaces:
Runtime error
Runtime error
def plot_bounding_boxes():
#6
by
shamikbose89
- opened
Question:
def plot_bounding_boxes():
Answer:
def plot_bounding_boxes(): """Plot bounding boxes on images.""" # Load the image and draw a box around it. img = cv2.imread('images/cat1.jpg') for i in range(len(img)): if len(img[i]) == 3: img[i] = cv2.cvtColor(img[i], cv2.COLOR_BGR2GRAY) fig, ax = plt.subplots() ax.imshow(img, cmap='gray', interpolation='nearest') # Draw a rectangle to represent face detections. rects = np.zeros((50, 4), dtype=np.int32) rects[:, :2] = [78, 69] + [-40, -30] rects[:, 2:] = [103, 126] + [40, 30] for (x, y, w, h) in rects: # Scale up by 4 so that they can be plotted over the whole image. x *= 4; y *= 4; w *= 4; h *= 4 # Draw a box with some padding between it and the