infer_deepsort
About
Multiple Object Tracking algorithm (MOT) combining a deep association metricwith the well known SORT algorithm for better performance.
Run DeepSort tracking algorithm for video analysis. In most cases, tracking algorithms should be connected to object detection algorithm.
Simple Online and Realtime Tracking (SORT) is a pragmatic approach to multiple object tracking with a focus on simple, effective algorithms. This algorithm improves performance of SORT by introducing deep association metric to reduce object identity switches.
🚀 Use with Ikomia API
1. Install Ikomia API
We strongly recommend using a virtual environment. If you're not sure where to start, we offer a tutorial here.
pip install ikomia
2. Create your workflow
from ikomia.dataprocess.workflow import Workflowfrom ikomia.utils.displayIO import displayimport cv2# Init your workflowwf = Workflow()# Add object detection algorithmdetector = wf.add_task(name="infer_yolo_v7", auto_connect=True)# Add DeepSORT tracking algorithmtracking = wf.add_task(name="infer_deepsort", auto_connect=True)stream = cv2.VideoCapture(0)while True:# Read image from streamret, frame = stream.read()# Test if streaming is OKif not ret:continue# Run the workflow on current framewf.run_on(array=frame)# Get resultsimage_out = tracking.get_output(0)obj_detect_out = tracking.get_output(1)# Displayimg_res = cv2.cvtColor(image_out.get_image_with_graphics(obj_detect_out), cv2.COLOR_BGR2RGB)display(img_res, title="DeepSORT", viewer="opencv")# Press 'q' to quit the streaming processif cv2.waitKey(1) & 0xFF == ord('q'):break# After the loop release the stream objectstream.release()# Destroy all windowscv2.destroyAllWindows()
☀️ Use with Ikomia Studio
Ikomia Studio offers a friendly UI with the same features as the API.
-
If you haven't started using Ikomia Studio yet, download and install it from this page.
-
For additional guidance on getting started with Ikomia Studio, check out this blog post.
📝 Set algorithm parameters
# Add DeepSORT tracking algorithmtracking = wf.add_task(name="infer_deepsort", auto_connect=True)tracking.set_parameters({"categories": "all","conf_thres": "0.5",})
- categories (str, default="all"): categories of objects you want to track. Use a comma separated string to set multiple categories (ex: "dog,person,car").
- conf_thresh (float, default=0.5): object detection confidence.
Note: parameter key and value should be in string format when added to the dictionary.
🔍 Explore algorithm outputs
Every algorithm produces specific outputs, yet they can be explored them the same way using the Ikomia API. For a more in-depth understanding of managing algorithm outputs, please refer to the documentation.
# Add DeepSORT tracking algorithmtracking = wf.add_task(name="infer_deepsort", auto_connect=True)stream = cv2.VideoCapture(0)while True:# Read image from streamret, frame = stream.read()# Test if streaming is OKif not ret:continue# Run the workflow on current framewf.run_on(array=frame)# Iterate over outputsfor output in tracking.get_outputs():# Print informationprint(output)# Export it to JSONoutput.to_json()
DeepSORT algorithm generates 2 outputs:
- Forwaded original image (CImageIO)
- Object detection output (CObjectDetectionIO)
Developer
Ikomia
License
GNU General Public License v3.0
Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.
Permissions | Conditions | Limitations |
---|---|---|
Commercial use | License and copyright notice | Liability |
Modification | State changes | Warranty |
Distribution | Disclose source | |
Patent use | Same license | |
Private use |
This is not legal advice: this description is for informational purposes only and does not constitute the license itself. Provided by choosealicense.com.