當前位置: 首頁>>代碼示例>>Java>>正文


Java BaseLoaderCallback類代碼示例

本文整理匯總了Java中org.opencv.android.BaseLoaderCallback的典型用法代碼示例。如果您正苦於以下問題:Java BaseLoaderCallback類的具體用法?Java BaseLoaderCallback怎麽用?Java BaseLoaderCallback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BaseLoaderCallback類屬於org.opencv.android包,在下文中一共展示了BaseLoaderCallback類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: RNScanDocModule

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
public RNScanDocModule(ReactApplicationContext reactContext) {
  super(reactContext);
  this.mReactContext = reactContext;
  mOpenCVCallBack = new BaseLoaderCallback(getCurrentActivity()) {
    @Override
    public void onManagerConnected(int status) {
      switch (status) {
        case LoaderCallbackInterface.SUCCESS:
        {
          rgbMat = new Mat();
          grayMat = new Mat();
          cannyMat = new Mat();
          linesMat = new Mat();
          Log.d(TAG, "OpenCV loaded success");
        } break;
        default:
        {
          super.onManagerConnected(status);
        } break;
      }
    }
  };
}
 
開發者ID:beast,項目名稱:react-native-scan-doc,代碼行數:24,代碼來源:RNScanDocModule.java

示例2: configOpenCv

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:davidmigloz,項目名稱:go-bees,代碼行數:21,代碼來源:MonitoringService.java

示例3: getLoader

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
public BaseLoaderCallback getLoader(final Context context, final CameraBridgeViewBase openCvCameraView) {
    return new BaseLoaderCallback(context) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                    Log.i(TAG, "OpenCV loaded successfully");
                    try {
                        /** load face classificator */
                        File cascadeFileFace = FileHelper.readCascadeFile(context,
                                R.raw.haarcascade_frontalface_alt2,
                                "cascade", "haarcascade_front.xml");
                        detectorFace = initializeJavaDetector(cascadeFileFace);
                        cascadeFileFace.delete();
                        /** load eye classificator */
                        File cascadeFileEye = FileHelper.readCascadeFile(context,
                                R.raw.haarcascade_eye_tree_eyeglasses,
                                "cascadeER", "haarcascade_eye.xml");
                        detectorEye = initializeJavaDetector(cascadeFileEye);
                        cascadeFileEye.delete();
                        setMachineLearningMechanism();
                    } catch (IOException e) {
                        e.printStackTrace();
                        Log.e(TAG, "Failed to load cascade. Exception thrown: " + e);
                    }

                    setCameraParameters(openCvCameraView);

                    break;
                default:
                    super.onManagerConnected(status);
                    break;
            }
        }
    };
}
 
開發者ID:raulh82vlc,項目名稱:Image-Detection-Samples,代碼行數:37,代碼來源:FDOpenCVPresenter.java

示例4: init

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
protected void init() {
    addAccessibilityServiceDelegates();
    registerActivityLifecycleCallbacks();
    InputEventObserver.initGlobal(mContext);
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_13, mContext, new BaseLoaderCallback(mContext) {
    });
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:8,代碼來源:AutoJs.java

示例5: onActivityCreated

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);

	/// Must wait until OpenCV is initialized before loading the tours (since we load image descriptors).
	BaseLoaderCallback _loader_callback = new BaseLoaderCallback(getActivity()) {
		@Override
		public void onManagerConnected(int status) {
			switch (status) {
				case LoaderCallbackInterface.SUCCESS:
				{
					Log.i(TAG, "OpenCV loaded successfully");

					/// Add footer so the floating action button doesn't cover up the list.
					_adapter = new TourAdapter(Tour.getTours(getActivity()));
					WrapAdapter wrap_adapter = new WrapAdapter(_adapter);
					wrap_adapter.addFooter(getActivity().getLayoutInflater().inflate(R.layout.empty_list_footer, _recycler_view, false));
					_recycler_view.setAdapter(wrap_adapter);
				} break;
				default:
				{
					super.onManagerConnected(status);
				} break;
			}
		}
	};

	_recycler_view = (RecyclerView) getActivity().findViewById(R.id.recycler_view);
	OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, getActivity(), _loader_callback);
	_recycler_view.setLayoutManager(new LinearLayoutManager(getActivity()));

	getActivity().findViewById(R.id.fab).setOnClickListener(this);
	getActivity().findViewById(R.id.help_button).setOnClickListener(this);
}
 
開發者ID:WriterOfAlicrow,項目名稱:OpenCVTour,代碼行數:35,代碼來源:TourListFragment.java

示例6: initialize

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    activity = cordova.getActivity();

    super.initialize(cordova, webView);

    mLoaderCallback = new BaseLoaderCallback(activity) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                    Log.i(TAG, "OpenCV loaded successfully");
                } break;
                default:
                {
                    super.onManagerConnected(status);
                } break;
            }
        }
    };

    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    activity.getWindow().setFormat(PixelFormat.TRANSLUCENT);
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    SurfaceView surfaceView = new SurfaceView(activity.getApplicationContext());

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT,
            Gravity.CENTER);

    cameraFrameLayout = new FrameLayout(activity.getApplicationContext());

    cameraFrameLayout.addView(surfaceView);

    activity.getWindow().addContentView(cameraFrameLayout, params);

    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);

    sendViewToBack(cameraFrameLayout);

    setCameraIndex(CAMERA_ID_BACK);
    openCamera();

    cameraFrameLayout.setVisibility(View.INVISIBLE);
}
 
