Android method for automatically capturing photos and uploading them every X seconds

StackOverflow https://stackoverflow.com/questions/11856993

  •  25-06-2021
  •  | 
  •  

Pergunta

I have the following task:

Later this month, I will launch an Android smart phone (htc droid incredible) aboard a solar balloon much like I did last May.

I would like to configure the Android to take a photo every X seconds and upload it to Google+. I have the automatic upload working but I have not yet been able to find an app that can take photos automatically while using very little system resources (the hope is to keep the phone transmitting for a long period of time).

What apps or simple scripts would be able to do this?

We can't keep photos on the hard drive because we will never get it back. It has to transmit.

Foi útil?

Solução

I have used this python script:

import android
import time

droid = android.Android()
for i in range(5): 
    temp = str(i)
    path = '/sdcard/picscript/'
    path += time.strftime("%B-%_e-%_I-%M-")
    path += temp
    path += '.png'
    droid.cameraCapturePicture(path, True)

in conjunction with SL4A To loop taking pictures. As it is now it will take 5 images and save them to a folder on the SDcard named picscript, the filenames will be a timestamp of the time that the photo was taken. Once they are saved you could upload them from there, If you are feeling adventurous you could probably even figure out how to upload them from the python script itself.

You could alter the script to make it an infinite(ish) loop and add a time delay inbetween each photo if you wanted.

If you are ok with needing sl4a installed on the device you can run it from the python file. If you'd rather not have sl4a installed you can instead wrap it in an android apk as detailed in this pdf. No matter which route you take you will have to have python installed on your device though.

Note: I have no idea about battery usage with this script but I suspect it'd be rather draining. In more recent versions of sl4a the APIs have changed a bit and the camera preview is now shown on the screen. I don't think it used to show the preview so if you went back and grabbed an older version you might be able to get better battery performance out of it. droid.cameraTakePicture(path,True) is what the method used to be called in the older versions.

Outras dicas

First of all the main idea is to be capturing using an IntentService.

This will be quite straight forward, just override the onCommand method and take the shot with the sample code here

http://developer.android.com/guide/topics/media/camera.html#access-camera

You don't have to set a preview view or perhaps just set up a dummy preview if it's not working on your device.

To trigger the IntentService you should have an AlarmManager to trigger every X time and fire off the intent. And a BroadcastReceiver to kick off the AlarmManagers on boot.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top