Linssi - burst-stacking camera for the Nokia 9500 (Series 80 v2.0)
Version 1.0, 2026-11-11. Package UID 0x01000A28, app name "Linssi".

Sami Vuori, written together with Claude (Anthropic). MIT licence.

The 9500's VGA camera is noisy and soft. Linssi takes a quick burst, finds
the sharpest frame, lines the others up on it (to a sixteenth of a pixel,
following small turns of the hand) and averages them, leaving out anything
that moved. Then it stretches the tones, smooths the colour noise, sharpens
a little and saves a high-quality JPEG. On the PC test an 8-frame stack
cut the noise by 7.9 dB (2.5x less noise; 9 dB is the most 8 frames can give).

The viewfinder is on the inner screen, so the cover has to be open while
you shoot. The 9500's cover display has no public API, so Linssi can't put
the viewfinder there.

SCREEN
  Viewfinder on the left, full height. On the right: the mode, size and
  quality, a live histogram (red end bars = clipped highlights / shadows),
  brightness, frames per second, a steadiness bar (how much the picture
  moves between viewfinder frames: green = steady), the status line and the
  last picture. After a picture the result stays up for 3 seconds.

KEYS
  Enter, rocker centre, space   take a picture (again during the preview)
  left / right                  mode
  up / down                     digital zoom, if the camera has it
  Esc                           stop the timer / burst / processing, else exit
  I                             camera information

  Kuvaa       take a picture
  Tila        next mode: Pino x 4, Pino x 8, Pino x 16, Yksi kuva, Kameran oma JPEG
  Asetukset   settings (the viewfinder keeps running, so exposure and white
              balance changes show at once): up/down pick, left/right change
              Tiedot = camera information, Oletukset = defaults
  Sulje       exit

MODES
  Pino x N          N frames, stacked. x4 is quick; x8 or x16 on a table or
                    with the self-timer for dim light.
  Yksi kuva         one frame through the same finishing (tones, colour
                    noise, sharpening).
  Kameran oma JPEG  the camera's own JPEG, untouched, at the set quality:
                    for comparing.

SETTINGS
  Kuvakoko          the sizes the camera offers
  JPEG-laatu        80 / 90 / 95 / 100
  Savyt             ennallaan / kontrasti / kontrasti + varit (grey-world
                    colour balance, half way)
  Teravointi        pois / kevyt / vahva (less with fewer frames)
  Varikohina        ennallaan / tasoitetaan
  Varikyllaisyys    ennallaan / +15 % / +30 %
  Epateravat kuvat  mukaan / jatetaan pois (under 75 % of the sharpest)
  Ajastin           pois / 2 / 5 / 10 s
  Valotus, Valkotasapaino, Kirkkaus, Kontrasti
                    only what the camera says it supports
  Kansio            D:\Images\ / D:\Linssi\ / C:\Documents\Images\
                    (C:\Documents\Images\ by itself when there's no card)

FILES
  Pictures          LIN_0001.JPG ... in the chosen folder
  D:\Linssi\caminfo.txt   what the camera reports, written at the first
                          start (C:\Linssi\ without a memory card); Tallenna in
                          the info view writes it again
  D:\Linssi\linssi.log    every picture: frames, sharpness, shifts, tiles,
                          ghost pixels, times per stage
  C:\System\Data\Linssi.dat   settings, mode, file counter

HOW IT WORKS (linproc.c, plain C89)
  Frames are kept as YUYV 4:2:2 (the sensor's own format: 8-bit luma at half
  the memory of RGB). Alignment: a luma pyramid per frame, a +-6 search on
  the level near 80x60, +-1 on each finer level, then 4x3 tiles at full size
  search +-2 around that and keep their own shift if clearly better. Sub-
  pixel parts come from an equiangular fit of the sums. The tile shifts are
  interpolated per pixel and the luma is sampled bilinearly. A pixel is
  added only if its luma and colour are near the reference's (moving things
  stay as they were in the reference). Frame brightness is matched first.
  Finishing: levels from the luma histogram (0.2 % clipped, at most 2x),
  chroma follows half the stretch, 3x3 colour smoothing, unsharp mask with
  coring. Work memory for 640x480: 2.4 MB, plus 600 kB a frame.

  What the 9500's ECam does, from the SDK's emulator ECAM.DLL and
  CAMSERVERCORE.DLL: no direct-to-screen viewfinder (so bitmaps), no
  clipping, stills as JPEG or bitmap. Linssi asks for a bitmap still for
  stacking (16M, 64K, 4K, then JPEG/EXIF), and EXIF/JPEG for its own JPEG
  mode. It all comes from TCameraInfo at run time; caminfo.txt shows it.

SOURCES
  LinssiApp.cpp     app UI, document, application
  LinssiView.h/.cpp the view: viewfinder, panel, settings, info, log
  Camera.h/.cpp     CLinCamera: ECam reserve / power / viewfinder / stills
  Shot.h/.cpp       CLinShot: the burst, processing steps, JPEG out (ICL)
  linproc.h/.c      alignment, stacking, finishing
  LinssiAif.rss     Desk caption + icon (AIF line in Linssi.mmp)
  make_icon.py      draws the lens icon BMPs + masks (Pillow)
  tests\proc_test.c PC test of linproc.c: a fake shaky noisy burst
                    gcc -std=gnu89 -O2 -Wall -I.. proc_test.c ..\linproc.c -o proc_test -lm
                    proc_test [picture.bmp]   -> out\*.bmp
  tools\make_testclip.py  clips for the emulator's fake camera (below)
  tools\cppcheck.sh  syntax check of the C++ against the real SDK headers
                    with a modern MinGW g++:  sh tools/cppcheck.sh
                    (set SDK and GXX at the top to your own paths)
  tools\make_release.py  packs release\Linssi-<version>-src.zip and, with
                    Linssi.sis copied into release\, Linssi-<version>.zip

BUILD (on the Win2000 VM, with the Series 80 v2.0 SDK)
  bldmake bldfiles
  abld build armi urel
  makesis Linssi.pkg

INSTALL
  Linssi.sis, or copy Linssi.app, Linssi.rsc and Linssi.aif to
  C:\System\Apps\Linssi\.

EMULATOR
  The SDK emulator's camera plays epoc32\wins\c\Handshake_qqvga.yuv
  (160x120, a lens on an orange background). For bigger sizes, or a shaky
  noisy scene to stack, make clips with:
    python tools\make_testclip.py picture.jpg --sizes vga,qvga
  and copy handshake_vga.yuv / handshake_qvga.yuv to epoc32\wins\c\.
  Whether the emulator also takes stills from them is not known.

STATUS
  Version 1.0 was built with the Series 80 v2.0 SDK and runs on a Nokia
  9500 (November 2026). Not measured yet:
  - which formats and sizes the 9500's camera offers (caminfo.txt shows
    them), how long a still takes, and the viewfinder size it settles on
    (Linssi asks for the pane's size, then 320x240, 160x120 and 176x144);
  - processing time on the 9500's 150 MHz ARM. On the PC (gcc -O2) one
    640x480 frame takes 6 ms to align and add, finishing 5 ms; linssi.log
    has the phone's times per stage.

LICENCE
  MIT, see LICENSE.txt. Nokia, Series 80 and Symbian are trademarks of
  their owners. This project isn't affiliated with them.
