org.opencv.android.LoaderCallbackInterface Java Examples

The following examples show how to use org.opencv.android.LoaderCallbackInterface. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VisionEnabledActivity.java    From FTCVision with MIT License 8 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    if (opMode == null)
        return;

    if (!OpenCVLoader.initDebug()) {
        Log.d("OpenCV", "Internal OpenCV library not found. Using OpenCV Manager for initialization");
        boolean success = OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, openCVLoaderCallback);
        if (!success)
            Log.e("OpenCV", "Asynchronous initialization failed!");
        else
            Log.d("OpenCV", "Asynchronous initialization succeeded!");
    } else {
        Log.d("OpenCV", "OpenCV library found inside package. Using it!");
        openCVLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}
 
Example #2
Source File: ColorizeFaceActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS: {
            Log.i("OpenCV", "OpenCV loaded successfully");
            mRgbMat = new Mat();
            mHsvMat = new Mat();
            mMaskMat = new Mat();
            mDilatedMat = new Mat();
            hierarchy = new Mat();
        }
        break;
        default: {
            super.onManagerConnected(status);
        }
        break;
    }
}
 
Example #3
Source File: MainActivity.java    From MOAAP with MIT License 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
        {
            Log.d("OCR", "Start loading MNIST and creating classifier");
            mOpenCvCameraView.enableView();
            mnist = new DigitRecognizer("train-images.idx3-ubyte", "train-labels.idx1-ubyte");
            Log.d("OCR", "Loading MNIST done");
        } break;
        default:
        {
            super.onManagerConnected(status);
        } break;
    }
}
 
Example #4
Source File: FtcTestOpenCv.java    From FtcSamples with MIT License 6 votes vote down vote up
private void startCamera()
    {
        final String funcName = "startCamera";

        if (cameraEnabled)
        {
            if (!OpenCVLoader.initDebug())
            {
                tracer.traceInfo(
                        funcName,
                        "Internal OpenCV library not found, using OpenCV Manager for initialization");
                OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, activity, loaderCallback);
            }
            else
            {
                tracer.traceInfo(funcName, "OpenCV library found inside package, use it!");
                loaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
            }
//            setCameraDisplayOrientation(activity, Camera.CameraInfo.CAMERA_FACING_FRONT);
//            cameraPreview.onResume();
        }
    }
 
Example #5
Source File: CameraActivity.java    From android-object-distance with Apache License 2.0 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
        {
            Log.i(RIZ_TAG, "OpenCV loaded successfully");
            // Create and set View
            setContentView(R.layout.activity_camera);
            getFragmentManager().beginTransaction()
                    .replace(R.id.container, Camera2BasicFragment.newInstance())
                    .commit();
        } break;
        default:
        {
            super.onManagerConnected(status);
        } break;
    }
}
 
Example #6
Source File: MainActivity.java    From OpenCV-Android-Object-Detection with MIT License 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS: {
            Log.i(TAG, "OpenCV loaded successfully");
            mOpenCvCameraView.enableView();
            try {
                initializeOpenCVDependencies();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        break;
        default: {
            super.onManagerConnected(status);
        }
        break;
    }
}
 
Example #7
Source File: Tutorial2Activity.java    From OpenCV-AndroidSamples with MIT License 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
        {
            Log.i(TAG, "OpenCV loaded successfully");

            // Load native library after(!) OpenCV initialization
            System.loadLibrary("ndklibrarysample");

            mOpenCvCameraView.enableView();
        } break;
        default:
        {
            super.onManagerConnected(status);
        } break;
    }
}
 
Example #8
Source File: Puzzle15Activity.java    From OpenCV-AndroidSamples with MIT License 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
        {
            Log.i(TAG, "OpenCV loaded successfully");

            /* Now enable camera view to start receiving frames */
            mOpenCvCameraView.setOnTouchListener(Puzzle15Activity.this);
            mOpenCvCameraView.enableView();
        } break;
        default:
        {
            super.onManagerConnected(status);
        } break;
    }
}
 
Example #9
Source File: ImageFragment.java    From OpenCV-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ivOrigin = view.findViewById(R.id.originIv);
    ivAfter = view.findViewById(R.id.afterIv);
    RadioGroup radioGroup = view.findViewById(R.id.rg);
    if (!OpenCVLoader.initDebug()) {
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, getContext(), mLoaderCallback);
    } else {
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (currentId == checkedId) {
                return;
            }
            currentId = checkedId;
        }
    });
}
 
Example #10
Source File: MainActivity.java    From hand_finger_recognition_android with MIT License 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
        {
            Log.i(TAG, "OpenCV loaded successfully");
            mOpenCvCameraView.enableView();
            mOpenCvCameraView.setOnTouchListener(MainActivity.this);
            // 640x480
        } break;
        default:
        {
            super.onManagerConnected(status);
        } break;
    }
}
 
