我正在實施google-vision face tracker中給出的示例。 MyFaceDetector
類:來自CameraSource的裁剪面
public class MyFaceDetector extends Detector<Face> {
private Detector<Face> mDelegate;
MyFaceDetector(Detector<Face> delegate) {
mDelegate = delegate;
}
public SparseArray<Face> detect(Frame frame) {
return mDelegate.detect(frame);
}
public boolean isOperational() {
return mDelegate.isOperational();
}
public boolean setFocus(int id) {
return mDelegate.setFocus(id);
}
}
FaceTrackerActivity
類:
private void createCameraSource() {
imageView = (ImageView) findViewById(R.id.face);
FaceDetector faceDetector = new FaceDetector.Builder(this).build();
myFaceDetector = new MyFaceDetector(faceDetector);
myFaceDetector.setProcessor(new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory())
.build());
mCameraSource = new CameraSource.Builder(this, myFaceDetector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(60.0f)
.build();
if (!myFaceDetector.isOperational()) {
Log.w(TAG, "Face detector dependencies are not yet available.");
}
}
我需要裁剪的臉,把它放在ImageView
。我無法在這裏實現我的自定義Frame
。 frame.getBitmap()
總是在detect(Frame frame)
中返回null
。我如何實現這一目標?
看吧https://stackoverflow.com/questions/32299947/mobile-vision-api-concatenate-new-detector-object-to-continue-frame-processing/ 32314136#32314136 – George