Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to determine if OpenCV4Android has already been initialized?

We initialize OpenCV4Android using

OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, activityContext, baseLoaderCallback);

The situation I am facing is that in my launcher Activity, I have two buttons, and clicking on them results in a start of a different Activity. Let's call those activities A and B.

My JavaCameraView is in one of those two activities, say A. So I am executing the above statement in A.

But what if the user never enters the Activity A, what if they directly enter the Activity B? I need the OpenCV4Android to be initialized in Activity B as well.

So I need to do something like:

if (OpenCV4Android IS NOT INITIALIZED) {
  OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, activityContext, baseLoaderCallback);
}

How do I perform that check in if?