Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(int m = 0 ; m < 6; m++) {
- mPrimCamera.takePicture(null, mPictureCallbackMet, mPictureCallbackMet);
- }
- private void takePhoto() {
- if (!(cameraPreview.isRunning())) {
- Log.i(LOG_TAG, "Camera is not ready. Skip frame");
- return;
- }
- camera.takePicture(null, null, this);
- cameraPreview.onPictureTook();
- }
- public void onPictureTaken(byte[] data, Camera camera) {
- // save photo
- cameraPreview.start();
- }
- public class CameraPreview extends SurfaceView {
- private boolean previewRunning = false;
- /**
- * Should be called after calling camera.takePicture
- */
- public void onPictureTook() {
- previewRunning = false;
- }
- public boolean isRunning() {
- return previewRunning;
- }
- public void start() {
- try {
- camera.setPreviewDisplay(surfaceHolder);
- camera.startPreview();
- previewRunning = true;
- } catch (Exception ignored) {
- Log.e(LOG_TAG, "Error starting camera preview", ignored);
- }
- }
- }
- private class CaptureThread extends Thread {
- @Override
- public void run() {
- int count = 0;
- while(count < mNo) {
- mFileName = mLocation + "/pic" + count + ".jpg";
- mCamera.takePicture(null, mPictureCallback, mPictureCallback);
- count++;
- try {
- Thread.sleep(3000);
- } catch (InterruptedException exception) {
- exception.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement