├── LICENSE.txt ├── README.md ├── deepsort └── deepsort.engine ├── demo.py ├── yolo_deepsort.cpython-37m-x86_64-linux-gnu.so └── yolov5 └── yolov5s.engine /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 cong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # yolov5_deepsort_tensorrt_cpp 2 | 3 | ## Introduction 4 | 5 | This repo is a C++ version of **[yolov5_deepsort_tensorrt](https://github.com/cong/yolov5_deepsort_tensorrt)**. 6 | 7 | And packing all C++ programs into .so files, using Python script to call C++ programs further. 8 | 9 | The entire project file size totals 40MB 10 | 11 | **NVIDIA Jetson Xavier NX** and the *X86* architecture works all be ok. 12 | 13 | Since this project is being used in a science and technology major project, we just temporarily provide a test example. 14 | 15 | ## Environments 16 | 17 | All platforms: 18 | - CUDA and cuDNN latest 19 | - Python 3.7 20 | - OpenCV latest (we use 4.2) 21 | 22 | 23 | ## Speed 24 | 25 | The speeds of DeepSort depend on the target number in the picture. 26 | 27 | The following data are tested in the case of single target and 100+ targets with 720p USB camera. 28 | 29 | 30 | | Platforms | Single target | 100+ targets | 31 | | :---------------- | --------------------- | ---------------------- | 32 | | GTX 2080Ti | 8ms / 125FPS / 1247M | 31ms / 32FPS / 1247M | 33 | | Jetson Xavier NX | -ms / -FPS / -M | -ms / -FPS / -M | 34 | 35 | ## Inference 36 | 37 | 1. Clone this repo 38 | 39 | ```shell 40 | git clone https://github.com/cong/yolov5_deepsort_tensorrt_cpp.git 41 | ``` 42 | 43 | 2. Run 44 | 45 | ``` 46 | python demo.py 47 | ``` 48 | 49 | ## Customize 50 | 51 | 1. Training your own model. 52 | 2. Convert your own model to engine. 53 | 3. Replace the `***.engine` file. 54 | 55 | ## Optional setting 56 | 57 | - Your likes are my motivation to update the project, if you feel that it is helpful to you, please give me a star. Thx! :) 58 | - For more information you can visit the [Blog](http://wangcong.net). 59 | -------------------------------------------------------------------------------- /deepsort/deepsort.engine: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cong/yolov5_deepsort_tensorrt_cpp/dc1f831cc06ebaefce10aaac1adf5f7cc6c020c9/deepsort/deepsort.engine -------------------------------------------------------------------------------- /demo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | #!/usr/bin/python3 3 | """ 4 | Created on 2021/5/24 13:46 5 | @Author: Wang Cong 6 | @Email : iwangcong@outlook.com 7 | @Version : 0.1 8 | @File : demo_trt.py 9 | """ 10 | import yolo_deepsort 11 | import cv2 12 | import time 13 | 14 | if __name__ == '__main__': 15 | 16 | yolo_engine = './yolov5/yolov5s.engine' 17 | sort_engine = './deepsort/deepsort.engine' 18 | capture = cv2.VideoCapture(0) 19 | yolo_deepsort_test = yolo_deepsort.Yolov5DeepSort(yolo_engine, sort_engine) 20 | 21 | fps = 0.0 22 | while True: 23 | ret, img = capture.read() 24 | if img is None: 25 | print('No image input!') 26 | break 27 | 28 | t1 = time.time() 29 | frame = yolo_deepsort_test.detect_track_frame(img) 30 | t2 = time.time() - t1 31 | print(t2*1000) 32 | cv2.imshow('frame', frame) 33 | if cv2.waitKey(10) & 0xFF == ord('q'): 34 | break 35 | 36 | capture.release() 37 | cv2.destroyAllWindows() 38 | 39 | -------------------------------------------------------------------------------- /yolo_deepsort.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cong/yolov5_deepsort_tensorrt_cpp/dc1f831cc06ebaefce10aaac1adf5f7cc6c020c9/yolo_deepsort.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /yolov5/yolov5s.engine: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cong/yolov5_deepsort_tensorrt_cpp/dc1f831cc06ebaefce10aaac1adf5f7cc6c020c9/yolov5/yolov5s.engine --------------------------------------------------------------------------------