如何在 Android 中检测到人脸后将图像下载到图库?
How to donwload image to gallery after FACE DETECTED in Android?
我可以借助 Google 的示例视觉应用程序 FaceTracker 检测人脸。我想要做的是拍摄检测到的面部照片并将其下载到 phone 图库。
File imagesFolder = new File( Environment.getExternalStorageDirectory() , "FolderName" );
imagesFolder.mkdirs();
final File image = new File( imagesFolder , "/" + "IMG_" +System.currentTimeMillis() + ".png" );
File file = new File( Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".png");
imgCap.takePicture(image, new ImageCapture.OnImageSavedListener() {
@Override
public void onImageSaved(@NonNull File file) {
String msg = "Pic captured at " + image.getAbsolutePath();
//storing the image in a folder in gallery
Intent mediaScanIntent = new Intent( Intent.ACTION_MEDIA_SCANNER_SCAN_FILE );
Uri contentUri = Uri.fromFile( image );
mediaScanIntent.setData( contentUri );
getActivity().sendBroadcast( mediaScanIntent );
我可以借助 Google 的示例视觉应用程序 FaceTracker 检测人脸。我想要做的是拍摄检测到的面部照片并将其下载到 phone 图库。
File imagesFolder = new File( Environment.getExternalStorageDirectory() , "FolderName" );
imagesFolder.mkdirs();
final File image = new File( imagesFolder , "/" + "IMG_" +System.currentTimeMillis() + ".png" );
File file = new File( Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".png");
imgCap.takePicture(image, new ImageCapture.OnImageSavedListener() {
@Override
public void onImageSaved(@NonNull File file) {
String msg = "Pic captured at " + image.getAbsolutePath();
//storing the image in a folder in gallery
Intent mediaScanIntent = new Intent( Intent.ACTION_MEDIA_SCANNER_SCAN_FILE );
Uri contentUri = Uri.fromFile( image );
mediaScanIntent.setData( contentUri );
getActivity().sendBroadcast( mediaScanIntent );