当前位置: 首页>>代码示例>>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;未经允许,请勿转载。