I'm working on a project that I need to save the camera picture based on a face detection. the part of face detection is done based on google examples but the problem is in saving the CameraSourcePreview into a jpg file. I am only able to save overlay of camera feed with a black background!
my mainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<com.google.android.gms.samples.vision.face.facetracker.ui.camera.CameraSourcePreview
android:id="@+id/preview"
android:drawingCacheQuality="auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.samples.vision.face.facetracker.ui.camera.GraphicOverlay
android:id="@+id/faceOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.gms.samples.vision.face.facetracker.ui.camera.CameraSourcePreview>
</LinearLayout>
my code for saving:
CameraSourcePreview csp
csp.setDrawingCacheEnabled(true);
File f = new File(Environment.getExternalStorageDirectory().getPath()+"/" + currentTime.toString() + ".jpg");
Bitmap bmp = Bitmap.createBitmap(csp.getDrawingCache());
csp.setDrawingCacheEnabled(false);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(f));
lastPic = currentTime.getTime();
where is the problem? is it because the overlay is infront of the camera feed? how can i make black pixels transparetn?
edit:
the differnce between my case and other questions is that i want to save the real time pic not the taken image. this question is not repeated. my clear question is where is camera picture that i can see in the screen? why it did not save in jpg file?