yolov4-deepsort icon indicating copy to clipboard operation
yolov4-deepsort copied to clipboard

bbox's information and crop object

Open farshokat opened this issue 2 years ago • 1 comments

Hi everyone, I cloned this source. It is very interesting and helpful to many people. I used this source for my project. But, I wanted to crop this object after detection based bbox's information. As I know, the bbox has consisted of x_max, x_min, y_max, y_min. But, I don't know using this information's bbox to crop objects and I using OpenCV. Can you help me with this problem? I don't have a formula. Many thanks to you, and I hoped to help me?

farshokat avatar Apr 01 '22 06:04 farshokat

To crop the detected objects, one thing you can do is add this line in object_tracker.py: cropped_frame = frame[int(bbox[1]):int(bbox[3]),int(bbox[0]):int(bbox[2])]

Somewhere after: for track in tracker.tracks: if not track.is_confirmed() or track.time_since_update > 1: continue bbox = track.to_tlbr() class_name = track.get_class()

And if you want to then save the cropped object as an image:

cv2.imwrite("cropped_"+str(track.track_id)+".png",cropped_frame)

22Raj avatar Apr 11 '22 05:04 22Raj