Java Code Examples for org.opencv.android.OpenCVLoader#initAsync()
The following examples show how to use
org.opencv.android.OpenCVLoader#initAsync() .
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: FtcTestOpenCv.java From FtcSamples with MIT License | 6 votes |
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 2
Source File: MainActivity.java From MOAAP with MIT License | 6 votes |
@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 3
Source File: FaceFragment.java From OpenCV-android with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); cameraView = view.findViewById(R.id.cameraView); if (!OpenCVLoader.initDebug()) { OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, getContext(), mLoaderCallback); } else { mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS); } cameraView.setCvCameraViewListener(this); face = new ObjectDetector(getContext().getApplicationContext(), R.raw.lbpcascade_frontalface, 6, 0.2F, 0.2F, new Scalar(255, 0, 0, 255)); eye = new ObjectDetector(getContext().getApplicationContext(), R.raw.haarcascade_eye, 6, 0.1F, 0.1F, new Scalar(0, 255, 0, 255)); smile = new ObjectDetector(getContext().getApplicationContext(), R.raw.haarcascade_smile, 10, 0.2F, 0.2F, new Scalar(0, 255, 255, 255)); }
Example 4
Source File: Puzzle15Activity.java From OpenCV-AndroidSamples with MIT License | 5 votes |
@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 5
Source File: MainActivity.java From MOAAP with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, this, mOpenCVCallBack); if(getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } ivImage1 = (ImageView)findViewById(R.id.ivImage1); tvKeyPointsObject1 = (TextView) findViewById(R.id.tvKeyPointsObject1); tvKeyPointsObject2 = (TextView) findViewById(R.id.tvKeyPointsObject2); tvKeyPointsMatches = (TextView) findViewById(R.id.tvKeyPointsMatches); keypointsObject1 = keypointsObject2 = keypointMatches = -1; tvTime = (TextView) findViewById(R.id.tvTime); Intent intent = getIntent(); if(intent.hasExtra("ACTION_MODE")){ ACTION_MODE = intent.getIntExtra("ACTION_MODE", 0); } 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 6
Source File: GabrielClientActivity.java From faceswap with Apache License 2.0 | 5 votes |
@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 7
Source File: OpenCvCamera.java From opencv-documentscanner-android with Apache License 2.0 | 5 votes |
@Override public void onResume() { super.onResume(); if (!OpenCVLoader.initDebug()) { OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, this, mLoaderCallback); } else { mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS); } }
Example 8
Source File: ColorizeFaceActivity.java From FaceT with Mozilla Public License 2.0 | 5 votes |
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 9
Source File: MainActivity.java From OpenCV-Android-Object-Detection with MIT License | 5 votes |
@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: MainActivity.java From Form-N-Fun with MIT License | 5 votes |
@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 11
Source File: Tutorial3Activity.java From OpenCV-AndroidSamples with MIT License | 5 votes |
@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: CameraCalibrationActivity.java From OpenCV-AndroidSamples with MIT License | 5 votes |
@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: ImageManipulationsActivity.java From OpenCV-AndroidSamples with MIT License | 5 votes |
@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: OldMainActivity.java From pasm-yolov3-Android with GNU General Public License v3.0 | 5 votes |
@Override protected void onResume() { super.onResume(); // Chiama l'inizializzazione asincrona e passa l'oggetto callback // creato in precendeza, e sceglie quale versione di OpenCV caricare. // Serve anche a verificare che l'OpenCV manager installato supporti // la versione che si sta provando a caricare. if (!disable) OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION,this, mLoaderCallback); }
Example 15
Source File: CameraActivity.java From Android-Car-duino with GNU General Public License v2.0 | 5 votes |
@Override public void onResume() { driver = new AutomaticCarDriver(); super.onResume(); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback); }
Example 16
Source File: App.java From pulse with ISC License | 4 votes |
@Override public void onResume() { super.onResume(); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_11, this, loaderCallback); }
Example 17
Source File: MainActivity.java From SoftwarePilot with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { checkAndRequestPermissions(); } setContentView(R.layout.activity_main); mHandler = new Handler(Looper.getMainLooper()); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); /* ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.INTERNET, Manifest.permission.VIBRATE, Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.WAKE_LOCK, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.SYSTEM_ALERT_WINDOW, Manifest.permission.READ_PHONE_STATE, } , 1); */ if(!OpenCVLoader.initDebug()){ Log.v(TAG, "OpenCV not loaded"); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_11, this, new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status) { case LoaderCallbackInterface.SUCCESS: { Log.i("OpenCV", "OpenCV loaded successfully"); System.loadLibrary(Core.NATIVE_LIBRARY_NAME); CascadeClassifier tt = new CascadeClassifier(); Mat imageMat=new Mat(); } break; default: { super.onManagerConnected(status); } break; } } }); } else { Log.v(TAG, "OpenCV loaded"); } /*DJISDKManager.getInstance().registerApp(MainActivity.this.getApplicationContext(), mDJISDKManagerCallback); while (hasRegistered == false) { System.out.println("No Registration Loop"); try { Thread.sleep(10000); } catch (Exception e) { } DJISDKManager.getInstance().registerApp(MainActivity.this.getApplicationContext(), mDJISDKManagerCallback); }*/ }
Example 18
Source File: MainActivity.java From open-quartz with Apache License 2.0 | 4 votes |
@Override public void onResume() { super.onResume(); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback); }
Example 19
Source File: ScanActivity.java From opencv-documentscanner-android with Apache License 2.0 | 4 votes |
@Override protected void onResume() { super.onResume(); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, this, mOpenCVCallBack); }
Example 20
Source File: Yolov3DrawRectTest.java From pasm-yolov3-Android with GNU General Public License v3.0 | 4 votes |
@Test public void drawImage() throws IOException { OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION, appContext, mLoaderCallback); YoloV3Classifier detector = (YoloV3Classifier) YoloV3Classifier.create( appContext.getAssets(), YOLO_MODEL_FILE, YOLO_INPUT_SIZE, YOLO_INPUT_NAME, YOLO_OUTPUT_NAMES, YOLO_BLOCK_SIZE, 1); checkPermissions(); // Bitmap loadedImage = getBitmapFromTestAssets(SAMPLE_IMG); Context testContext = InstrumentationRegistry.getInstrumentation().getContext(); AssetManager assetManager = testContext.getAssets(); String pathToImages = "images"; // String pathToImages = SAMPLE_IMG; // change pathToImages to this for single image String[] list = assetManager.list(pathToImages); for (int i = 0; i < list.length; i++) { if(list[i].endsWith(".jpg")) { Bitmap loadedImage = getBitmapFromTestAssets(list[i], pathToImages); Bitmap redimBitmap = Bitmap.createScaledBitmap(loadedImage, YOLO_INPUT_SIZE, YOLO_INPUT_SIZE, false); long start = System.currentTimeMillis(); List<Classifier.Recognition> recognitions = detector.recognizeImage(redimBitmap); long end = System.currentTimeMillis(); Log.i(TAG, "execution time = " + (end-start)); Log.i(TAG, "yolov3 recognitions = " + recognitions); ImageProcessor processor = new ImageProcessor(testContext, detector.getLabels()); processor.loadImage(loadedImage, YOLO_INPUT_SIZE, YOLO_INPUT_SIZE); Mat mat = processor.drawBoxes(recognitions, 0); Mat ultimate = new Mat(); Imgproc.cvtColor(mat, ultimate, Imgproc.COLOR_RGB2BGR); Imgcodecs.imwrite(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + "/yolo_v3/boxes" + i + ".jpg", ultimate); } } }