Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.StringTokenizer;
import android.util.Log;

public class Main {
    private static final String TAG = "OpenCV/StaticHelper";

    private static boolean initOpenCVLibs(String Libs) {
        Log.d(TAG, "Trying to init OpenCV libs");

        boolean result = true;

        if ((null != Libs) && (Libs.length() != 0)) {
            Log.d(TAG, "Trying to load libs by dependency list");
            StringTokenizer splitter = new StringTokenizer(Libs, ";");
            while (splitter.hasMoreTokens()) {
                result &= loadLibrary(splitter.nextToken());
            }
        } else {
            // If dependencies list is not defined or empty.
            result &= loadLibrary("opencv_java3");
        }

        return result;
    }

    private static boolean loadLibrary(String Name) {
        boolean result = true;

        Log.d(TAG, "Trying to load library " + Name);
        try {
            System.loadLibrary(Name);
            Log.d(TAG, "Library " + Name + " loaded");
        } catch (UnsatisfiedLinkError e) {
            Log.d(TAG, "Cannot load library \"" + Name + "\"");
            e.printStackTrace();
            result &= false;
        }

        return result;
    }
}