Objective

Use your camera-equipped J2ME device, such as the Nokia N82 as a remote camera monitor. Images are captured at with an user-defined interval and uploaded to a web server.

Materials and tools

  • Mobile phone, such as the Nokia N82, which supports the following specifications:
    • J2ME MIDP2.0/CLDC1.0,
    • Wireless Messaging API 1.1 (JSR 120),
    • Mobile Media API (JSR 135),
    • Web Service Access for J2ME (JSR 172).
  • Java 2 Platform, Micro Edition (J2ME) Wireless Toolkit Version 2.2 [patch 200508] (http://java.sun.com/j2me).
  • Apache or any other web server with PHP support (version 4.1 or later).

Implementation: J2ME device

Modified example source code taken from Sun Developer Network's article Taking Pictures with MMAPI (Snapper.zip). The main changes in short are:
  • added parameters to mMainForm,
  • new class Grabber which takes care of capturing images periodically in a separate thread,
  • function httpUpload which pushes the images to web server using HTTP POST.
For development and debugging in emulator, change variable emulator to false in file SnapperMIDlet.java. Do not forget to change it back when compiling a package for the real device.

Implementation: web server

Very simple PHP script which takes uploaded images and saves those to a directory tree in form.
       YYYY/MM/DD/HH/YYYYMMDDTHHMMSS.jpg
relative to the root directory which is defined by variable dstroot. For example, photo captured at noon on 24 October 2007 is saved to:
       2007/10/24/12/20071024T120000.jpg

Installation and configuration

Compile the sources and create a JAR package, which you then install into the device. You should then modify some settings for this installed application. In Nokia devices it can be done as follows.
  1. Open 'Application Manager'
  2. Select 'SnapperMIDlet' from the list and open it.
  3. Change 'Network access' to 'Ask first time'.
  4. Change 'Multimedia' to 'Ask first time'.
When you open the application, you see a form in which you can set upload and capture parameters.
  • URL: the address of PHP upload script.
  • Interval: pause between snapshot in seconds.
  • Quality: image compression parameter 0-100, 0 is the best compression (worst quality) and 100 is the least compression (best quality).
Source code and non-warranty You can download the sources from this source directory. Rename file index.txt to a PHP file of your choice.

See the original copyrights and disclaimers.

My changes (hacks) and this documentation are under the GNU Lesser General Public License.
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
Furthermore, I recommend that you treat the sources as 'read only'. With little time you can certainly write much better program from the scratch.

JAR package can be downloaded from here.

Use cases

None. This is just a toy software for playing around. Do not even think of using this for anything critical or relying anybody's safety on this. Read the disclaimer above and in the source files: there is absolutely no warranty. The user of this software is responsible for any use of this software.

Some example images are here.

See also

Time-lapse imaging using GNU/Linux.

24 October 2007, Petteri Kettunen