Camera takePicture - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Camera takePicture method.

This code example shows how to use the following methods:release, stopPreview, takePicture, sleep
 
    /** 
     * Helper method for taking a photo 
     */ 
    public void capturePhoto() throws Exception { 
        mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
        Thread.sleep(WAIT_GENERIC);
        mCamera.stopPreview();
        mCamera.release();
    } 
 
    /** 
     * Helper method for cleaning up pics taken during tests 
     */ 
    public void cleanupTestImages() { 
        try { 
            File stressImagesDirectory = new File(String.format("%s/%s",
                    Environment.getExternalStorageDirectory(), CAMERA_STRESS_IMAGES_DIRECTORY));
            File[] stressImages = stressImagesDirectory.listFiles();
            for (File f : stressImages) {
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setPreviewCallback, setPreviewDisplay, startPreview, takePicture
 
    private void checkTakePicture() {  
        SurfaceHolder mSurfaceHolder;
        try { 
            mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
            mCamera.setPreviewDisplay(mSurfaceHolder);
            Log.v(TAG, "Start preview");
            mCamera.startPreview();
            waitForPreviewDone(); 
            mCamera.setPreviewCallback(null);
            mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
            waitForSnapshotDone(); 
        } catch (Exception e) {
            Log.v(TAG, e.toString());
        }       
    } 
     
    private void checkPreviewCallback() {  
        SurfaceHolder mSurfaceHolder;
        try { 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:takePicture
		 
		return(super.onKeyDown(keyCode, event));
	} 
	 
	private void takePicture() { 
		 camera.takePicture(null, null, photoCallback);
	} 
	 
	SurfaceHolder.Callback surfaceCallback=new SurfaceHolder.Callback() {
		public void surfaceCreated(SurfaceHolder holder) { 
			camera=Camera.open(); 
			 
			try { 
				camera.setPreviewDisplay(previewHolder); 
			} 
			catch (Throwable t) { 
				Log.e("Photographer", 
							"Exception in setPreviewDisplay()", t); 
				Toast 
					.makeText(Photographer.this, t.getMessage(), 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, takePicture
  public void takePicture(boolean needBitmap, boolean needByteArray) {
    if (inPreview) {
      this.needBitmap=needBitmap;
      this.needByteArray=needByteArray;
 
      previewParams=camera.getParameters();
 
      Camera.Parameters pictureParams=camera.getParameters();
      Camera.Size pictureSize=getHost().getPictureSize(pictureParams);
 
      pictureParams.setPictureSize(pictureSize.width,
                                   pictureSize.height);
      pictureParams.setPictureFormat(ImageFormat.JPEG);
      camera.setParameters(getHost().adjustPictureParameters(pictureParams));
 
      camera.takePicture(getHost().getShutterCallback(), null, this);
      inPreview=false;
    } 
  } 
 
  public boolean isRecording() { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:release, stopPreview, takePicture, sleep
 
    /** 
     * Helper method for taking a photo 
     */ 
    public void capturePhoto() throws Exception { 
        mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
        Thread.sleep(WAIT_GENERIC);
        mCamera.stopPreview();
        mCamera.release();
    } 
 
    /** 
     * Helper method for cleaning up pics taken during tests 
     */ 
    public void cleanupTestImages() { 
        try { 
            File stressImagesDirectory = new File(String.format("%s/%s",
                    Environment.getExternalStorageDirectory(), CAMERA_STRESS_IMAGES_DIRECTORY));
            File[] stressImages = stressImagesDirectory.listFiles();
            for (File f : stressImages) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:takePicture
			} 
		} 
	} 
 
	public void onClick(View view) {
		camera.takePicture(null, null,
				new PhotoHandler(getApplicationContext()));
	} 
 
	private int findFrontFacingCamera() { 
		int cameraId = -1;
		// Search for the front facing camera 
		int numberOfCameras = Camera.getNumberOfCameras();
		for (int i = 0; i < numberOfCameras; i++) {
			CameraInfo info = new CameraInfo();
			Camera.getCameraInfo(i, info);
			if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
				Log.d(DEBUG_TAG, "Camera found");
				cameraId = i;
				break; 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:takePicture
		mTextureView.setRotation(45.0f);
 
	} 
 
	public void onClick(View view) {
		camera.takePicture(null, null,
				new PhotoHandler(getApplicationContext()));
	} 
 
	private int findFirstFrontFacingCamera() { 
		int cameraId = -1;
		// search for the first front facing camera 
		int numberOfCameras = Camera.getNumberOfCameras();
		for (int i = 0; i < numberOfCameras; i++) {
			CameraInfo info = new CameraInfo();
			Camera.getCameraInfo(i, info);
			if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
				cameraId = i;
				break; 
			} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewDisplay, startPreview, takePicture
  } 
   
  // by jenn 
  private void takePicture() { 
	  if (inPreview) {
		  camera.takePicture(null, null, photoCallback);
		  inPreview=false;
		  createAlertDialog("Alert", "pictureTaken", "OK").show();
	  } else { 
	      initPreview(1196, 590); 
	      startPreview(); 
	      takePicture(); 
	  } 
  } 
 
  @Override 
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setPreviewCallback, setPreviewDisplay, startPreview, takePicture
 
    private void checkTakePicture() {  
        SurfaceHolder mSurfaceHolder;
        try { 
            mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
            mCamera.setPreviewDisplay(mSurfaceHolder);
            Log.v(TAG, "Start preview");
            mCamera.startPreview();
            waitForPreviewDone(); 
            mCamera.setPreviewCallback(null);
            mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
            waitForSnapshotDone(); 
        } catch (Exception e) {
            Log.v(TAG, e.toString());
        }       
    } 
     
    private void checkPreviewCallback() {  
        SurfaceHolder mSurfaceHolder;
        try { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewDisplay, startPreview, takePicture
 
		if (sCamera == null) {
			sCamera = Camera.open();
		} 
 
		Parameters params = sCamera.getParameters();
		params.setFlashMode(Parameters.FLASH_MODE_ON);
		params.setPictureFormat(PixelFormat.JPEG);
		sCamera.setParameters(params);
 
		try { 
			sCamera.setPreviewDisplay(MainActivity.surfaceview.getHolder());
		} catch (IOException e) {
			// FIXME Auto-generated catch block 
			e.printStackTrace();
		} 
		sCamera.startPreview();
 
		Camera.ShutterCallback cb = new Camera.ShutterCallback() {
			public void onShutter() { 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Camera takePicture Questions & Answers:

Other Camera takePicture Examples

37:	
38:	  public void onClick(View view) {
39:	    camera.takePicture(null, null,
40:	        new PhotoHandler(getApplicationContext()));
41:	  }

Read More

takePicture Method Overview
Equivalent to takePicture(shutter, raw, null, jpeg).
See Code Examples for other Android Camera Methods: