【发布时间】:2018-04-07 03:40:23
【问题描述】:
人脸检测找到我的脸,然后在 3 秒后圆圈消失。只发生在某些手机上,所以我不确定它为什么会发生。我的代码非常样板:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detect);
detector = new FaceDetector.Builder(getApplicationContext())
.setTrackingEnabled(false)
.setProminentFaceOnly(true)
.setMode(FaceDetector.FAST_MODE)
.setMinFaceSize((float) 0.60)
.setLandmarkType(FaceDetector.ALL_CLASSIFICATIONS)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
initViews();
}
private void initViews() {
imgTakePicture = (ImageView) findViewById(R.id.imgTakePic);
btnTakePicture = (Button) findViewById(R.id.btnTakePicture);
txtSampleDesc = (TextView) findViewById(R.id.txtSampleDescription);
txtTakenPicDesc = (TextView) findViewById(R.id.textView);
btnTakePicture.setOnClickListener(this);
imgTakePicture.setOnClickListener(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult: this is resyult");
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
launchMediaScanIntent();
try {
processCameraPicture();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Failed to load Image", Toast.LENGTH_SHORT).show();
}
}
}
private void launchMediaScanIntent() {
Log.d(TAG, "launchMediaScanIntent: ");
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
mediaScanIntent.setData(imageUri);
this.sendBroadcast(mediaScanIntent);
}
private void startCamera() {
Log.d(TAG, "startCamera: ");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Log.d(TAG, "startCamera: 2");
File photo = new File(Environment.getExternalStorageDirectory(), "/videoDIARY/ReferencePic/photo.jpg");
imageUri = Uri.fromFile(photo);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAMERA_REQUEST);
}
编辑:好的,我发现这完全是关于设备方向的。在横向模式下的所有设备上都可以正常工作,仅在纵向模式下的某些设备上工作。仍在尝试找出原因,我会在修复时更新!
【问题讨论】:
-
手机有什么区别?性能、Android版本等?
-
@MaximTsybanov,它适用于我的 Moto G5 Plus,andorid 版本 7.0,它适用于 HTC 6.0,但不适用于混合了 5.0、5.1、6.0 和 6.1 的三星或 Lg。它似乎更多地与手机面部检测或 Google Play 视觉相关,因为我注意到它在这些手机上的常规相机应用程序中做同样的事情。
标签: android google-play-services face-detection google-vision