本文整理匯總了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;
}
}
};
}
示例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);
}
示例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;
}
}
};
}
示例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) {
});
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
);
}