theAIGuysCode/yolov3_deepsort

How to crop the detetctions?

hasantha-nirmal opened this issue · 2 comments

How to save the detections of each frame? For an example all the frames generated by one tracker object?

Hello, I was passing by and I saw your comment. In order to crop a detected object (to then save it), what you can do is :

  1. get the bounding box :
    bbox = track.to_tlbr()
  2. Get the cropped picture :
    cropped_picture = img[ (int(bbox[1])):(int(bbox[3])), (int(bbox[0])):(int(bbox[2])) ]
  3. Save it:
    cv2.imwrite('result.jpg', cropped_picture)

Hello, I was passing by and I saw your comment. In order to crop a detected object (to then save it), what you can do is :

  1. get the bounding box :

bbox = track.to_tlbr()

  1. Get the cropped picture :

cropped_picture = img[ (int(bbox[1])):(int(bbox[3])), (int(bbox[0])):(int(bbox[2])) ]

  1. Save it:

cv2.imwrite('result.jpg', cropped_picture)

Thank you very much, really appreciate it.🙏🙏