org.opencv.android.OpenCVLoader Java Examples

The following examples show how to use org.opencv.android.OpenCVLoader. 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: 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 #3
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 #4
Source File: CameraActivity.java    From android-object-distance with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    activity = this;
    /*RIZ: To check if opencv is loaded. If not exit app*/
    Log.i(RIZ_TAG, "Trying to load OpenCV library");
    if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
    {
        Log.e(RIZ_TAG, "Cannot connect to OpenCV Manager");
    }

    setContentView(R.layout.activity_camera);
    if (null == savedInstanceState) {
        getFragmentManager().beginTransaction()
                .replace(R.id.container, Camera2BasicFragment.newInstance())
                .commit();
    }
}
 
Example #5
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 #6
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 #7
Source File: MainActivity.java    From MOAAP with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    imageView = (ImageView)findViewById(R.id.image_view);

    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, this, mOpenCVCallBack);

    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
        Log.i("permission", "request READ_EXTERNAL_STORAGE");
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                REQUEST_READ_EXTERNAL_STORAGE);
    }else {
        Log.i("permission", "READ_EXTERNAL_STORAGE already granted");
        read_external_storage_granted = true;
    }
}
 
Example #8
Source File: MainActivity.java    From OpenTLDAndroid with Apache License 2.0 5 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    Log.i(Util.TAG, "Trying to load OpenCV library");
    if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, _openCVCallBack)) {
    	Log.e(Util.TAG, "Cannot connect to OpenCV Manager");
    }
}
 
Example #9
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 #10
Source File: CropImage.java    From reader with MIT License 5 votes vote down vote up
@Override  
public void onResume(){  
    super.onResume();  
    //通过OpenCV引擎服务加载并初始化OpenCV类库,所谓OpenCV引擎服务即是  
    //OpenCV_2.4.3.2_Manager_2.4_*.apk程序包,存在于OpenCV安装包的apk目录中  
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_10, this, mLoaderCallback);  
}
 
Example #11
Source File: FaceDetectionActivity.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 #12
Source File: Tutorial3Activity.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 #13
Source File: Tutorial1Activity.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 #14
Source File: Tutorial2Activity.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 #15
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 #16
Source File: ImageManipulationsActivity.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 #17
Source File: CameraActivity.java    From Android-Car-duino with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume()
{
    driver = new AutomaticCarDriver();
    super.onResume();
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
}
 
Example #18
Source File: Puzzle15Activity.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 #19
Source File: ColorDetectionActivity.java    From FaceT with Mozilla Public License 2.0 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_1_0, this, mLoaderCallback);
    } else {
        Log.d(TAG, "OpenCV library found inside package. Using it!");
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}
 
Example #20
Source File: MainActivity.java    From effective_android_sample with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /**
     * OpenCVの初期化
     */
    if (!OpenCVLoader.initDebug()) {
        // Report initialization error
        Log.i(TAG,"OpenCV init Error");
    }

    // シークバーのセッティング
    SeekBar seekBar = (SeekBar) findViewById(R.id.pickupSeekbar);
    seekBar.setMax(255);
    seekBar.setProgress(30);
    sTH = 30;
    seekBar.setOnSeekBarChangeListener(new MySeekBarListener());

    // 他のUI部品セッティング
    mImageView1 = (ImageView) findViewById(R.id.imageView1);
    mImageView2 = (ImageView) findViewById(R.id.imageView2);
    mImageView3 = (ImageView) findViewById(R.id.imageView3);
    mImageView4 = (ImageView) findViewById(R.id.imageView4);
    mImageView5 = (ImageView) findViewById(R.id.imageView5);
    mImageView6 = (ImageView) findViewById(R.id.imageView6);
    mImageView7 = (ImageView) findViewById(R.id.imageView7);
    mImageView8 = (ImageView) findViewById(R.id.imageView8);
  
    // オリジナルのビットマップをオープン
    try {
        InputStream is = getResources().getAssets().open("orig.jpg");
        mBitmap = BitmapFactory.decodeStream(is);
    } catch (IOException e) {
    }
    extractObject(mBitmap);
}
 
Example #21
Source File: CameraCalibrationActivity.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 #22
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 #23
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 #24
Source File: BaseFragment.java    From CVScanner with GNU General Public License v3.0 5 votes vote down vote up
protected void loadOpenCV(){
    if(!OpenCVLoader.initDebug()){
        //OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, getActivity().getApplicationContext(), mLoaderCallback);
    }
    else{
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}
 
Example #25
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 #26
Source File: MainActivity.java    From Form-N-Fun with MIT License 5 votes vote down vote up
@Override
public void onResume()
{
    super.onResume();
    if(Build.VERSION.SDK_INT< 23)
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
    hideSystemUI(); //hide UI
}
 
Example #27
Source File: MainActivity.java    From Form-N-Fun with MIT License 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
        Toast.makeText(this, "Permission granted", Toast.LENGTH_SHORT).show();
    } else{

        Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show();
    }
}
 
Example #28
Source File: MainActivity.java    From Form-N-Fun with MIT License 5 votes vote down vote up
private void askForPermission(String permission, Integer requestCode) {
    if (ContextCompat.checkSelfPermission(MainActivity.this, permission) != PackageManager.PERMISSION_GRANTED) {
        if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, permission)) {

            ActivityCompat.requestPermissions(MainActivity.this, new String[]{permission}, requestCode);

        } else {

            ActivityCompat.requestPermissions(MainActivity.this, new String[]{permission}, requestCode);
        }
    } else {
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
        //Toast.makeText(this, "" + permission + " is already granted.", Toast.LENGTH_SHORT).show();
    }
}
 
Example #29
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 #30
Source File: ColorizeFaceActivity.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);
    }
}