How to determine if OpenCV4Android has already been initialized?

asked 2016-04-19 04:02:09 -0500

Solace gravatar image

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?

edit retag flag offensive close merge delete