Skip to content
Snippets Groups Projects
Commit 102c629b authored by Mathieu Beligon's avatar Mathieu Beligon
Browse files

[all] (black) blackify the files uploaded from the nano

parent fa117554
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,7 @@ class TRTModel:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, self.input_size)
img = img.transpose((2, 0, 1)).astype(np.float32)
img = (2.0/255.0) * img - 1.0
img = (2.0 / 255.0) * img - 1.0
return img
# Initialization
......
......@@ -39,13 +39,21 @@ def bend_boxed_text_on_image(img: Image, text: str, topleft: Tuple[int, int], co
# the patch is used to draw boxed text
patch = np.zeros((h, w, 3), dtype=np.uint8)
patch[...] = color
cv2.putText(patch, text, (margin+1, h-margin-2), FONT, TEXT_SCALE,
WHITE, thickness=TEXT_THICKNESS, lineType=cv2.LINE_8)
cv2.rectangle(patch, (0, 0), (w-1, h-1), BLACK, thickness=1)
cv2.putText(
patch,
text,
(margin + 1, h - margin - 2),
FONT,
TEXT_SCALE,
WHITE,
thickness=TEXT_THICKNESS,
lineType=cv2.LINE_8,
)
cv2.rectangle(patch, (0, 0), (w - 1, h - 1), BLACK, thickness=1)
w = min(w, img_w - topleft[0]) # clip overlay at image boundary
h = min(h, img_h - topleft[1])
# Overlay the boxed text onto region of interest (roi) in img
roi = img[topleft[1]:topleft[1]+h, topleft[0]:topleft[0]+w, :]
roi = img[topleft[1] : topleft[1] + h, topleft[0] : topleft[0] + w, :]
cv2.addWeighted(patch[0:h, 0:w, :], ALPHA, roi, 1 - ALPHA, 0, roi)
return img
......
......@@ -77,8 +77,8 @@ if __name__ == "__main__":
for f in filters:
objects = f.filter(objects, image)
fps = .9 * fps + .1 / (time() - previous_time)
bend_boxed_text_on_image(image, f'FPS: {fps:.1f}', (10, 10), (0, 0, 0))
fps = 0.9 * fps + 0.1 / (time() - previous_time)
bend_boxed_text_on_image(image, f"FPS: {fps:.1f}", (10, 10), (0, 0, 0))
for obj in objects:
bend_object_on_image(image, obj)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment