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
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


Scripting Layer 4 Android,

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)

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.


No comments: