Force load opencv before using OpenCV functions#1808
Force load opencv before using OpenCV functions#1808spacey-sooty merged 5 commits intoPhotonVision:mainfrom
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 |
Gold856
left a comment
There was a problem hiding this comment.
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.
OpenCVLoaderhas 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