Example #11
Source File: FaceRecognitionAppActivity.java    From FaceRecognitionApp with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
            NativeMethods.loadNativeLibraries(); // Load native libraries after(!) OpenCV initialization
            Log.i(TAG, "OpenCV loaded successfully");
            mOpenCvCameraView.enableView();

            // Read images and labels from shared preferences
            images = tinydb.getListMat("images");
            imagesLabels = tinydb.getListString("imagesLabels");

            Log.i(TAG, "Number of images: " + images.size()  + ". Number of labels: " + imagesLabels.size());
            if (!images.isEmpty()) {
                trainFaces(); // Train images after they are loaded
                Log.i(TAG, "Images height: " + images.get(0).height() + " Width: " + images.get(0).width() + " total: " + images.get(0).total());
            }
            Log.i(TAG, "Labels: " + imagesLabels);

            break;
        default:
            super.onManagerConnected(status);
            break;
    }
}
 
Example #12
Source File: MainActivity.java    From Form-N-Fun with MIT License 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    super.onManagerConnected(status);
    switch(status)
    {
        case LoaderCallbackInterface.SUCCESS: {
            Log.i(TAG, "OpenCV loaded successfully");

            mOpenCvCameraView.enableView();

        }break;
        default:
        {
            super.onManagerConnected(status);
        } break;
    }
}
 
Example #13
Source File: AAVActivity.java    From AAV with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
	switch (status) {
	case LoaderCallbackInterface.SUCCESS: {
		_opencvCameraView.enableView();
		_hsvMat = new Mat();
		_processedMat = new Mat();
		_dilatedMat = new Mat();
	}
		break;
	default: {
		super.onManagerConnected(status);
	}
		break;
	}
}
 
Example #14
Source File: FdActivity.java    From open-quartz with Apache License 2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    // Load default libopencv_java.so
    if (OpenCVLoader.initDebug()) {
        Toast.makeText(getApplicationContext(), "Libraries Loaded!", Toast.LENGTH_SHORT).show();

        if (mLoaderCallback != null) {
            mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
        }
    } else {
        Toast.makeText(getApplicationContext(), "failed to load libraries", Toast.LENGTH_SHORT)
            .show();
    }

    // Usual OpenCV Loader
    // OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
}
 
Example #15
Source File: MonitoringService.java    From go-bees with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Config OpenCV (config callback and init OpenCV).
 * When OpenCV is ready, it starts monitoring.
 */
private void configOpenCv() {
    // OpenCV callback
    BaseLoaderCallback loaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(final int status) {
            if (status == LoaderCallbackInterface.SUCCESS) {
                openCvLoaded = true;
                startMonitoring();
            } else {
                super.onManagerConnected(status);
            }
        }
    };
    // Init openCV
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, this, loaderCallback);
}
 
Example #16
Source File: MainActivity.java    From pasm-yolov3-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
// Una volta che OpenCV manager è connesso viene chiamato questo metodo di
public void onManagerConnected(int status) {
    switch (status) {
        // Una volta che OpenCV manager si è connesso con successo
        // possiamo abilitare l'interazione con la tlc
        case LoaderCallbackInterface.SUCCESS:
            Log.i(TAG, "OpenCV loaded successfully");
            mOpenCvCameraView.enableView();

            break;
        default:
            super.onManagerConnected(status);
             break;
    }
}
 
Example #17
Source File: OldMainActivity.java    From pasm-yolov3-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
// Una volta che OpenCV manager è connesso viene chiamato questo metodo di
public void onManagerConnected(int status) {
    switch (status) {
        // Una volta che OpenCV manager si è connesso con successo
        // possiamo abilitare l'interazione con la tlc
        case LoaderCallbackInterface.SUCCESS:
            Log.i(TAG, "OpenCV loaded successfully");
            mOpenCvCameraView.enableView();

            break;
        default:
            super.onManagerConnected(status);
             break;
    }
}
 
Example #18
Source File: SingleMakeupActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS: {
            Log.i("OpenCV", "OpenCV loaded successfully");
            mRgbMat = new Mat();
            mHsvMat = new Mat();
            mMaskMat = new Mat();
            mDilatedMat = new Mat();
            hierarchy = new Mat();
        }
        break;
        default: {
            super.onManagerConnected(status);
        }
        break;
    }
}
 
Example #19
Source File: CropImage.java    From reader with MIT License 5 votes vote down vote up
@Override  
public void onManagerConnected(int status) {  
    switch (status) {  
        case LoaderCallbackInterface.SUCCESS:{  
        } break;  
        default:{  
            super.onManagerConnected(status);  
        } break;  
    }  
}
 
