Code Monkey home page Code Monkey logo

dasiamrpn-oop's Introduction

DaSiamRPN-OOP

This is an openCV DaSiamRPN object oriented implementation. An example usage is made in the main.cpp file. Besides that, the DaSiamTracker class methods are explained in the Class Usage Explanation. It is tested with NVIDIA Jetson Nano and recieved an average of 16-19 FPS. With NVIDIA RTX 3050 mobile version, it recieves around 120-130 FPS.
Note: The current implementation is using CUDA backend with fp16 halp precision in order to increase FPS. The backend and target can be changed in dasiamtracker.cpp file.

!!WARNING: To build and run this code, you have to build openCV with CUDA. This link can be used for that purpose.

WARNING: The .onnx files in the build directory is essential for the code to run. Do not delete them.

WARNING: It is tested on opencv 4.7 and 4.6 but the current code is for the 4.7 version. If the code needs to be used with opencv 4.6, then #include <opencv2/video/tracking.hpp> line should be changed with #include <opencv2/tracking.hpp>

This implementation is made for easy usage of the DaSiamRPN tracker with the utilization of abstraction.
An example implementation of the DaSiamTracker class in dasiamtracker.hpp file can be tested with building the main.cpp file as following:

Class Usage Explanation

This DaSiamTracker class implementation is made for the sake of simplicity, using abstraction as much as possible. To initialize the tracking, you need to follow the steps below :

Summary of the usage explanation:

  1. Create the tracker object, set it's width and height. Also declare the initial bounding box coordinates.
  2. To initialize, set the current frame and call the initialize tracking function.
  3. To resume the tracking, set the current frame and call the track function.
  4. Use get_current_tracked_bbox(), get_fps(), get_score() functions to obtain the results.
    !! WARNING: Before initialization and each single tracking operation, you should set a new frame.

More detailed usage explanation:

(It is assumed that the video capture is already handled and you can get consecutive frames in your program.)

  1. Obtain the capture width and height of the frames.
  2. Create the tracker object using the capture width and height, either with "DaSiamTracker(int w, int h)" contructor or with the "DaSiamTracker()" contructor and use "set_w_h(int new_w, int new_h)" function.
  3. Use "void set_static_bbox(int new_bbox_x_px, int new_bbox_y_px, int new_bbox_w_px, int new_bbox_h_px)" funtion to declare the static bounding box, where the tracking will be initialized. (Use pixel values as parameters. First two parameters are for the center of the bounding box, the last two are for the width and height of the bounding box.)
  4. Before initializing the tracker, use "set_frame(Mat new_frame)*" function to load the current frame in to the tracker object, and call "initialize_tracking()" function. (Pass the address of the Mat object)
  5. For each track operation after initialization, it is necessary to use "set_frame(Mat new_frame)*" function. After this, you can call the "track()" function.
  6. After each track function is called, you can obtain the resulting bounding box with "get_current_tracked_bbox()" function, and get the tracking score and fps with "get_score()" and "get_fps()" functions respectively.

Building and Running

First, download the files Then, go in to the project folder. Navigate to the build directory.

cd build

After this, perform cmake and make commands.

cmake ..
make

Finally, you are ready to run the program.

./DaSiamRPNTrack

dasiamrpn-oop's People

Contributors

uozyurt avatar

Stargazers

 avatar  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.