Loading...
Searching...
No Matches
usher_sources.h
Go to the documentation of this file.
46inline std::vector<OrthoSource> readUsherSources(const MapConfig& config, const std::filesystem::path& manifest) {
48 if (!usher_camera_profile_read(config.cameraProfile.c_str(), &profile) || profile.camera_id != 2)
59 name.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-") != std::string::npos ||
63 source.path = (config.sourceDirectory.empty() ? config.photoDirectory : config.sourceDirectory) / name;
71 if (exif_read_jpeg(source.path.c_str(), payload.data(), payload.size(), &size) || exif_parse(&view, payload.data(), size))
79 if (comment.find("USHER_MOCK_MAP_V1") != std::string::npos || comment.find("USHER_LENS_V1") != std::string::npos)
101 if (found == fields.end() || found->second.empty()) throw std::runtime_error(std::string("USHER EXIF lacks ") + key);
118 for (const auto* key : {"capture_pose_synchronized", "observation_pose_aligned", "frame_identity_bound"}) {
120 if (value != "true" && value != "false") throw std::runtime_error("Invalid USHER pose qualification");
126 throw std::runtime_error("AI Camera mapping requires exposure-aligned, frame-bound pose; recorded policy is explicitly approximate");
130 const auto earliest = integer("observation_earliest_monotonic_us"), latest = integer("observation_latest_monotonic_us");
131 if (!earliest || latest < earliest || latest - earliest > 50000 || latest > uint64_t(LLONG_MAX / 10))
137 !capture.sequence || !capture.sensor_timestamp_ns || capture.sequence != integer("observation_sequence") ||
138 capture.sensor_timestamp_ns != integer("sensor_timestamp_ns") || capture.boot_id != required("observation_boot_id") ||
141 throw std::runtime_error("AI Camera frame identity/dimensions disagree with its observation pose");
142 source.poseTime = static_cast<long long>(earliest * 10); source.frameTime = static_cast<long long>(latest * 10);
162 source.poseUncertainty = exposurePose ? real("observation_pose_uncertainty_m", 0, config.maxPoseUncertainty) :
177 throw std::runtime_error("AI Camera calibration/pose fails shared coverage geometry validation");
178 source.camera.emplace(source.focal, source.focalY, source.cx, source.cy, source.bank, source.pitch, source.heading,
180 for (const double column : {0.0, double(source.width - 1)}) for (const double row : {0.0, double(source.height - 1)})
184 if (!input.eof() || result.empty()) throw std::runtime_error("Empty or unreadable AI Camera snapshot");
bool usher_camera_profile_read(const char *filename, struct usher_camera_profile *profile)
Read a bounded PANGEA_CAMERA_V1 key=value calibration file.
Definition camera_profile.c:132
Public C API for reading PANGEA camera calibration profiles.
static bool capture(struct transport *transport, FILE *file, const struct capture_settings *settings)
Capture to the camera's SD card and download the resulting JPEG.
Definition chdkbridge.c:1463
bool coverage_project(const struct coverage_camera *camera, const struct coverage_pose *pose, double origin_latitude_deg, double origin_longitude_deg, struct coverage_footprint *footprint)
Project delivered-image corners onto a local flat ground plane.
Definition coverage_scheduler.c:46
bool exif_value_unsigned(const struct exif_value *value, size_t index, uint32_t *result)
Decode one BYTE, SHORT or LONG component without an unaligned load.
Definition exifite.c:339
int exif_parse(struct exif_view *view, const unsigned char *payload, size_t size)
Validate an EXIF APP1 payload and create a borrowed view.
Definition exifite.c:257
bool exif_get(const struct exif_view *view, enum exif_directory directory, uint16_t tag, struct exif_value *value)
Look up a directory-local tag without copying its bytes.
Definition exifite.c:310
int exif_read_jpeg(const char *filename, unsigned char *payload, size_t capacity, size_t *size)
Read the single EXIF APP1 segment before the first JPEG scan.
Definition exifite.c:1022
int exif_jpeg_dimensions(FILE *input, uint32_t *width, uint32_t *height, unsigned *components)
Inspect the frame header without allocating or decoding image pixels.
Definition exifite.c:1309
size_t exif_text_length(const struct exif_value *value)
Count text bytes after trimming trailing NUL padding only.
Definition exifite.c:399
Definition camera_optics.h:32
std::string trim(const std::string &text)
Strip the ASCII whitespace allowed around route INI tokens.
Definition route.h:130
void range(double value, double minimum, double maximum, const std::string &name)
Enforce the inclusive policy bounds for a parsed setting.
Definition route.h:160
std::vector< OrthoSource > readUsherSources(const MapConfig &config, const std::filesystem::path &manifest)
Read a photo snapshot and verify each source against profile/evidence.
Definition usher_sources.h:46
double number(const std::string &text, const std::string &name)
Read a complete finite numeric route field.
Definition route.h:141
Exact bounded SENSOR02 capture evidence, independent of TIFF byte order.
static bool sensor_capture_decode(struct sensor_capture *record, const unsigned char *data, size_t size)
Decode a complete SENSOR02 record.
Definition sensor_capture.h:136
Convex ground quadrilateral with a conservative boundary margin.
Definition coverage_scheduler.h:79
Pose estimate and its positional margin for a single observation.
Definition coverage_scheduler.h:59
double latitude_deg
Observation latitude in geographic degrees, not FC fixed-point units.
Definition coverage_scheduler.h:60
Borrowed bytes plus enough type information for safe interpretation.
Definition exifite.h:119
Fully parsed settings shared by orthomap and XYZ export.
Definition map_config.h:41
std::filesystem::path cameraProfile
Definition map_config.h:60
std::filesystem::path sourceDirectory
Definition map_config.h:59
std::filesystem::path photoDirectory
Definition map_config.h:60
One fixed-session source image and its camera/pose evidence.
Definition ortho_map.h:55
Definition sensor_capture.h:33
One measured camera calibration loaded from the flat PANGEA profile format.
Definition camera_profile.h:41