Coder Social home page Coder Social logo

tracking_with_ocv's Introduction

Object tracking with python

This program tracks multiple objects in a video

Demo

Dependences

It only depends on OpenCV 4.5. You can use pip3 to install the dependencies:

pip3 install -r ./requirements.txt

Run the program

Run this to see the input options:

python3 main.py --help

usage: This program tracks multiple objects in a video [-h] [--video VIDEO] [--json JSON] [--method {CSRT,KCF,DaSiamRPN}] [--output OUTPUT] [--display]

options:
  -h, --help            show this help message and exit
  --video VIDEO         Input video
  --json JSON           JSON file containing initial bboxes
  --method {CSRT,KCF,DaSiamRPN}
                        Tracking method
  --output OUTPUT       Output video
  --display             Show results in the screen

The program expects a video (--video ) and a JSON file (--json) containing the starting position coordinates ( [x,y,w,h] rectangle) of each object you want to track (see this example).

Examples:

  • Run with default parameters. It will use the video and JSON file inside folder development_assets:
    python3 main.py
    
  • Show results on the screen:
    python3 main.py --display 
    
  • Use DaSiamRPN method (based on Deep Learning):
    python3 main.py --display --method=DaSiamRPN
    
  • Use custom data:
    python3 main.py --display --method=DaSiamRPN --video=sample1.mp4  --json=sample1.json --output=results.avi 
    

Using docker

Create docker image:

docker build -f Dockerfile -t obj_tracking:v01 .

Run this command to execute the program inside the container. Replace python3 main.py --help with your own command.

docker run -it --rm --net=host -e DISPLAY=$DISPLAY -w /app -v /tmp/.X11-unix/:/tmp/.X11-unix -v $HOME:/data obj_tracking:v01 python3 main.py --help

If you want to use the --display option make sure to run this command on the terminal:

xhost +

tracking_with_ocv's People

Contributors

otre99 avatar

Watchers

 avatar

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.