theAIGuysCode / yolov3_deepsort

Object tracking implemented with YOLOv3, Deep Sort and Tensorflow.
GNU General Public License v3.0
337 stars 186 forks source link

How to crop the detetctions? #40

Open hasantha-nirmal opened 3 years ago

hasantha-nirmal commented 3 years ago

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

TibRib commented 3 years ago

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)

hasantha-nirmal commented 3 years ago

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)

Thank you very much, really appreciate it.🙏🙏