googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.93k stars 1.73k forks source link

screen shot not working #203

Open mithunkumarc opened 7 years ago

mithunkumarc commented 7 years ago

After tracking while saving image , only overlay mask image is saved but background appear blackscreen. How to save image tracked face with mask image together? I am using below code to save tracked image.

        Date now = new Date();
        android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);

        try {
            // image naming and path  to include sd card  appending name you choose for file
            String mPath = Environment.getExternalStorageDirectory().toString() +                      "/Pictures/Screenshots/" + now + ".jpg";

            View v1 = view.getRootView();
            v1.setDrawingCacheEnabled(true);
            Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
            v1.setDrawingCacheEnabled(false);
            File imageFile = new File(mPath);
            FileOutputStream outputStream = new FileOutputStream(imageFile);
            int quality = 100;
            bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
            outputStream.flush();
            outputStream.close();

            MediaScannerConnection.scanFile(this,
                    new String[]{imageFile.toString()}, null,
                    new MediaScannerConnection.OnScanCompletedListener() {
                        public void onScanCompleted(String path, Uri uri) {
                            Log.i("ExternalStorage", "Scanned " + path + ":");
                            Log.i("ExternalStorage", "-> uri=" + uri);
                        }
                    });

        } catch (Throwable e) {
            // Several error may come out with file handling or OOM
            e.printStackTrace();
        } 
jibinjoseph commented 7 years ago

Any solution ?

mithunkumarc commented 7 years ago

@jibinjoseph not yet found

josharry133 commented 7 years ago

Not yet

kimpoytoledo commented 7 years ago

any solution?