Class CVInit
Initialization is tricky as Loader.load(opencv_java.class)
needs to be called once
before any OpenCV libraries can be used. However, this is an expensive operation that can last
several seconds.
To avoid delays, this class will begin the loading as soon as alwaysExecuteBeforeCallingLibrary()
is called (typically from a static
block in a class
that uses OpenCV, but in a separate thread that doesn't block other (typically non-OpenCV)
operations.
Non-OpenCV code continues unaffected, but OpenCV code should not be prevented from being
called until loading is complete. Therefore, code using the openCV libraries should always first
call blockUntilLoaded()
before immediately before the first call to an OpenCV library.
This will force the thread to wait, if loading is not yet completed.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
This routine must always be executed at least once before calling any routines in the OpenCV librarystatic void
Blocks a thread until the initialization has completed.
-
Method Details
-
alwaysExecuteBeforeCallingLibrary
public static void alwaysExecuteBeforeCallingLibrary()This routine must always be executed at least once before calling any routines in the OpenCV library -
blockUntilLoaded
public static void blockUntilLoaded()Blocks a thread until the initialization has completed.
-