開發者ID:Cloudoki,項目名稱:ImageDetectionCordovaPlugin,代碼行數:51,代碼來源:ImageDetectionPlugin.java

示例7: initialize

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
public static void initialize(Context context){
	mContext = context;
	faceDataSource = new FacesDataSource(context);
	mLoaderCallback = new BaseLoaderCallback(context) {
        @Override
        public void onManagerConnected(int status) {
        	System.out.println("---------------------------- status: "+status);
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                	
            		new Thread(new Runnable() {
            			
            			@Override
            			public void run() {
            				System.loadLibrary("native_camera_r2.2.0");
            				System.loadLibrary("native_camera_r2.3.3");
            				System.loadLibrary("native_camera_r3.0.1");
            				System.loadLibrary("native_camera_r4.0.0");
            				System.loadLibrary("native_camera_r4.0.3");
            				System.loadLibrary("native_camera_r4.1.1");
            				System.loadLibrary("native_camera_r4.2.0");
            				System.loadLibrary("opencv_java");
            				System.loadLibrary("detection_and_recognition_lib");
            				loadCascadeFiles();
            				cascadeFilesLoaded = true;
            			}
            		}).start();
                } break;
                default:
                {
                    super.onManagerConnected(status);
                } break;
            }
        }
        
        @Override
        public void onPackageInstall(int operation,
        		InstallCallbackInterface callback) {
        	System.out.println("---------------------------------------- onPackageInstall");
        	//super.onPackageInstall(operation, callback);
        	/*System.loadLibrary("native_camera_r2.2.0");
System.loadLibrary("native_camera_r2.3.3");
System.loadLibrary("native_camera_r3.0.1");
System.loadLibrary("native_camera_r4.0.0");
System.loadLibrary("native_camera_r4.0.3");
System.loadLibrary("native_camera_r4.1.1");*/
System.loadLibrary("native_camera_r4.2.0");
System.loadLibrary("opencv_java");
System.loadLibrary("detection_and_recognition_lib");
loadCascadeFiles();
cascadeFilesLoaded = true;
        }
    };
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, context.getApplicationContext(), mLoaderCallback);
}
 
開發者ID:yaylas,項目名稱:AndroidFaceRecognizer,代碼行數:57,代碼來源:FaceDetectionUtils.java

示例8: onCreate

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager()
			.findFragmentById(R.id.navigation_drawer);
	mTitle = getTitle();

	// Set up the navigation drawer.
	mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
			(DrawerLayout) findViewById(R.id.drawer_layout));
	// Setup loader callbacks
	mLoaderCallbacks = new BaseLoaderCallback(this) {
		@Override
		public void onManagerConnected(int status) {
			switch (status) {
			// Open CV loaded succesfully
			case LoaderCallbackInterface.SUCCESS: {
				MainActivity.this.runOnUiThread(new Runnable() {
					@Override
					public void run() {
						Toast.makeText(MainActivity.this,
								"OpenCV library is loaded",
								Toast.LENGTH_SHORT).show();
					}
				});
				break;
			}
			// Open CV failed to load
			case LoaderCallbackInterface.INIT_FAILED: {
				MainActivity.this.runOnUiThread(new Runnable() {
					@Override
					public void run() {
						Toast.makeText(MainActivity.this,
								"Could not load OpenCV", Toast.LENGTH_SHORT)
								.show();
					}
				});
				break;
			}

			default: {
				super.onManagerConnected(status);
				break;
			}
			}
		}
	};
	// Initialize OpenCv library
	OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this,
			mLoaderCallbacks);
}
 
開發者ID:centosGit,項目名稱:EyeDroid,代碼行數:54,代碼來源:MainActivity.java

示例9: onResume

import org.opencv.android.BaseLoaderCallback; //導入依賴的package包/類
public void onResume(final Context pContext, final IOnLoaded pIOnLoaded) {
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, pContext, new BaseLoaderCallback(pContext) {
                @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("detection_based_tracker");

                            try {
                                // load cascade file from application resources
                                InputStream is = pContext.getResources().openRawResource(R.raw.lbpcascade_frontalface);
                                File cascadeDir = pContext.getDir("cascade", Context.MODE_PRIVATE);
                                File mCascadeFile = new File(cascadeDir, "lbpcascade_frontalface.xml");
                                FileOutputStream os = new FileOutputStream(mCascadeFile);

                                byte[] buffer = new byte[4096];
                                int bytesRead;
                                while ((bytesRead = is.read(buffer)) != -1) {
                                    os.write(buffer, 0, bytesRead);
                                }
                                is.close();
                                os.close();

                                mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0);

                                cascadeDir.delete();

                            } catch (IOException e) {
                                e.printStackTrace();
                                Log.e(TAG, "Failed to load cascade. Exception thrown: " + e);
                            }
                        }
                        break;
                        default: {
                            super.onManagerConnected(status);
                        }

                        break;
                    }
                    pIOnLoaded.onLoaded();
                }
            }
    );
}
 
開發者ID:fblandroidhackathon,項目名稱:persontracker,代碼行數:48,代碼來源:FaceDetector.java


注:本文中的org.opencv.android.BaseLoaderCallback類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。