Martin Wright

Coastal Camera Image Processing

July 2026 Computer Vision • Coastal Engineering • Image Processing
Auckland Council runs nine time-lapse cameras along its coast, each photographing the beach roughly every hour. The problem: the photos are taken at a steep angle, so you can't measure a beach directly from them. This project builds Python tools that turn those tilted snapshots into real measurements — holding each frame steady against camera wobble, flattening the oblique view into a true overhead map, and tracking where the waterline sits over months and years to show whether a beach is eroding or rebuilding. The toolkit is organised around three jobs: stabilise, map, and measure.
Te Arai Regional Park, Auckland, New Zealand. Source: Auckland Council.

Background

Auckland Council operates nine Obscape time-lapse cameras along the east coast from Te Arai to Waiheke Island, capturing hourly imagery transmitted via GSM. The existing image-processing ecosystem (MATLAB-based Argus tools and the CoastSnap citizen-science platform) presented barriers to operational use: licensing costs, complexity, and unsuitability for fixed-camera networks.

This project delivers standalone Python tools that exploit the fixed geometry of the Obscape installations. Because the cameras rarely move, a calibration solved from surveyed ground control points can be reused across thousands of frames — and when a camera is bumped or repositioned, a fresh calibration is recorded and applied from that point on (see the calibration registry below).

The Pinhole Camera Model

Every camera turns a 3D world into a flat picture by drawing a straight line from each real-world point, through a single pinhole, onto the sensor. Capture that geometry in a matrix and you can predict exactly where any point on the beach lands in the photo — and, working backwards, where a pixel came from.

The projection of a 3D world point $\mathbf{X} = [X, Y, Z, 1]^T$ onto a 2D image point $\mathbf{x} = [u, v, 1]^T$ is modelled by the $3 \times 4$ projection matrix:

$$\mathbf{x} = P\,\mathbf{X} = K\,[R \mid \mathbf{t}]\,\mathbf{X}$$

where $K$ is the $3 \times 3$ intrinsic matrix encoding focal length and principal point:

$$K = \begin{bmatrix} f_x & 0 & c_{0u} \\ 0 & f_y & c_{0v} \\ 0 & 0 & 1 \end{bmatrix}$$

and $[R \mid \mathbf{t}]$ encodes the camera's 6-DOF pose — three Euler angles (azimuth, tilt, swing via ZXZ convention) and a 3D position in NZTM2000 coordinates.

Lens Distortion

Real lenses aren't perfect pinholes: straight lines bow near the edges of the frame, so a pixel's true direction has to be corrected before any measurement is trustworthy. The Caltech distortion model captures this as radial and tangential aberrations in normalised camera coordinates $(x_n, y_n)$:

$$f_r = 1 + d_1 r^2 + d_2 r^4 + d_3 r^6$$

where $r^2 = x_n^2 + y_n^2$. Tangential components model decentring:

$$\Delta x = 2t_1 x_n y_n + t_2(r^2 + 2x_n^2)$$

$$\Delta y = t_1(r^2 + 2y_n^2) + 2t_2 x_n y_n$$

The final distorted pixel coordinate is then $u_d = (x_n f_r + \Delta x)\,f_x + c_{0u}$. The full intrinsics vector stores 11 parameters: image dimensions, principal point, focal lengths, and five distortion coefficients.

Image Stabilisation

Even bolted-down cameras twitch — wind buffets the housing, metal expands in the sun, technicians nudge it during maintenance. A few pixels of wander would masquerade as beach change, so every frame is snapped back into alignment with a reference using a robust homography (a flexible 2D warp):

$$\mathbf{x}' = H\,\mathbf{x}$$

where $H$ is a $3 \times 3$ projective transformation estimated from matched feature correspondences. The pipeline extracts SIFT keypoints under CLAHE equalisation, matches via FLANN KD-trees with Lowe's ratio test ($\tau = 0.65$), and estimates $H$ using MAGSAC++ with 10,000 iterations at 99.9% confidence.

Quality gating rejects frames with fewer than 15 inliers or condition number $\sigma_{\max}/\sigma_{\min} > 10^6$. Failed frames are interpolated from temporal neighbors to maintain continuity.

Projection Geometry

The diagram below illustrates the pinhole projection from a 3D world point through the camera's optical centre onto the image plane. Ground control points (GCPs) surveyed in NZTM2000 coordinates provide the known correspondences needed to solve for the extrinsic parameters via Levenberg-Marquardt optimisation.

Image plane (c₀ᵤ, c₀ᵥ) O f X = [X,Y,Z]ᵀ x Ground plane (Z = 0) GCP₁ GCP₂ GCP₃ y z x x = K[R|t] X

Oblique-to-Plan Rectification

