Camera¶
Camera
¶
Camera sensor for video files and image sequences.
Supports three operating modes: 1. Photogrammetry mode: Loads pre-processed photogrammetry results from CSV 2. Sony RX0 MarkII mode: Extracts IMU telemetry from .mp4 files and computes orientation 3. Alvium industrial camera mode: Reads timestamp and frame number from log files
The camera data is stored as a tuple (DataFrame, model_string) in the data attribute
after calling load_data().
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
Path to video file, image directory, or photogrammetry CSV. |
use_photogrammetry |
bool
|
Whether to use photogrammetry mode. |
data |
tuple[DataFrame, str | None]
|
Camera data as (DataFrame, camera_model). Set by load_data(). camera_model is "sony", "alvium", or None for photogrammetry. |
logpath |
(Path, optional)
|
Path to log file for timestamp extraction (set during load_data). |
Examples:
>>> # Load Sony camera with IMU telemetry
>>> camera = Camera("/path/to/camera/folder")
>>> camera.load_data()
>>> df, model = camera.data
>>> print(model) # "sony"
>>> print(df.columns) # ['timestamp', 'gyro_x', 'gyro_y', 'gyro_z', ...]
>>>
>>> # Load photogrammetry results
>>> camera = Camera("/path/to/results.csv", use_photogrammetry=True)
>>> camera.load_data()
>>> df, model = camera.data
>>> print(model) # None
>>> print(df.columns) # ['timestamp', 'pitch', 'roll', 'yaw']
Initialize Camera sensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to camera data. For Sony/Alvium cameras, this is a directory containing .mp4 files or .log files. For photogrammetry mode, this is the path to a CSV file with processed results. |
required |
use_photogrammetry
|
bool
|
If True, loads photogrammetry CSV. If False, auto-detects Sony or Alvium camera based on files in directory. |
False
|
Examples:
>>> camera = Camera("/path/to/camera/folder")
>>> camera = Camera("/path/to/photogrammetry.csv", use_photogrammetry=True)
Source code in pils/sensors/camera.py
load_data
¶
Load camera data and store in self.data attribute.
Automatically detects camera type and loads appropriate data:
Photogrammetry mode (use_photogrammetry=True): Loads CSV file with columns: timestamp, pitch, roll, yaw Sets self.data = (DataFrame, None)
Sony RX0 MarkII mode (.mp4 files found): Extracts IMU telemetry from video, computes orientation using AHRS Requires .log file in parent directory with start timestamp Sets self.data = (DataFrame, "sony") DataFrame columns: timestamp, gyro_x/y/z, accel_x/y/z, roll, pitch, yaw, qw/qx/qy/qz
Alvium industrial camera mode (no .mp4, .log file found): Reads log file for frame timestamps and numbers Sets self.data = (DataFrame, "alvium") DataFrame columns: timestamp, frame_num
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the camera data path does not exist or no valid files are found. |
Examples:
>>> camera = Camera("/path/to/sony/folder")
>>> camera.load_data()
>>> df, model = camera.data
>>> print(model) # "sony"
>>> df.select(['timestamp', 'pitch', 'roll', 'yaw'])