本文整理匯總了Java中com.google.android.gms.vision.CameraSource.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java CameraSource.Builder方法的具體用法?Java CameraSource.Builder怎麽用?Java CameraSource.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.vision.CameraSource
的用法示例。
在下文中一共展示了CameraSource.Builder方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createCameraSource
import com.google.android.gms.vision.CameraSource; //導入方法依賴的package包/類
public void createCameraSource() {
//Setup the BarCodeDetector
Context context = getApplicationContext();
BarcodeDetector detector = new BarcodeDetector.Builder(context)
.build();
//note the barcodeTrackerFactory is defined below and is very simple.
detector.setProcessor(new MultiProcessor.Builder<>(new BarcodeTrackFactory()).build());
if (!detector.isOperational()) {
// Note: The first time that an app using face API is installed on a device, GMS will
// download a native library to the device in order to do detection. Usually this
// completes before the app is run for the first time. But if that download has not yet
// completed, then the above call will not detect any faces.
//
// isOperational() can be used to check if the required native library is currently
// available. The detector will automatically become operational once the library
// download completes on device.
Log.w(TAG, "Face detector dependencies are not yet available.");
}
// Creates and starts the camera. Note that this uses a higher resolution in comparison
// to other detection examples to enable the barcode detector to detect small barcodes
// at long distances.
CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), detector)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1600, 1024)
.setRequestedFps(15.0f);
builder = builder.setAutoFocusEnabled(true);
mCameraSource = builder.build();
}
示例2: createCameraSource
import com.google.android.gms.vision.CameraSource; //導入方法依賴的package包/類
private void createCameraSource() {
Context context = getActivity().getApplicationContext();
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
getActivity());
if (code != ConnectionResult.SUCCESS) {
GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), code, 100).show();
} else {
// A barcode detector is created to track barcodes. An associated multi-processor instance
// is set to receive the barcode detection results, track the barcodes, and maintain
// graphics for each barcode on screen. The factory is used by the multi-processor to
// create a separate tracker instance for each barcode.
BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
processor = new PandroidScannerView.SimpleProcessor() {
@Override
public boolean handleBarcode(Barcode barcode) {
toastManager.makeToast(getActivity(), "Detected: " + barcode.displayValue, new ToastManager.ToastListener() {
@Override
public void onDismiss() {
processor.resumeDetector();
}
@Override
public void onActionClicked() {
}
});
return true;
}
};
barcodeDetector.setProcessor(processor);
if (!barcodeDetector.isOperational()) {
// Note: The first time that an app using the barcode or face API is installed on a
// device, GMS will download a native libraries to the device in order to do detection.
// Usually this completes before the app is run for the first time. But if that
// download has not yet completed, then the above call will not detect any barcodes
// and/or faces.
//
// isOperational() can be used to check if the required native libraries are currently
// available. The detectors will automatically become operational once the library
// downloads complete on device.
Log.w(TAG, "Detector dependencies are not yet available.");
}
// Creates and starts the camera. Note that this uses a higher resolution in comparison
// to other detection examples to enable the barcode detector to detect small barcodes
// at long distances.
CameraSource.Builder builder = new CameraSource.Builder(context, barcodeDetector)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1600, 1024)
.setRequestedFps(30.0f)
.setAutoFocusEnabled(true);
mCameraSource = builder.build();
}
}