roboflow / zero-shot-object-tracking

Object tracking implemented with the Roboflow Inference API, DeepSort, and OpenAI CLIP.
https://blog.roboflow.com/zero-shot-object-tracking/
GNU General Public License v3.0
357 stars 62 forks source link

How to draw a tracing line? #8

Closed VYRION-Ai closed 2 years ago

VYRION-Ai commented 2 years ago

hi @Jacobsolawetz and @maxhs2014 i want to draw a tracing line for the object , how i can i do that?

Jacobsolawetz commented 2 years ago

Hello @totoadel we don’t currently have that visualization but it would be cool to add it. Do you have an example video of what you’re looking for? And how many frames back does the tracing line follow?

VYRION-Ai commented 2 years ago

yes like what happened here in this video. https://www.youtube.com/watch?v=Cu3ERM0Zk4s and all frames the object are still founded.

Jacobsolawetz commented 2 years ago

Ok cool - thanks for the example, we will put it on the list of todo

If you want to try a PR, it would be maintaining a dictionary for each object with history of box center locations, then plotting that line at visualization time

VYRION-Ai commented 2 years ago

than you very much @Jacobsolawetz

VYRION-Ai commented 2 years ago

Ok cool - thanks for the example, we will put it on the list of todo

If you want to try a PR, it would be maintaining a dictionary for each object with history of box center locations, then plotting that line at visualization time

i did it thank you very much. @Jacobsolawetz
this is the code

height, width, _ = im0.shape
                        x1, y1, x2, y2 = max(0, int(bboxes[0])), max(0, int(bboxes[1])), min(width,
                                                                                             int(bboxes[2])), min(
 height, int(bboxes[3]))
 center = (int((x1 + x2) / 2), int((y1 + y2) / 2))
 chk = checkKey_track(id_track, (id))
  if chk == 1:
            resl=all_values(id_track, id)
            for key in list (resl):
                        cv2.circle(im0, resl[key], radius=5, color=color, thickness=-1)
                         upd_dict = {(count_id): center}
                         id_track[(id)].update(upd_dict)
 else:
           upd_dict = {(count_id): center}
            id_track[(id)]=(upd_dict)
def checkKey_track(dict, key):
    if key in dict.keys():
        return 1
    else:
        return 0

def all_values(dict_obj,ids):
 for p_id, p_info in dict_obj.items():
    if ids == p_id:
        for key in p_info:
            p_info[key]
 return p_info
yeldarby commented 2 years ago

Nice! Can you post an example video?

Jacobsolawetz commented 2 years ago

@maxhs2014, let's take a look this week together

VYRION-Ai commented 2 years ago

let me upload video to you tube

VYRION-Ai commented 2 years ago

https://youtu.be/HlvybeSzbqs I'm very happy, because I'm a Java developer, not Python,

zxq309 commented 2 years ago

Ok cool - thanks for the example, we will put it on the list of todo If you want to try a PR, it would be maintaining a dictionary for each object with history of box center locations, then plotting that line at visualization time

i did it thank you very much. @Jacobsolawetz this is the code

height, width, _ = im0.shape
                        x1, y1, x2, y2 = max(0, int(bboxes[0])), max(0, int(bboxes[1])), min(width,
                                                                                             int(bboxes[2])), min(
 height, int(bboxes[3]))
 center = (int((x1 + x2) / 2), int((y1 + y2) / 2))
 chk = checkKey_track(id_track, (id))
  if chk == 1:
            resl=all_values(id_track, id)
            for key in list (resl):
                        cv2.circle(im0, resl[key], radius=5, color=color, thickness=-1)
                         upd_dict = {(count_id): center}
                         id_track[(id)].update(upd_dict)
 else:
           upd_dict = {(count_id): center}
            id_track[(id)]=(upd_dict)
def checkKey_track(dict, key):
    if key in dict.keys():
        return 1
    else:
        return 0

def all_values(dict_obj,ids):
 for p_id, p_info in dict_obj.items():
    if ids == p_id:
        for key in p_info:
            p_info[key]
 return p_info

Which file to add these codes?

VYRION-Ai commented 2 years ago

Ok cool - thanks for the example, we will put it on the list of todo If you want to try a PR, it would be maintaining a dictionary for each object with history of box center locations, then plotting that line at visualization time

i did it thank you very much. @Jacobsolawetz this is the code

height, width, _ = im0.shape
                        x1, y1, x2, y2 = max(0, int(bboxes[0])), max(0, int(bboxes[1])), min(width,
                                                                                             int(bboxes[2])), min(
 height, int(bboxes[3]))
 center = (int((x1 + x2) / 2), int((y1 + y2) / 2))
 chk = checkKey_track(id_track, (id))
  if chk == 1:
            resl=all_values(id_track, id)
            for key in list (resl):
                        cv2.circle(im0, resl[key], radius=5, color=color, thickness=-1)
                         upd_dict = {(count_id): center}
                         id_track[(id)].update(upd_dict)
 else:
           upd_dict = {(count_id): center}
            id_track[(id)]=(upd_dict)
def checkKey_track(dict, key):
    if key in dict.keys():
        return 1
    else:
        return 0

def all_values(dict_obj,ids):
 for p_id, p_info in dict_obj.items():
    if ids == p_id:
        for key in p_info:
            p_info[key]
 return p_info

Which file to add these codes?

Detect.py

zxq309 commented 2 years ago

I can't find detect.py, can you help me in detail? thank you

Ok cool - thanks for the example, we will put it on the list of todo If you want to try a PR, it would be maintaining a dictionary for each object with history of box center locations, then plotting that line at visualization time

i did it thank you very much. @Jacobsolawetz this is the code

height, width, _ = im0.shape
                        x1, y1, x2, y2 = max(0, int(bboxes[0])), max(0, int(bboxes[1])), min(width,
                                                                                             int(bboxes[2])), min(
 height, int(bboxes[3]))
 center = (int((x1 + x2) / 2), int((y1 + y2) / 2))
 chk = checkKey_track(id_track, (id))
  if chk == 1:
            resl=all_values(id_track, id)
            for key in list (resl):
                        cv2.circle(im0, resl[key], radius=5, color=color, thickness=-1)
                         upd_dict = {(count_id): center}
                         id_track[(id)].update(upd_dict)
 else:
           upd_dict = {(count_id): center}
            id_track[(id)]=(upd_dict)
def checkKey_track(dict, key):
    if key in dict.keys():
        return 1
    else:
        return 0

def all_values(dict_obj,ids):
 for p_id, p_info in dict_obj.items():
    if ids == p_id:
        for key in p_info:
            p_info[key]
 return p_info

Which file to add these codes?

Detect.py