performanceactive / phonegap-custom-camera-plugin

45 stars 37 forks source link

Is it possible to use the plugin to take a photo automatically? #4

Open OscarIT opened 10 years ago

OscarIT commented 10 years ago

Can we attach a timeout click event to take the picture without user action?

cvanes commented 10 years ago

I don't quite follow, do you mean capture an image x milliseconds/seconds after the user has tapped the capture button? Or capture the image x milliseconds/seconds after the camera preview is shown?

OscarIT commented 10 years ago

Im searching for a an Android phonegap plugin to take a photo directly, with no user action needed. I want to avoid the camera interface totally, to capture a photo, create timelapses, etc.

There are a few plugins for iOS, but cant find one for Android: http://codrspace.com/vote539/writing-a-custom-camera-plugin-for-phonegap/

I saw at your code there is a Takepicture action, is it possible to access it from the javascript code? It would be a nice feature.

cvanes commented 10 years ago

customCamera.getPicture(...) can be called from javascript but it will open a camera preview and remain open until the user taps the capture button.

https://github.com/performanceactive/phonegap-custom-camera-plugin/blob/master/www/js/customcamera.js

OscarIT commented 10 years ago

Sorry, I mean these 2 functions:

  1. takePictureWithAutoFocus()
  2. takePicture()

https://github.com/performanceactive/phonegap-custom-camera-plugin/blob/master/platforms/android/src/com/performanceactive/plugins/camera/CustomCameraActivity.java

cvanes commented 10 years ago

You could probably re-use some of the code but the CustomCameraActivity will always display the camera preview when created.

crapthings commented 10 years ago

We need this feature too. i've forked official cordova camera plugin, and add some new code to android platform. it works without cordova, we have tested itself as an android newproject, but can't make it work with cordova.

  1. a new thread that allow surfaceView wait 5s to takePicture()

https://github.com/crapthings/cordova-plugin-camera/blob/0a2fdead0536e21fb8ea86e577c1a70470721fa6/src/android/CameraLauncher.java#L1043

  1. save it.

https://github.com/crapthings/cordova-plugin-camera/blob/0a2fdead0536e21fb8ea86e577c1a70470721fa6/src/android/CameraLauncher.java#L1043

class MyThread extends Thread {
  public void run() {
        // test
    try {
      Thread.sleep(Timer);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  camera.autoFocus(new AutoFocusCallback() {// autofocus

        public void onAutoFocus(boolean success, Camera camera) {
                Parameters params = camera.getParameters();
                params.setPictureFormat(PixelFormat.JPEG);// format
                params.setPreviewSize(800, 480);// width & height
                camera.setParameters(params);// set parameters
                camera.takePicture(null, null, jpeg);// take photo.
        }
    });
   }
 }
kjakub commented 9 years ago

Someone tried this ?

Yojerry11 commented 6 years ago

Hello there.. I need to capture an image x every 30 seconds after the user has tapped the capture button! Can any one help me with that?