Skip to main content

Posts

Showing posts with the label Camera sample program

Camera without preview in android

Camera sample program without preview/How to take photo without a preview in android program package  com.sample import  java.io.FileNotFoundException; import  java.io.FileOutputStream; import  java.io.IOException; import  android.app.Activity; import  android.graphics.Bitmap; import  android.graphics.BitmapFactory; import  android.hardware.Camera; import  android.hardware.Camera.Parameters; import  android.os. Bundle ; import  android.util.Log; import  android.view.SurfaceHolder; import  android.view.SurfaceView; import  android.widget.ImageView; public   class  TakePicture  extends  Activity  implements  SurfaceHolder.Callback {        //a variable to store a reference to the Image View at the main.xml file        private  ImageView  iv_image ;        //a variable to store a reference to the Surface View at the main.xml file      private  SurfaceView  sv ;          //a bitmap to display the captured image        private  Bitmap  bmp ;              //Camera variables        //a surfac

Open front camera in android program

How to access front camera in android/get number of cameras in android/Program to open front camera in android Using the code explained below, we can easily find out number of cameras in your android device. Camera.CameraInfo cameraInfo = new Camera.CameraInfo();         Log. d ( "No of cameras" ,Camera. getNumberOfCameras ()+ "" );         for ( int camNo = 0; camNo < Camera. getNumberOfCameras (); camNo++) {             CameraInfo camInfo = new CameraInfo();             Camera. getCameraInfo (camNo, camInfo);                         if (camInfo. facing ==(Camera.CameraInfo. CAMERA_FACING_FRONT )) {                 mCamera = Camera. open (camNo);             }         }         if ( mCamera == null ) {            // no front-facing camera, use the first back-facing camera instead.            // you may instead wish to inform the user of an error here...               mCamera = Camera. open ();         } A sample program that take photo using front camer