2

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.

glossarch
  • 272
  • 5
  • 18

2 Answers2

3

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.

FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • I appreciate your answer. I am reasonably familiar with python so I will give this a try. If it pans out I'll let you know and mark this as answered (might be a couple of weeks though). – glossarch Aug 08 '12 at 18:41
  • @glossarch I wish you luck! Out of curiosity do you have a plan to keep the phone under the 9000ft ceiling of the cell signals this time? Or do you have some other way planned for it to send data to the internet? – FoamyGuy Aug 08 '12 at 23:20
  • I am not sure what the ceiling will be. It was at 9000 ft in Massachusetts when I launched the 20' solar balloon. This one will be in North Carolina, and my hope is that since it is more rural the cell signal will be stronger. A high altitude weather balloon launch with onboard cell in New Mexico transmitted to probably 30,000 ft (description of that launch is on my blog too). This upcoming launch is a sacrifice-the android is up for renewal so we are not planning on getting it back. It will transmit up to the ceiling (wherever that is) and then disappear. – glossarch Aug 09 '12 at 13:56
  • I cannot find the module "android". i'm getting this error when i try to install it ERROR: No matching distribution found for android. am i doing anything wrong or could you guide me how to install it. – Manoj Mar 31 '21 at 17:22
1

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.

Pork 'n' Bunny
  • 6,740
  • 5
  • 25
  • 32
  • The ImageCaptureIntent combined with AlarmManager for a repeating trigger and a BroadcastReceiver (receiving start event) is a very elegant use of existing droid features, sounds like you could whip this up very quickly. – Syntax Aug 08 '12 at 03:41
  • 1
    Doesn't that require a user to take the photo? – Pork 'n' Bunny Aug 08 '12 at 03:42
  • True, when you say trigger the intent service using the alarm manager I take it then you mean to trigger your own service (which is performing the onCommand image capture)? – Syntax Aug 08 '12 at 11:33
  • 1
    Yeah that's correct. Trigger the capture with no user interface. Considering it's going up in a science balloon nobody is going to see the screen :) – Pork 'n' Bunny Aug 08 '12 at 13:18