public class CVInit extends Object
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.
Modifier and Type | Method and Description |
---|---|
static void |
alwaysExecuteBeforeCallingLibrary()
This routine must always be executed at least once before calling any routines in the OpenCV
library
|
static void |
blockUntilLoaded()
Blocks a thread until the initialization has completed.
|
public static void alwaysExecuteBeforeCallingLibrary()
public static void blockUntilLoaded()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.