alankbi / detecto

Build fully-functioning computer vision models with PyTorch
https://detecto.readthedocs.io/
MIT License
613 stars 107 forks source link

detect_video from detecto.visualize needs to use int in cv2.rectangle #106

Open ad2946 opened 2 years ago

ad2946 commented 2 years ago

I tried to use the detect_video function in my code and i found that the function is using

        cv2.rectangle(frame, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 3)

        cv2.putText(frame, '{}: {}'.format(label, round(score.item(), 2)), (box[0], box[1] - 10),
                    cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 3)

when it should be:

        cv2.rectangle(frame, (int(box[0]), int(box[1])), (int(box[2]), int(box[3])), (255, 0, 0), 3)

        cv2.putText(frame, '{}: {}'.format(label, round(score.item(), 2)), (int(box[0]), int(box[1]) - 10),
                    cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 3)

Otherwise it won't work.

tomh014 commented 1 year ago

This fixed an issue I was having, thanks!