本文整理汇总了Java中com.google.android.gms.vision.face.FaceDetector.setProcessor方法的典型用法代码示例。如果您正苦于以下问题:Java FaceDetector.setProcessor方法的具体用法?Java FaceDetector.setProcessor怎么用?Java FaceDetector.setProcessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.vision.face.FaceDetector
的用法示例。
在下文中一共展示了FaceDetector.setProcessor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
private void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = createFaceDetector(context);
detector.setProcessor(new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build());
if (!detector.isOperational()) {
Timber.d("Face detector dependencies are not yet available.");
}
cameraSource = new CameraSource.Builder(context, detector) //
// Camera will decide actual size, and we'll crop accordingly in layout.
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(MAX_FRAME_RATE)
.setAutoFocusEnabled(true)
.build();
}
示例2: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* 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.
*/
private void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.setLandmarkType(FaceDetector.ALL_LANDMARKS)
.setMode(FaceDetector.ACCURATE_MODE)
.build();
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory())
.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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
}
示例3: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* Creates and starts the camera. Note that this uses a higher resolution in comparison
* to other detection examples to enable the ocr detector to detect small text samples
* at long distances.
* <p>
* Suppressing InlinedApi since there is a check that the minimum version is met before using
* the constant.
*/
@SuppressLint("InlinedApi")
private void createCameraSource(boolean autoFocus, boolean useFlash) {
Context context = getApplicationContext();
// A text recognizer is created to find text. An associated multi-processor instance
// is set to receive the text recognition results, track the text, and maintain
// graphics for each text block on screen. The factory is used by the multi-processor to
// create a separate tracker instance for each text block.
textRecognizer = new TextRecognizer.Builder(context).build();
textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay, this));
// A face detector is created to track faces. An associated multi-processor instance
// is set to receive the face detection results, track the faces, and maintain graphics for
// each face on screen. The factory is used by the multi-processor to create a separate
// tracker instance for each face.
FaceDetector faceDetector = new FaceDetector.Builder(context).build();
FaceTrackerFactory faceFactory = new FaceTrackerFactory(mGraphicOverlay, this);
faceDetector.setProcessor(
new MultiProcessor.Builder<>(faceFactory).build());
// A multi-detector groups the two detectors together as one detector. All images received
// by this detector from the camera will be sent to each of the underlying detectors, which
// will each do face and barcode detection, respectively. The detection results from each
// are then sent to associated tracker instances which maintain per-item graphics on the
// screen.
multiDetector = new MultiDetector.Builder()
.add(faceDetector)
.add(textRecognizer)
.build();
if (!multiDetector.isOperational()) {
Log.w(TAG, "Detector dependencies are not yet available.");
// Check for low storage. If there is low storage, the native library will not be
// downloaded, so detection will not become operational.
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
if (hasLowStorage) {
Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
Log.w(TAG, getString(R.string.low_storage_error));
}
}
// Creates and starts the camera. Note that this uses a higher resolution in comparison
// to other detection examples to enable the text recognizer to detect small pieces of text.
mCameraSource =
new CameraSource.Builder(getApplicationContext(), multiDetector)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1600, 1024)
.setRequestedFps(2.0f)
.setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
.setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null)
.build();
}
示例4: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* 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.
*/
private void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory())
.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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedFps(30.0f)
.build();
}
示例5: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
public void createCameraSource(GraphicOverlay overlay) {
mGraphicOverlay = overlay;
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory())
.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.");
}
mCameraSourceBack = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(1980, 1080)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedFps(30.0f)
.build();
mCameraSourceFront = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(1980, 1080)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
}
示例6: setupFaceTracker
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* Setup the face tracker
*/
private void setupFaceTracker(){
//Move on to Face graphic overlay
try {
faceTracker = new FaceTrackerWithGraphic(graphic_face_overlay, this);
FaceDetector detector = new FaceDetector.Builder(this)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
detector.setProcessor(faceTracker.buildDetector());
} catch (Exception e){
e.printStackTrace();
}
}
示例7: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* 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.
*/
private void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.setProminentFaceOnly(true)
.build();
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory())
.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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
}
示例8: onCreateView
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_face_tracking, container, false);
mPreview = (CameraSourcePreview) view.findViewById(R.id.preview);
mGraphicOverlay = (GraphicOverlay) view.findViewById(R.id.faceOverlay);
Context context = getActivity().getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context).build();
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
// .setRequestedPreviewSize(640, 480)
// .setFacing(CameraSource.CAMERA_FACING_BACK)
// .setRequestedFps(30.0f)
.build();
return view;
}
示例9: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
public void createCameraSource() {
//Setup the FaceDetector
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
.setProminentFaceOnly(true) //track only one face... makes it faster.
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) //allows for eye and smile detection!
.build();
detector.setProcessor(
new LargestFaceFocusingProcessor(detector, new FaceTracker()));
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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
}
示例10: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
public void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
//.setProminentFaceOnly(true) //track only one face... makes it faster.
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) //allows for eye and smile detection!
.build();
detector.setProcessor(
//new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build());
new LargestFaceFocusingProcessor(detector, new GraphicFaceTracker(mGraphicOverlay)));
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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
}
示例11: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
public void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
//.setProminentFaceOnly(true) //track only one face... makes it faster.
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) //allows for eye and smile detection!
.build();
//set it up to easily handle more then one face at a time, via the multi processor class.
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build());
//new LargestFaceFocusingProcessor(detector,new GraphicFaceTracker(mGraphicOverlay)));
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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
//.setFacing(CameraSource.CAMERA_FACING_BACK)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
}
示例12: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* 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.
*/
private void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory())
.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.");
}
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
}
示例13: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* 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.
*/
private void createCameraSource() {
Context context = getApplicationContext();
// A face detector is created to track faces. An associated multi-processor instance
// is set to receive the face detection results, track the faces, and maintain graphics for
// each face on screen. The factory is used by the multi-processor to create a separate
// tracker instance for each face.
FaceDetector faceDetector = new FaceDetector.Builder(context).build();
FaceTrackerFactory faceFactory = new FaceTrackerFactory(mGraphicOverlay);
faceDetector.setProcessor(
new MultiProcessor.Builder<>(faceFactory).build());
// 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();
BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay);
barcodeDetector.setProcessor(
new MultiProcessor.Builder<>(barcodeFactory).build());
// A multi-detector groups the two detectors together as one detector. All images received
// by this detector from the camera will be sent to each of the underlying detectors, which
// will each do face and barcode detection, respectively. The detection results from each
// are then sent to associated tracker instances which maintain per-item graphics on the
// screen.
MultiDetector multiDetector = new MultiDetector.Builder()
.add(faceDetector)
.add(barcodeDetector)
.build();
if (!multiDetector.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.");
// Check for low storage. If there is low storage, the native library will not be
// downloaded, so detection will not become operational.
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
if (hasLowStorage) {
Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
Log.w(TAG, getString(R.string.low_storage_error));
}
}
// 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.
mCameraSource = new CameraSource.Builder(getApplicationContext(), multiDetector)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1600, 1024)
.setRequestedFps(15.0f)
.build();
}
示例14: createCameraSource
import com.google.android.gms.vision.face.FaceDetector; //导入方法依赖的package包/类
/**
* 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.
*/
private void createCameraSource() {
Context context = mContextWeakReference.get();
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
detector.setProcessor(new Detector.Processor<Face>() {
@Override
public void release() {
}
@Override
public void receiveDetections(final Detector.Detections<Face> detections) {
final SparseArray<Face> detectedItems = detections.getDetectedItems();
if (detectedItems.size() != 0) {
final int key = detectedItems.keyAt(0);
final Face face = detectedItems.get(key);
final float isSmilingProbability = face.getIsSmilingProbability();
String feedback = getFeedbackForSmileProbability(isSmilingProbability);
mCallBacks.onShouldGivePositiveAffirmation(feedback);
}
}
});
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.");
}
try {
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
mCameraSource.start();
} catch (IOException | RuntimeException e) {
Log.e(TAG, "Something went horribly wrong, with your face.", e);
}
}