Search This Blog

Friday, 19 November 2021

Object tracking with OpenCV Python

 Contents:

1) Introduction to the Project
2) Uses of Object Tracking
3) Tools and Softwares used
4) Python Program.

Introduction to the Project:

Object tracking is an application of deep learning where the program takes an initial set of object detections and develops a unique identification for each of the initial detections and then tracks the detected objects as they move around frames in a video.

In other words, object tracking is the task of automatically identifying objects in a video and interpreting them as a set of trajectories with high accuracy

Uses of Object Tracking:

Object tracking is used for a variety of use cases involving different types of input footage. Whether or not the anticipated input will be an image or a video, or a real-time video vs. a prerecorded video, impacts the algorithms used for creating object tracking applications.

The kind of input also impacts the category, use cases, and applications of object tracking. Here, we will briefly describe a few popular uses and types of object tracking, such as video tracking, visual tracking, and image tracking

Tools and Softwares needer:

1) Python 3.x

2) OpenCV-Python

Hardware requirements: Camera


MAIN PROGRAM:


import cv2
cam = cv2.VideoCapture(0)
track = cv2.TrackerCSRT_create()
suc,img=cam.read()
img = cv2.flip(img,1)
bbox = cv2.selectROI("Tracking",img,False)
track.init(img,bbox)

def drawbox(img):
x,y,w,h=int(bbox[0]),int(bbox[1]),int(bbox[2]),int(bbox[3])
cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2)

while 1:
suc,img = cam.read()
img = cv2.flip(img,1)
suc,bbox=track.update(img)
if suc:
drawbox(img)
else:
pass
cv2.imshow("Tracking",img)
if cv2.waitkey(1) & 0xff == ord('q'):
break


Tutorial:




No comments:

Post a Comment

how to implement YOLOv3 using Python and TensorFlow

Object Detection with YOLOv3 Introduction YOLOv3 (You Only Look Once version 3) is a real-time object detection algorithm that can detect ob...