[Example] Three threads inference in Yolov8 with Opencv DNN C++ loading Onnx, and Python. C++ in window10, Linux #10201
+844
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have checked for Existing Contributions: Before submitting, my contribution is unique and complementary.
No related issues.
directory: examples\YOLOv8-Threads-Cpp-Python-Video
Three threads inference in Yolov8 with Opencv DNN C++ loading Onnx, and Python.
C++ and Python, it all have three threads to cowork. each of them works independently. Like customer and producer.
the first thread reads video frame;
the second thread predict the frame;
the third thread plot the prediction result to the frame and save it to video;
Reading video thread is a producer, predicting the frame thread is a customer. Then predicting the frame thread will give a prediction result, now it is a producer, ploting and saving thread is a customer. To write these function, we need a queue which is safe between different threads. Python have a Queue which is thread-safe in queue package. C++ doesn't provide such thread-safe queue, so I write a thread-safe queue by myself.
I have read the CLA Document and I sign the CLA
I also have read the examples/README.md
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Introducing multi-threaded video processing for YOLOv8 in both C++ and Python.
📊 Key Changes
🎯 Purpose & Impact
Overall, this update is set to markedly improve the speed and efficiency of video processing tasks using YOLOv8, making it more accessible across different platforms and even to those with limited multi-threading experience.