Code Monkey home page Code Monkey logo

object-tracker's Introduction

object-tracker

Image

Real-Time Object Tracker written in Python using dlib and OpenCV | Video 1 Video 2


Quick Links

Dependencies

Starting the code

Tracking can either be done using a live video from a webcam or using a video file.

Tracking using Video File

To run the code using a video file use the following command line argument --

python object-tracker-single.py -v <path-2-video-file>

For example, you can use the demo video provided with this code as --

python object-tracker-single.py -v demo-video-single.avi

Tracking using Live Video

To run the code using live video use the following command line argument --

python object-tracker-single.py -d <device-id>

For example, on most systems device id 0 is the webcam attached.

python object-tracker-single.py -v docs/demo-single-video.avi

Use the -l or `--dispLoc' command line option to display the locations of the tracked object as show below -

python object-tracker-single.py -v docs/demo-single-video.avi -l

NOTE -- If you want to do multi object tracking code, use the file object-tracker-multi.py instead of object-tracker-single.py. This is a hack to do multi-object tracking and hence the code slows down.

How to perform tracking

Once the code starts, it will start the video file or the live stream. To select the objects to be tracked, pause the video by pressing the p key.The next step is to create a bounding box around the object(s) to be tracked. Press the mouse to select the top-left pixel location of the object to be tracked and then release the mouse on the bottom-right location of the object to be tracked. Once, this is done press p to start the tracking. Also, if you want to discard the object, press the d key. In SINGLE OBJECT TRACKING MODE, you can only select one object but in MULTI OBJECT TRACKING MODE, you can select as many objects you want but at the cost of speed. Press esc anytime to gracefully quit the code.

object-tracker's People

Contributors

adithyaselv avatar bikz05 avatar powderblock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

object-tracker's Issues

Cordinates become negative when using i3 window manager

santiago@santiago-Aspire-A515-51:~/Devel$ python '/home/santiago/Devel/videotracker/object-tracker-multiple.py' -v '/home/santiago/Documents/NewConsultoriaMarketing/accordion.mkv'
Press key p to pause the video to start tracking
Press and release mouse around the object to be tracked.
You can also select multiple objects.
Press key p to continue with the selected points.
Press key d to discard the last object selected.
Press key q to quit the program.
Object selected at [(664, 599), (691, 623)]
Traceback (most recent call last):)] , (-12942, -16384)]
File "/home/santiago/Devel/videotracker/object-tracker-multiple.py", line 89, in
run(source, args["dispLoc"])
File "/home/santiago/Devel/videotracker/object-tracker-multiple.py", line 60, in run
cv2.rectangle(img, pt1, pt2, (255, 255, 255), 3)
TypeError: an integer is required

Also, having trouble drawing the square + what I show in the video:
https://www.loom.com/share/3eaf26160d874ccfac61d6b79ea1864f

detector

I add a ssd detector to initialize the tracker in stead of a mouse event. the problem is the tracker will appear forever after the object disappear.... how can i fix that

thank you

Issue with the code

The code works great in some instances but most of the time it does not track the objects properly so is there any way to make this code more robust? I'm just trying to enhance this code for my application., so any response would be helpful

Object tracking fails with error

After I draw the bounding box on the object I want to track, when I press p again, I get the following error:

Object selected at [(857, 280), (912, 394)]
Object tracked at [{}, {}] 
Traceback (most recent call last):
  File "object-tracker-single.py", line 88, in <module>
    run(source, args["dispLoc"])
  File "object-tracker-single.py", line 60, in run
    print ("Object tracked at [{}, {}] \r").format(pt1, pt2),
AttributeError: 'NoneType' object has no attribute 'format'

Illegal Instruction

After selecting the object to be tracked using mouse and pressing the key 'p', I am getting the following error in my terminal.

Press key p to pause the video to start tracking
init done
opengl support available
Press and release mouse around the object to be tracked.
You can also select multiple objects.
Press key p to continue with the selected points.
Press key d to discard the last object selected.
Press key q to quit the program.
Object selected at [(224, 166), (412, 323)]
Illegal instruction (core dumped)

problem of selecting tracked window

key'p' will let the video just stop but not be available to select the coordinates of the tracked windows!Please tell me the solutions as soon as you can,thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.