Back to project page compCellScope.
The source code is released under:
MIT License
If you think the Android project compCellScope listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.wallerlab.compcellscope; /*w w w . j a v a2s.c om*/ import android.app.Activity; import android.content.pm.ActivityInfo; import android.hardware.Camera; import android.hardware.Camera.CameraInfo; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.FrameLayout; public class BurstModeActivity extends Activity { private AcquireSurfaceView mPreview; private Camera mCamera; private Button mCapture; private int capture_counter, delay; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_burst_mode); //set # of images you want and delay between each image capture_counter = 5; delay = 5000; // Get the instance of Camera mCamera = getCameraInstance(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR | ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // access camera Parameters final Camera.Parameters camParams = mCamera.getParameters(); //set color efects to none camParams.setColorEffect(Camera.Parameters.EFFECT_NONE); //set antibanding to none if (camParams.getAntibanding() != null) { camParams.setAntibanding(Camera.Parameters.ANTIBANDING_OFF); } // set white ballance if (camParams.getWhiteBalance() != null) { camParams.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT); } // Get camera ID of rear camera int cameraId = -1; 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_BACK) { //Log.d(TAG, "Camera found"); cameraId = i; break; } } Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); if (info.canDisableShutterSound) { mCamera.enableShutterSound(false); } // Create our Preview view and set it as the content of our activity. mPreview = new AcquireSurfaceView(this, mCamera); FrameLayout preview = (FrameLayout) findViewById(R.id.camera_perp); preview.addView(mPreview); mCapture= (Button) findViewById(R.id.burst_capture); mCapture.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { final Handler handler = new Handler(); handler.post(new Runnable() { @Override public void run() { Log.d("Burst", "Picture Being Taken"); mPreview.previewCallback(); handler.postDelayed(this, 200); capture_counter--; if(capture_counter == 0){ handler.removeMessages(0); } } }); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.burst_mode, menu); return true; } public static Camera getCameraInstance(){ Camera c = null; try { c = Camera.open(); // attempt to get a Camera instance } catch (Exception e){ // Camera is not available (in use or does not exist) } return c; // returns null if camera is unavailable } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }