nehulagrawal commited on
Commit
734ec8a
·
1 Parent(s): 430b3cb

Update detection.py

Browse files
Files changed (1) hide show
  1. detection.py +9 -7
detection.py CHANGED
@@ -44,19 +44,21 @@ class ObjectDetection:
44
  rgb = ImageColor.getcolor(code, "RGB")
45
  return rgb
46
 
47
- def plot_bboxes(self, results, frame, threshold=0.5, box_color='red', text_color='white'):
48
  labels, conf, coord = results
49
-
50
- frame = frame.copy()
 
 
51
  box_color = self.get_color(box_color)
52
  text_color = self.get_color(text_color)
53
-
54
  for i in range(len(labels)):
55
  if conf[i] >= threshold:
56
  x1, y1, x2, y2 = self.get_coords(frame, coord[i])
57
  class_name = self.class_to_label(labels[i])
58
-
59
  cv2.rectangle(frame, (x1, y1), (x2, y2), box_color, 2)
60
  cv2.putText(frame, f"{class_name} - {conf[i]*100:.2f}%", (x1, y1), cv2.FONT_HERSHEY_COMPLEX, 0.5, text_color)
61
-
62
- return frame
 
44
  rgb = ImageColor.getcolor(code, "RGB")
45
  return rgb
46
 
47
+ def plot_bboxes(self, results, frame, threshold=0.5, box_color='orange', text_color='black'):
48
  labels, conf, coord = results
49
+
50
+ # Resize the frame to 400x400
51
+ frame = cv2.resize(frame, (400, 400))
52
+
53
  box_color = self.get_color(box_color)
54
  text_color = self.get_color(text_color)
55
+
56
  for i in range(len(labels)):
57
  if conf[i] >= threshold:
58
  x1, y1, x2, y2 = self.get_coords(frame, coord[i])
59
  class_name = self.class_to_label(labels[i])
60
+
61
  cv2.rectangle(frame, (x1, y1), (x2, y2), box_color, 2)
62
  cv2.putText(frame, f"{class_name} - {conf[i]*100:.2f}%", (x1, y1), cv2.FONT_HERSHEY_COMPLEX, 0.5, text_color)
63
+
64
+ return frame