Sunday, February 05, 2012

Android Camera App

NOTE: This email is also a blog entry for "Church of BSD Blog"
I was going to write an app for the place I'm working now
http://www.lawrenceslist.com/
It would take a picture and upload it to the website.
I did not want to do it in Java. My alternatives are:

RFO Basic! 4 Android
http://laughton.com/basic/

and

Scripting Layer 4 Android,
http://code.google.com/p/android-scripting/

which uses a single library to support several scripting languages
(Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell)

After looking at, and testing, Basic!, it appeared a good choice,
I preferred to use something I'm more familiar with - python or tcl.

After spending several hours with sample code, I was confident
enough to tweak a few of the samples. Things went well with an
example that used a method, cameraCapturePicture() - but it had
a small quirk. The person shooting had less than a second to
stabilize the camera while it focuses, then the camera shoots.
The alternative seemed to be cameraInteractiveCapturePicture().
After several failures, I found out the second method
was intended for the "Front-facing" camera (that would be
the camera on the same side as the screen)

http://books.google.com/books?id=uYEmWet7QtsC&pg=PA124&lpg=PA124&dq=cameraInteractiveCapturePicture+python+examples&source=bl&ots=iXk_Dfn4Rl&sig=qcHXBMef3vFlTIhbjle0vj0FYSQ&hl=en&sa=X&ei=tR4uT_a7BIb9iQKGjqkZ&ved=0CEEQ6AEwBQ#v=onepage&q=cameraInteractiveCapturePicture%20python%20examples&f=false

it appeared the only alternative left was for another even less
documented method cameraStartPreview() and cameraStopPreview()

The hack would be that the camera would preview for several
seconds and then after a brief pause would focus and shoot.

It worked -- sort of.

The image was exposed in landscape while I shot in portrait.
As it turns out, the preview mode as in landscape. It appears
that as of this moment there are no other controls, modes, or
methods to use the camera under SL4A.

As it turns out, this round will be won by this dialect of
Dartmouth Basic - example f33_camera.bas does exactly
what I want the camera to do. Now all I have to do is upload
the picture.

tc

No comments: