【问题标题】:How to donwload image to gallery after FACE DETECTED in Android?如何在 Android 中检测到人脸后将图像下载到图库?
【发布时间】:2020-07-02 21:56:11
【问题描述】:

我可以借助 Google 的示例视觉应用程序FaceTracker 检测人脸。我想要做的是拍摄检测到的面部照片并将其下载到手机图库。

【问题讨论】:

    标签: android android-camera face-detection


    【解决方案1】:
    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 );
    

    【讨论】:

    • 什么是imgCap?它显示错误。您能否修改此代码,使其在FaceTracker 应用程序上运行。
    • imgCap 是预览图片的变量。
    猜你喜欢
    • 2015-08-07
    • 2021-08-27
    • 2018-05-30
    • 2013-09-24
    • 2019-12-01
    • 2021-06-27
    • 2015-03-29
    • 2019-02-27
    • 2014-04-28
    相关资源
    最近更新 更多