The core value of the pipeline is turning a tilted, foreshortened photo into a true top-down map — rebuilding the beach as if it had been photographed straight down from above. Rather than computing a direct homography between image and ground (which would assume a perfectly flat scene), the system projects through the full calibrated camera model onto a known ground-elevation surface.

A regular grid of world coordinates $(X_i, Y_j, Z_{\text{ground}})$ is constructed in NZTM2000 at the surveyed beach elevation. Each grid node is projected forward through the calibrated camera model to obtain distorted pixel coordinates $(u_d, v_d)$. The rectified image is then constructed by backward sampling — each output pixel at grid location $(i,j)$ takes its colour from the oblique image at $(u_d, v_d)$ via bilinear interpolation:

$$I_{\text{rect}}(i,j) = I_{\text{oblique}}\big(u_d(X_i, Y_j),\; v_d(X_i, Y_j)\big)$$

This backward-mapping approach avoids holes in the output grid and naturally handles the variable ground-sample distance inherent to oblique viewing geometry — pixels near the camera map to small ground areas (high resolution) while pixels near the horizon span large distances (low resolution).

Oblique camera view from Orewa Beach showing the raw perspective captured by the Obscape camera

The oblique view above (Orewa Beach) illustrates the characteristic perspective compression of distant features. After rectification through the calibrated camera model, the same scene is projected to an orthographic plan-view with consistent spatial scale:

Rectified plan-view temporal mean (timex) image of Orewa Beach showing consistent spatial scale

This temporal mean image (timex) averages all frames in a capture period after rectification. Wave action appears as a diffuse white band along the shoreline, while stable features (seawalls, rock platforms) remain sharp. The consistent ground-sample distance enables direct measurement of distances and areas.

Stabilisation Assessment: Pixel Time Stacks

A direct way to assess stabilisation quality is to extract a fixed pixel row from the oblique imagery at every timestep and stack these 1D slices vertically. The horizontal axis represents cross-shore pixel position, and the vertical axis is time. If stabilisation is working correctly, static features (seawalls, vegetation boundaries) appear as vertical lines — any horizontal drift would indicate residual camera motion:

Cross-shore pixel time stack from stabilised oblique imagery at Takapuna Beach

The time stack above is sampled from the stabilised oblique sequence at Takapuna. Fixed features remain vertically coherent, confirming sub-pixel alignment across frames. The dynamic shoreline signal (the migrating bright-dark boundary) reflects real tidal excursion rather than camera jitter — demonstrating that the homography stabilisation preserves genuine coastal change while removing instrumental noise.

Keeping Calibration Honest Over Time

Long-term monitoring has a subtle catch: cameras occasionally move. A storm reseats a housing, or a technician bumps it during maintenance — and from that moment an old calibration silently mismaps every pixel. Rather than assume one fixed calibration forever, each camera keeps a calibration registry: a timestamped, immutable list of calibrations, each valid from a given date. Any photo is matched to the calibration that was in force when it was taken, so measurements stay comparable across a camera move. The calibration itself follows the CIRN photogrammetric workflow (Bruder & Brodie, 2020), solving the camera pose from surveyed ground control points.

The rectified products shown above — timex composites and pixel time-stacks — are being re-plumbed to draw their calibration per frame from this registry, so that even a multi-year record assembled across camera moves stays geometrically consistent.

Measuring the Beach: Wet-Edge Transects

Rectified imagery is the means, not the end — the point is to measure whether a beach is gaining or losing sand. The instrument for this is a fixed transect: a single cross-shore line drawn once from a landward benchmark (A) down to the sea (B). Every qualifying photo is then reduced to one number — how far along that line the waterline sits.

The trick is comparing like with like. The waterline naturally marches up and down the beach with the tide, so its raw position tells you nothing on its own. Each measurement is therefore paired with the tide height at that instant (from Oceanum's met-ocean model), and only frames captured in calm conditions are kept — wind under 5 knots and significant wave height under 0.3 m — so that wave run-up and swash don't corrupt the reading. Detection runs along the transect, locating the wet/dry boundary from a red-minus-blue intensity profile.

Plotting waterline position (its chainage along the transect) against tide height turns a pile of photos into a beach-change signal. If the same tide now reaches a point further landward than it did months earlier, the beach has lost sand; further seaward, it has gained. The diagram below shows the idea:

Same tide level, different waterline = beach change elevation chainage along transect landward (A) seaward (B) → tide level (Oceanum) Δ shoreline Period A Period B (later)

Each passing measurement — capture time, tide height, chainage, and the transect version it was measured against — is appended to a running record for that camera. Comparing these clouds of points across time windows, tide band by tide band, is what ultimately reveals seasonal erosion and recovery at each site.