Open abc1110 opened 4 years ago
Yes it can be done.
The video file is being written in realtime.
Thanks, I saw the video output getting saved.
I am trying to figure out how to get the bounding boxes coloured as well, and I made the following modification to the code, but I'm afraid the output is not right. The colours for the bounding boxes are not changing as they should wrt distance. Could you suggest where am I going wrong?
def plot_pedestrian_boxes_on_image(frame, pedestrian_boxes, close_p, danger_p):
frame_h = frame.shape[0]
frame_w = frame.shape[1]
thickness = 2
color_red = (0, 0, 255)
color_yellow = (0, 170, 170)
color_green = (0, 255, 0)
for i in range(len(pedestrian_boxes)):
pt1 = (
int(pedestrian_boxes[i][1] * frame_w),
int(pedestrian_boxes[i][0] * frame_h),
)
pt2 = (
int(pedestrian_boxes[i][3] * frame_w),
int(pedestrian_boxes[i][2] * frame_h),
)
print(pt1, pt2)
print(pedestrian_boxes[i][1], int(pedestrian_boxes[i][0]))
if i in list(set(chain(*close_p))):
image = cv2.rectangle(frame, pt1, pt2, color_yellow, thickness)
cv2.putText(image, str(i), (int(pt1[0]), int(pt1[1]-10)),
cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 170, 170), 2)
elif i in list(set(chain(*danger_p))):
image = cv2.rectangle(frame, pt1, pt2, color_red, thickness)
cv2.putText(image, str(i), (int(pt1[0]), int(pt1[1]-10)),
cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 0, 255), 2)
else:
image = cv2.rectangle(frame, pt1, pt2, color_green, thickness)
cv2.putText(image, str("this is samep"), (int(pt1[0]), int(pt1[1]-10)),
cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
return image
Hi @abc1110 hope you are doing well, tell me you please you found the solution about how to get the bounding boxes colored as well , please if send me your modification. thanks in advance.
@abc1110 any update .i have the same issue
Is it possible to to modify the code so that the bounding boxes too can get different colours as per the violation? It would also be nice if the final output of the analyzer can be saved locally, by writing a video file in real time.