-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add asynchronous face detection sample for OpenVINO Java API 2.0 (updated from deprecated API 1.0) #951
base: master
Are you sure you want to change the base?
Conversation
Hey @likholat , in this last commit, I made changes primarily based on the deprecated sample. Let me know if there's anything else I can do to improve it further. This version should be more aligned and likely to work better now. Thanks for your time and review! |
@leoheim please keep only source files and remove all the binaries |
Hi @likholat , I have updated the repository to keep only the source files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all the binary files from PR.
modules/nvidia_plugin/build.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep only changes related to Java sample and Android sample
351ffc8
to
cd9cf4f
Compare
Hey @likholat, I believe it's correct now. I've removed the unnecessary files and kept only the source files as requested. Let me know if there's anything else you'd like me to adjust! |
Initial project structure created
Set up basic asynchronous structure with threads and queues for frame capturing and inference handling.
Implemented video capture using OpenCV’s VideoCapture class:
Frames continuously read from webcam/video file.
Frames added to a thread-safe queue (BlockingQueue).
Model loading and preprocessing implemented with new API 2.0 methods:
Core.read_model() instead of the deprecated Core.ReadNetwork().
Configured inputs with the modern PrePostProcessor API.
Full asynchronous inference logic implemented:
Created multiple InferRequest instances for parallel inference.
Leveraged start_async() and wait_async() methods clearly and efficiently.
Results processing:
Obtained inference results (Tensor) and parsed detection coordinates.
Results passed to visualization thread through a queue (BlockingQueue<float[]>).
Visualization using OpenCV (HighGui):
Real-time visualization of face detections.
Bounding boxes drawn around detected faces.
Graceful shutdown added for threads and resources:
Proper interruption and termination of threads (captureThread, inferenceThread).
Closing OpenCV windows upon exit.
CNNNetwork net = core.ReadNetwork(xmlPath)
Model model = core.read_model(xmlPath)
ExecutableNetwork exec = core.LoadNetwork(net, device)
CompiledModel compiledModel = core.compile_model(model, device)
execNetwork.CreateInferRequest()
compiledModel.create_infer_request()
StartAsync()
&Wait(WaitMode)
start_async()
&wait_async()
(simplified)Blob
Tensor
objectPrePostProcessor
APIKey additions and improvements:
Clean and modern Java API 2.0 usage:
Introduced modern classes (CompiledModel, Tensor, Model, PrePostProcessor).
Clear asynchronous logic:
Simplified inference workflow (start_async(), wait_async()).
Better readability and maintainability:
Added extensive inline comments explaining each step clearly.
Simplified queues management for multi-threading.
What was removed:
Deprecated API calls (CNNNetwork, manual Blob management).
Complex asynchronous management using deprecated WaitMode enums and ID queues.
JNI implementation status:
No new JNI methods required.
All necessary JNI methods (start_async, wait_async, tensor handling) were already implemented previously in JNI files provided in the repository.