Example #20
Source File: GabrielClientActivity.java    From faceswap with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	if (!OpenCVLoader.initDebug()) {
		Log.d(LOG_TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
		OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
	} else {
		Log.d(LOG_TAG, "OpenCV library found inside package. Using it!");
		mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
	}
	Log.d(DEBUG_TAG, "on resume");
}
 
Example #21
Source File: App.java    From pulse with ISC License 5 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    switch (status) {

        case LoaderCallbackInterface.SUCCESS:
            loaderCallbackSuccess();
            break;

        default:
            super.onManagerConnected(status);
            break;
    }
}
 
Example #22
Source File: ColorBlobDetectionActivity.java    From OpenCV-AndroidSamples with MIT License 5 votes vote down vote up
@Override
public void onResume()
{
    super.onResume();
    if (!OpenCVLoader.initDebug()) {
        Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
    } else {
        Log.d(TAG, "OpenCV library found inside package. Using it!");
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}
 
Example #23
Source File: OpenCVCallback.java    From SimpleDocumentScanner-Android with MIT License 5 votes vote down vote up
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS: {
            break;
        }

        case LoaderCallbackInterface.MARKET_ERROR: {
            Timber.e("Package installation failed, there is no market app.");
            showMessage("Unable to open Google Market", "The document scanner depends on the OpenCV Manager application available on Google Play.  We were unable to launch the Google Play Market on your device.");
            break;
        }

        case LoaderCallbackInterface.INSTALL_CANCELED: {
            Timber.d("OpenCV library installation was canceled by the user");
            finish();
            break;
        }

        case LoaderCallbackInterface.INCOMPATIBLE_MANAGER_VERSION: {
            Timber.d("OpenCV Manager Service is incompatible with this app!");
            showMessage("OpenCV Manager Outdated", "The OpenCV Manager installed on this device is incompatible with this app.  Try to update it via Google Play.");
            break;
        }

        default: {
            Timber.e("OpenCV loading failed!");
            showMessage("OpenCV Error", "OpenCV is unable initialize!  Document scanner is unavailable.");
            break;
        }
    }
}
 
Example #24
Source File: MainActivity.java    From opencv-android-sample with MIT License 5 votes vote down vote up
@Override
public void onResume()
{
    super.onResume();
    if (!OpenCVLoader.initDebug()) {
        Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
    } else {
        Log.d(TAG, "OpenCV library found inside package. Using it!");
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}
 
Example #25
Source File: MainActivity.java    From SimpleDocumentScanner-Android with MIT License 5 votes vote down vote up
/**
 * Attempt to load OpenCV via statically compiled libraries.  If they are not found, then load
 * using OpenCV Manager.
 */
private void initOpenCV() {
    if (!OpenCVLoader.initDebug()) {
        Timber.d("Internal OpenCV library not found. Using OpenCV Manager for initialization");
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mOpenCVLoaderCallback);
    } else {
        Timber.d("OpenCV library found inside package. Using it!");
        mOpenCVLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}
 
Example #26
Source File: StepByStepTestActivity.java    From CVScanner with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    if(!OpenCVLoader.initDebug()){
        //OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, getApplicationContext(), mCallback);
    }
    else mCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
 
Example #27
Source File: SingleMakeupActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public void onResume() {
    super.onResume();
    if (!OpenCVLoader.initDebug()) {
        Log.d("OpenCV", "Internal OpenCV library not found. Using OpenCV Manager for initialization");
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mLoaderCallback);
    } else {
        Log.d("OpenCV", "OpenCV library found inside package. Using it!");
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}
 
Example #28
Source File: BaseFragment.java    From CVScanner with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onManagerConnected(int status) {
    if(status == LoaderCallbackInterface.SUCCESS){
        onOpenCVConnected();
    }
    else{
        onOpenCVConnectionFailed();
    }
}
 
Example #29
Source File: MainActivity.java    From Android_OCV_Movement_Detection with MIT License 5 votes vote down vote up
@Override
public void onManagerConnected(int status) {
   switch (status) {
       case LoaderCallbackInterface.SUCCESS:
       {
      Log.i(TAG, "OpenCV loaded successfully");
       } break;
       default:
       {
      super.onManagerConnected(status);
       } break;
   }
    }
 
Example #30
Source File: GabrielClientActivity.java    From faceswap with Apache License 2.0 5 votes vote down vote up
@Override
public void onManagerConnected(int status) {
	switch (status) {
		case LoaderCallbackInterface.SUCCESS:
		{
			Log.i(LOG_TAG, "OpenCV loaded successfully");
			mOpenCvCameraView.setMaxFrameSize(Const.IMAGE_WIDTH, Const.IMAGE_HEIGHT);
			mOpenCvCameraView.enableView();
		} break;
		default:
		{
			super.onManagerConnected(status);
		} break;
	}
}