-
Notifications
You must be signed in to change notification settings - Fork 224
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
Force load opencv before using OpenCV functions #1808
base: main
Are you sure you want to change the base?
Conversation
When are these static blocks evaluated? Is there any way that they might end up only being evaluated once a robot begins autonomous.? Loading open CV can be pretty slow. |
It should only happen when trying to update a pose estimator with a strategy that requires OpenCV, would you want these to be earlier like when the pose estimator is created? |
I don't know. I don't want teams not using these to pay the RAM cost, but also don't want a footgun for other people |
Best I can do is both. It will load when the pose estimator is created with the necessary strategies, and before using the opencv functions just in case |
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.
Classloading in Java is lazy, so the static load will only happen when the class is first accessed. Checking for strategies that require OpenCV and then loading them if those strategies are used is exactly how I would've done it, and means only people who use those strategies will pay the cost of OpenCV.
Force loads OpenCV before any OpenCV functions are used.
OpenCVLoader
has all of its loading done in a static initializer field, so it's only loaded once.Also deprecates
OpenCVHelp.forceLoadOpenCV()
, since it's functionality is the exact same.Resolves #1803