簡體   English   中英

在Android中檢測到面部后如何將圖像下載到圖庫?

[英]How to donwload image to gallery after FACE DETECTED in Android?

我可以借助 Google 的示例視覺應用FaceTracker檢測人臉。 我想要做的是拍攝檢測到的人臉照片並將其下載到手機圖庫。

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 );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM