-
Notifications
You must be signed in to change notification settings - Fork 28
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
Deinhofer/javacv upgrade and optimizations #332
Deinhofer/javacv upgrade and optimizations #332
Conversation
* Adapted all imports to the new structure of org.bytedeco.opencv.* * .jars not yet committed, will try to download them in build file * still error message when trying to load XfacetrackerLK plugin: probably osgi export of javacv-xxx-.jar would have to be updated to all packages that are needed.
* added method to convert CvPoint2D32f object to Mat object that is needed by C++ API * added method to convert Mat object (representing 2D32f points) to CvPoint2D32f * added some debugging messages It seems that CPU usage dropped by 50% although precalculated pyramid images are not used. Generally the whole plugin should be rewritten to use only the C++ API.
…arm64 (opencv and openblas
* added jars to use maven artifact resolver ant tasks: https://maven.apache.org/resolver-ant-tasks * added jar for bndtools to easily generate osgi-fied jar out of javacv jars: https://bnd.bndtools.org/chapters/390-wrapping.html
…osgi-fied bundles of javacv * javacv are resolved and downloaded using the maven artifact resolver ant tasks: https://maven.apache.org/resolver-ant-tasks and the javacv pom.xml file. * using bndtools to easily generate osgi-fied jar out of javacv jars: https://bnd.bndtools.org/chapters/390-wrapping.html * the old mechanism of merging several jars together is not used any more, instead the opencv*.jars are included into the javacv-*-basic-*.jar file as jar files and referenced via class path
…ot take really long any more
…iz.aQuote.bnd-5.0.1.jar)
…detection. Thanks to learnopencv and Satya Mallick for this trick
Tested both versions on:
Performance: |
Thanks to @benjaminaigner , looks good. @ChrisVeigl and @klues please test on Windows and post the results here. With Java 32bit and 64bit, if possible. |
sorry for the repetitions, github showed an error message indicating that the post had failed. :-) |
Tested both versions on: Performance: this branch: So the new version needs about 80-90MB more RAM, all other things are working fine 👍 |
here my test results: System information: Win10 (x64), Lenovo Thinkpad P51s (core i7-7500, 2.7GHz), Java32bit Tested model: "XCameraMouse" (startup menu) Results (this branch): Results (AsTeRICS release version 4.0.0) Regarding the RAM usage: the system consumes about 58 MB when started (model autostart running, displays the main menu), but when the xCameraMouse model is loaded the RAM usage rises constantly (during the operation of the camera mouse, about 5MB per second) Further it should be noted, that the "old" CameraMouse model on Windows consumes only about 2% CPU during tracking, and RAM usage stay around 80MB (constant). |
The detection load decreases as the used images size is smaller.
If the rise is just temporarily and does not go up infinitely, it's fine. Does the rise stop at some point?
Yes, of course because it's implemented natively. But it does not run on other platforms. |
yes - RAM consumption rises quickly and the garbage collector kicks in occasionally. |
I just tested the performance of the facetracking on a RaspberryPi4 (4GB RAM, Raspbian buster). A standard raspi cam (2.1) was used as camera. The tracking works really well - even the chrome browser can be used without significant problems via the camera mouse :-) However, I also investigated the memory utilisation on the RaspberryPi: When the model was closed (and the menu was displayed again), the RAM was not released. |
As the memory consumption problem is unrelated to this pull request, I created a seperate issue for that. I have no obligations against merging this pull request, although 2 suggestions:
|
…ot print on Linux-based small platforms: to be tested
thanks for having a look at the memory consumption problem. i tested this on RaspberryPi4 - it somehow improves the situation, but still hundreds of MB are consumed rather quickly. I suggest another solution here #334 |
…n an RPi 3 this lead to swapping after some time. * Tuning of Java Garbage Collection according to * https://docs.oracle.com/javase/10/gctuning/factors-affecting-garbage-collection-performance.htm#JSGCT-GUID-6635C481-AE78-485A-A184-A1709712961A * Use -verbose:gc for debugging gc cycles and pause time * -Xmx<size> sets the max heap size. According to tests the real memory used is about up to 2*Xmx
The resolution is only used for face detection (haarcascade) and I did not have any detection problems so far. For optical flow the full resolution is used.
I actually don't know how to improve it now. But it's only the first time downloading the takes more time. After that the files are cached by maven. Also the generated osgi jar is cached as soon as it exists. |
in my tests, the initialisation of the face position (when the tracking points have not been set, or got lost) proved to be difficult. it is necessary to present the face in a perfectly aligned vertical orientaton to get a successful haar cascade classification. This could be a challenge (or even unusable) for the target audience. (the face detection works better in the original FaceTrackerLK algorithm, maybe this is related to the resolution). |
Fixes #331
This PR adds support for the Macbook webcam and improves tracking quality.
@klues @ChrisVeigl @benjaminaigner @sabicalija @bmedicke
Please test on your platforms in the next days.