Commit 0594db87 authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: fix lwir recalibration persistence targets

The virtual -CENTER INTERFRAME corr-xml only carries poses/velocities, so
saving the recalculated 16+16 lwir offsets/scales there was futile. Follow
the established photometric machinery (runPhotometric()/photoEach()) and
the top-menu save/restore convention instead: set the new values on
master_CLT (immediate use), quadCLTs[ref_index] (physical photometric
owner, its <scene>-INTERFRAME.corr-xml is saved) and quadCLT_main (applied
to next sequences and saved in the main configuration file).
Co-Authored-By: 's avatarClaude Fable 5 <noreply@anthropic.com>
parent ebef0b23
......@@ -3943,23 +3943,26 @@ public class CuasMotion {
* scale' = b * scale
* offset' = offset - a / scale'
* (the residual per-pixel term (1-b)*FPN(p) is second order - b is within ~15% of 1 and the FPN map is
* recomputed against the new photometric anyway). The offsets/scales are taken from the physical scene that
* conditioned the fitted images, updated on the calibration-carrier center instance together with the
* photometric_scene provenance marker, and written to &lt;name&gt;-ims.corr-xml via saveInterProperties().
* recomputed against the new photometric anyway). Persistence mimics the established photometric machinery
* (runPhotometric()/photoEach()): the values are set on the PHYSICAL reference scene and its
* &lt;scene&gt;-INTERFRAME.corr-xml is saved (the virtual -CENTER INTERFRAME file only carries poses/velocities),
* plus on quadCLT_main so they apply to the next sequences and are saved in the main configuration file.
* By Claude on 07/02/2026.
* @param center_CLT calibration carrier (virtual "-CENTER"): updated in memory and its corr-xml saved.
* @param phys_scene the physical scene whose current offsets/scales produced the fitted conditioned images.
* @param apply_to instances to update in memory (e.g. {physical reference scene, center_CLT, quadCLT_main});
* nulls and duplicates are allowed and handled.
* @param save_scene whose &lt;scene&gt;-INTERFRAME.corr-xml to save (the photometric owner - normally the
* physical reference scene quadCLTs[ref_index]); null - do not save, update in memory only.
* @param a per-sensor additive corrections from {@link #perSensorLinearFit}.
* @param b per-sensor multiplicative corrections from {@link #perSensorLinearFit}.
* @param save_corr_xml write the updated calibration to the center's corr-xml (false - update in memory only).
* @param debugLevel debug verbosity.
*/
public static void applyLwirLinearCalibration( // By Claude on 07/02/2026
QuadCLT center_CLT,
QuadCLT phys_scene,
QuadCLT [] apply_to,
QuadCLT save_scene,
double [] a,
double [] b,
boolean save_corr_xml,
int debugLevel) {
final int num_sens = a.length;
final double [] offsets = phys_scene.getLwirOffsets(); // current (what conditioned the fitted images)
......@@ -3967,7 +3970,7 @@ public class CuasMotion {
final double [] offsets_new = new double [num_sens];
final double [] scales_new = new double [num_sens];
System.out.println("applyLwirLinearCalibration(): recalculated per-sensor lwir offsets/scales"+
(save_corr_xml? " (saving to corr-xml)":" (in-memory only)"));
((save_scene != null)? " (saving to "+save_scene.getImageName()+" INTERFRAME corr-xml)":" (in-memory only)"));
System.out.println(" s | offset old -> offset new | scale old -> scale new");
for (int s = 0; s < num_sens; s++) {
scales_new[s] = b[s]*scales[s];
......@@ -3975,11 +3978,16 @@ public class CuasMotion {
System.out.println(String.format("%2d | %12.3f -> %12.3f | %8.5f -> %8.5f",
s, offsets[s], offsets_new[s], scales[s], scales_new[s]));
}
center_CLT.setLwirOffsets(offsets_new);
center_CLT.setLwirScales(scales_new);
center_CLT.setPhotometricScene(phys_scene.getImageName()); // provenance: recalibrated on this scene
if (save_corr_xml) {
center_CLT.saveInterProperties( // writes <image_name>-ims.corr-xml into the x3d directory
final String photometric_scene = phys_scene.getImageName(); // provenance: recalibrated on this scene
if (apply_to != null) {
for (QuadCLT qclt : apply_to) if (qclt != null) { // duplicates are harmless (idempotent set)
qclt.setLwirOffsets(offsets_new.clone());
qclt.setLwirScales (scales_new.clone());
qclt.setPhotometricScene(photometric_scene);
}
}
if (save_scene != null) {
save_scene.saveInterProperties( // writes <scene>-INTERFRAME.corr-xml into its x3d directory
null, // String path - null: default name in the x3d directory
debugLevel);
}
......
......@@ -7303,13 +7303,19 @@ java.lang.NullPointerException
true, // boolean save_adjusted (-CUAS-PERSENSOR-ADJ)
debugLevel, // int debugLevel
true); // boolean keep_averages: average offset = 0, average scale = 1.0
if (ab != null) { // recalculate the 16+16 lwir offsets/scales, save to the center corr-xml
CuasMotion.applyLwirLinearCalibration( // By Claude on 07/02/2026
master_CLT, // QuadCLT center_CLT (calibration carrier, corr-xml save)
if (ab != null) { // recalculate the 16+16 lwir offsets/scales (like runPhotometric()/photoEach())
// By Claude on 07/02/2026: top-menu-saved/restored parameters are applied to master_CLT,
// so quadCLT_main is the durable carrier (main configuration file); the physical reference
// scene's -INTERFRAME.corr-xml gets the in-run copy (the -CENTER file only carries poses).
CuasMotion.applyLwirLinearCalibration(
cond_phys, // QuadCLT phys_scene (its offsets/scales conditioned the fit input)
new QuadCLT [] { // QuadCLT [] apply_to (in-memory)
master_CLT, // immediate use in this run
quadCLTs[ref_index], // physical reference scene (photometric owner)
quadCLT_main}, // next sequences + saved in the main config file
quadCLTs[ref_index], // QuadCLT save_scene -> <scene>-INTERFRAME.corr-xml
ab[0], // double [] a,
ab[1], // double [] b,
true, // boolean save_corr_xml
debugLevel); // int debugLevel
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment