The GEMINI project collects plant measurements across hundreds of plots every season. A drone covers the whole field, but a lot of the ground truth has to be taken by hand: canopy temperature, plant height, leaf orientation, and the weather at the moment of capture.

For a while that meant carrying a thermal camera, a laser distance meter, a handheld weather station, and a notebook. Each device wrote its own file with its own clock, and matching them afterwards in a spreadsheet was slow and error-prone.

I built an iPhone app that records all of these in one capture. This series has four parts.

The idea

An iPhone already contains a 12 MP camera, a LiDAR depth sensor, GPS, an IMU, and Bluetooth. The missing piece was a thermal camera, which the FLIR ONE Pro adds through the Lightning port.

The weather station was built as a separate device first. Its Bluetooth link to the app came later, in the weather station series.

Two capture pairs shown side by side: RGB with thermal from the FLIR sensors, and RGB with depth from the phone sensors
The app records two sensor pairs at the same instant: RGB + thermal from the FLIR ONE Pro (top), and RGB + depth from the iPhone LiDAR (bottom).

A thermal image alone shows leaf temperature. Aligned with the RGB frame, the canopy depth, and the air temperature at the same second, it can be used in a model.

What one capture produces

Pressing the shutter writes five files. They share a timestamp and a sequential index, so a capture is never ambiguous:

File Sensor ID Content
YYMMDD_IMG_XXXXX.jpg 401 RGB still from the iPhone camera
YYMMDD_IMG_XXXXX_flir.jpg 402 Thermal frame from the FLIR ONE
YYMMDD_IMG_XXXXX.json 403 GPS, attitude, air temperature, humidity, settings
YYMMDD_IMG_XXXXX_depth.tiff 404 Depth map (32-bit float)
YYMMDD_IMG_XXXXX_confidence.tiff 405 Per-pixel depth confidence

The JSON sidecar describes each capture. It follows the same collections.json schema the drone and rover pipelines already used:

{
  "collection_device_id": 104,
  "sensor_id": 401,
  "date_collected": "2023-09-26",
  "file_name": "230926_IMG_00142.jpg"
}
Field Value Meaning
collection_device_id 103 drone
  104 rover / handheld
sensor_id 401 rgb_jpg
  402 flir_jpg
  403 meta_json
  404 depth_tiff
  405 confidence_tiff

Using the existing IDs meant the iPhone data could be dropped into the same processing scripts without a special case.

Depth

The LiDAR depth map is coarse, but in bench tests at 0.3 to 1 m above the canopy it was good enough to separate leaves from soil and to estimate canopy height per frame. Field data were collected from a rover at about 1.5 m and from a drone at 5 m and 10 m.

Point cloud of a single soybean plant reconstructed from ARKit frames, with the world origin axes and a bounding sphere drawn over a wooden surface
An early reconstruction from the ARKit session. The point cloud is sparse, but the plant silhouette and its shadow separate cleanly, which was enough to check that the depth and the RGB frame were aligned.

To check alignment I wrote a small desktop viewer that opens a capture and draws four panels: RGB, depth, confidence, and the RGB again with the measured distance printed on it.

Four panels: soybean canopy RGB, grayscale depth, confidence map, and a second RGB view
A soybean canopy capture. The depth panel (second) follows the canopy relief, and the confidence panel (third) marks the sky and the far background as unreliable, as expected.
Four panels: corn rows from above, depth with min and center distances, confidence, and a second RGB view
Corn rows from directly above. The depth panel prints the minimum distance and the distance at the image centre (3.81 m and 4.88 m here), which was how I checked that the phone was held at a consistent height.

The viewer also showed a problem. In the third panel the confidence drops to near zero over bare soil in full sun, and the depth values there are wrong by tens of centimetres. For this reason the app always stores confidence with depth, and the analysis masks low-confidence pixels.

Four panels from a second soybean capture, showing RGB, depth, confidence, and a reference RGB frame
A second soybean plot on the same morning. The four-panel view caught alignment drift before it reached the analysis.

Metadata

Every capture carries the phone’s GPS fix, compass heading, pitch and roll, and the weather station reading. The FLIR image also gets its own EXIF block, so the thermal file is not dependent on the sidecar JSON if it ever gets separated.

Terminal output of exiftool showing FLIR GPS latitude, longitude, altitude, and image direction tags
Running exiftool on a thermal image after adding GPS tagging. Latitude, longitude, altitude, and image direction are written into the FLIR XMP block, so the thermal file stays georeferenced on its own.

Writing GPS into the FLIR metadata was not automatic. The FLIR SDK exposes a gpsInfo object on the image, and the app fills it from Core Location before saving:

guard let location = self.location else { return }

var gpsInfo = image.getGpsInformation()
gpsInfo.latitudeRef = location.coordinate.latitude >= 0 ? "N" : "S"
gpsInfo.longitudeRef = location.coordinate.longitude >= 0 ? "E" : "W"
gpsInfo.latitude = Float(location.coordinate.latitude)
gpsInfo.longitude = Float(location.coordinate.longitude)
gpsInfo.altitude = Float(location.altitude)
gpsInfo.gpsMapDatum = "WGS84"
gpsInfo.timeStamp = NSDate()
image.setGpsInformation(gpsInfo)

What this version could not do

The first working version used ARKit for everything. It gave RGB and depth in the same frame with the camera pose attached, which the depth reconstruction needed.

It also capped the RGB image at 1920×1440. Compared with the same phone’s native camera app, the 2023 flight images were lower in resolution, and some were soft in a way sharpening did not fix. Part 2 covers these problems.

References