Class CVInit

Object
CVInit

public class CVInit extends Object
Provides for initialization of the JavaCPP bridge to OpenCV.

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 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.