Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. for(int m = 0 ; m < 6; m++) {
  2.  
  3. mPrimCamera.takePicture(null, mPictureCallbackMet, mPictureCallbackMet);
  4. }
  5.  
  6. private void takePhoto() {
  7. if (!(cameraPreview.isRunning())) {
  8. Log.i(LOG_TAG, "Camera is not ready. Skip frame");
  9. return;
  10. }
  11.  
  12. camera.takePicture(null, null, this);
  13. cameraPreview.onPictureTook();
  14. }
  15.  
  16. public void onPictureTaken(byte[] data, Camera camera) {
  17. // save photo
  18. cameraPreview.start();
  19. }
  20.  
  21.  
  22. public class CameraPreview extends SurfaceView {
  23.  
  24. private boolean previewRunning = false;
  25.  
  26. /**
  27. * Should be called after calling camera.takePicture
  28. */
  29. public void onPictureTook() {
  30. previewRunning = false;
  31. }
  32.  
  33. public boolean isRunning() {
  34. return previewRunning;
  35. }
  36.  
  37. public void start() {
  38. try {
  39. camera.setPreviewDisplay(surfaceHolder);
  40. camera.startPreview();
  41. previewRunning = true;
  42. } catch (Exception ignored) {
  43. Log.e(LOG_TAG, "Error starting camera preview", ignored);
  44. }
  45. }
  46. }
  47.  
  48. private class CaptureThread extends Thread {
  49.  
  50. @Override
  51. public void run() {
  52.  
  53. int count = 0;
  54.  
  55. while(count < mNo) {
  56. mFileName = mLocation + "/pic" + count + ".jpg";
  57.  
  58. mCamera.takePicture(null, mPictureCallback, mPictureCallback);
  59.  
  60. count++;
  61.  
  62. try {
  63. Thread.sleep(3000);
  64. } catch (InterruptedException exception) {
  65. exception.printStackTrace();
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement