Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Demo - Object Tracking (VitTrack) #240

Merged
merged 8 commits into from
Mar 6, 2024

Conversation

ryan1288
Copy link
Contributor

@ryan1288 ryan1288 commented Mar 3, 2024

This PR adds the C++ demo for the Object Tracking VitTrack model, as part of a request from #135.

  • demo.cpp: Added to have matching functionality to the demo.py, text offsets in both versions were adjusted to prevent overlap and improve clarity.
  • demo.py: Updated to use save and vis flags for optional saving (disabled by default) and visualization (enabled by default) functionality.
  • CMakeLists.txt: Created to build with OpenCV 4.9.0 and enforces C++11 standards upon building.
  • README.md: Updated with C++ instructions.

The interface matches other C++ demos within the set of ML models.

Average 100+ FPS on my laptop (AMD Ryzen 7 5800H) for a (640 x 480) webcam feed. FPS is slightly higher on a (1273 x 733) input video, see testing example below.

Testing

  • Run demo using webcam
cmake -B build -D OPENCV_INSTALLATION_PATH=/path/to/opencv .
cmake --build build
./build/opencv_zoo_object_tracking_vittrack

phone

  • Run demo using input video
cmake -B build -D OPENCV_INSTALLATION_PATH=/path/to/opencv .
cmake --build build
./build/opencv_zoo_object_tracking_vittrack -i=dog.mp4

dog

@ryan1288
Copy link
Contributor Author

ryan1288 commented Mar 3, 2024

@fengyuentau I noticed that the "save" functionality should be optionally enabled to save an output .mp4 with the tracking bounding box. This is currently neither available in the Python demo nor the new C++ demo. I'll add that functionality to both C++ and Python in a different PR. Other models may have the same problem so I'll add it to them as well.

Comment on lines 70 to 71
"{save s |false |Specify to save a file with results. Invalid in case of camera input.}"
"{vis v |false |Specify to open a new window to show results. Invalid in case of camera input.}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like both of them are not used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are now used! 👍 In both C++ and Python.

@fengyuentau
Copy link
Member

@fengyuentau I noticed that the "save" functionality should be optionally enabled to save an output .mp4 with the tracking bounding box. This is currently neither available in the Python demo nor the new C++ demo. I'll add that functionality to both C++ and Python in a different PR. Other models may have the same problem so I'll add it to them as well.

Ok, it would be like to have this fuctionality implemented.

@fengyuentau fengyuentau self-assigned this Mar 4, 2024
@fengyuentau fengyuentau added the demo anything related to demo in Python / C++ label Mar 4, 2024
@fengyuentau fengyuentau added this to the 4.10.0 milestone Mar 4, 2024
@ryan1288
Copy link
Contributor Author

ryan1288 commented Mar 5, 2024

@fengyuentau I noticed that the "save" functionality should be optionally enabled to save an output .mp4 with the tracking bounding box. This is currently neither available in the Python demo nor the new C++ demo. I'll add that functionality to both C++ and Python in a different PR. Other models may have the same problem so I'll add it to them as well.

Ok, it would be like to have this fuctionality implemented.

The functionality is added 💯 Saving works for both input videos and camera feed with matching FPS.

Copy link
Member

@fengyuentau fengyuentau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@fengyuentau fengyuentau merged commit ef3b465 into opencv:main Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo anything related to demo in Python / C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants