hello all


i want to save caputured image from camera preview. i am using 

*https://github.com/googlesamples/android-vision/tree/master/visionSamples/FaceTracker*

*above app. i want to know how to use camerasource.takepicture method to save 
captured image from camera*



/*inside FaceTrackerActivity.java*/

*.*

*.*

*.*


final CameraSource.ShutterCallback shutterCallback = new 
CameraSource.ShutterCallback() {
    @Override
    public void onShutter() {
        Log.d(TAG, "onShutter");
        Toast.makeText(view.getContext(),"sd",Toast.LENGTH_SHORT).show();
    }
};
CameraSource.PictureCallback myPictureCallback_JPG = new 
CameraSource.PictureCallback(){
    @Override
    public void onPictureTaken(byte[] arg0) {
    // TODO Auto-generated method stub
    Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);

    //save file
    String path = Environment.DIRECTORY_DCIM.toString();
  
    OutputStream fOut = null;
    File file = new File(path, "FitnessGirl"+".jpg"); // the File to save to
    try{
        fOut = new FileOutputStream(file);
        bitmapPicture.compress(Bitmap.CompressFormat.JPEG, 85, fOut); // saving 
the Bitmap to a file compressed as a JPEG with 85% compression rate
        
MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
        fOut.flush();
        fOut.close(); // do not forget to close the stream

    }catch (FileNotFoundException exception){

    }catch (IOException e){

    }
    //save file
    }};

mCameraSource.takePicture(shutterCallback, myPictureCallback_JPG);

 
thanks in advance

mithun







-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/6ff64c40-a8ea-4961-815e-f64f7de17205%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to