Commit 6da17148 authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: JNA imclt ref_scene fix + one-shot ref/scene post-mortem renders (TEMP)

(1) GpuQuadJna.execImcltRbgAll now passes ref_scene -> tp_proc_exec_imclt(use_ref)
so renderFromTD(true) renders gpu_clt_ref, not gpu_clt (TpJna binding updated).

(2) TEMP post-mortem in CuasMotion.correlatePair (gate -Dtp.dbg.corrpair=1,
one-shot): after the inter-correlation, SAVE ref (gpu_clt_ref) + scene (gpu_clt)
CLT renders to the model dir via saveImagePlusInModelDirectory (persist past the
later crash; no window flood). DBG-REF blank/NaN => reference not loaded =>
explains the all-NaN CORR2D (inter corr needs both images). REMOVE after fix.

Needs the tile_processor_gpu imclt use_ref commit + libtileproc.so rebuild.
Co-Authored-By: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
parent f8a7a972
...@@ -275,6 +275,7 @@ public class CuasMotion { ...@@ -275,6 +275,7 @@ public class CuasMotion {
private double [] noise_map8 = null; private double [] noise_map8 = null;
private int [] noise_neibs = null; private int [] noise_neibs = null;
private int debugLevel = 0; private int debugLevel = 0;
private boolean corrpair_dbg_done = false; // TEMP post-mortem one-shot flag (By Claude 06/26/2026), remove with the -Dtp.dbg.corrpair probe
private GpuQuad gpuQuad = null; private GpuQuad gpuQuad = null;
private ImageDtt image_dtt = null; private ImageDtt image_dtt = null;
private int gpu_max_width; private int gpu_max_width;
...@@ -2904,8 +2905,31 @@ public class CuasMotion { ...@@ -2904,8 +2905,31 @@ public class CuasMotion {
renderFromTD(false, "img"+dbg_suffix); renderFromTD(false, "img"+dbg_suffix);
} }
TDCorrTile [] tdCorrTiles = TDCorrTile.getFromGpu(gpuQuad); TDCorrTile [] tdCorrTiles = TDCorrTile.getFromGpu(gpuQuad);
// TEMP post-mortem (By Claude 06/26/2026): one-shot SAVE of reference + scene CLT renders (GPU->back)
// to localize the CORR2D-all-NaN divergence — is gpu_clt_ref actually populated? Both buffers are
// current here (ref from setRectilinearReferenceTD, scene from interRectilinearCorrTD). Saved (not
// shown) so they persist post-mortem; one-shot so no flood. Gate: -Dtp.dbg.corrpair=1. REMOVE after fix.
if (!corrpair_dbg_done && "1".equals(System.getProperty("tp.dbg.corrpair"))) {
corrpair_dbg_done = true;
String sfx = (dbg_suffix == null) ? "" : dbg_suffix;
saveTDRender(true, "DBG-REF"+sfx); // gpu_clt_ref render — blank/NaN => reference not loaded
saveTDRender(false, "DBG-IMG"+sfx); // gpu_clt render (scene) — expected OK (matches SOURCE)
}
return tdCorrTiles; return tdCorrTiles;
} }
// TEMP post-mortem helper (By Claude 06/26/2026): imclt the selected CLT buffer (ref/scene) back to an
// image and SAVE it to the model directory (persists after the run). REMOVE with the probe above.
private void saveTDRender(boolean use_reference, String title) {
gpuQuad.execImcltRbgAll(gpuQuad.getNumColors() <= 1, use_reference, null);
float [][] rbg = gpuQuad.getRBG(0); // single-camera rectilinear
ImagePlus imp = ShowDoubleFloatArrays.makeArrays(
rbg, gpuQuad.getImageWidth(), gpuQuad.getImageHeight(), title, null);
if (imp != null) {
parentCLT.saveImagePlusInModelDirectory(imp);
System.out.println("saveTDRender(): saved post-mortem render '"+title+"' (use_reference="+use_reference+")");
}
}
public float [][] shiftAndRenderAccumulate( public float [][] shiftAndRenderAccumulate(
CLTParameters clt_parameters, CLTParameters clt_parameters,
......
...@@ -274,7 +274,7 @@ public class GpuQuadJna extends GpuQuad { ...@@ -274,7 +274,7 @@ public class GpuQuadJna extends GpuQuad {
// ---- inverse CLT -> RBG ---- // ---- inverse CLT -> RBG ----
@Override public void execImcltRbgAll(boolean is_mono, boolean ref_scene, int[] wh) { @Override public void execImcltRbgAll(boolean is_mono, boolean ref_scene, int[] wh) {
ensureRbgCorr(); ensureRbgCorr();
lib.tp_proc_exec_imclt(proc, 1); // apply_lpf = 1 lib.tp_proc_exec_imclt(proc, 1, ref_scene ? 1 : 0); // apply_lpf = 1; honor ref_scene (gpu_clt_ref). By Claude 06/26/2026.
} }
@Override public float[][] getRBG(int ncam) { @Override public float[][] getRBG(int ncam) {
int out_width = getImageWidth(), out_height = getImageHeight(); int out_width = getImageWidth(), out_height = getImageHeight();
......
...@@ -83,7 +83,7 @@ public interface TpJna extends Library { ...@@ -83,7 +83,7 @@ public interface TpJna extends Library {
/** Allocate imclt(RBG) + correlation buffers and store corr config. */ /** Allocate imclt(RBG) + correlation buffers and store corr config. */
int tp_proc_setup_rbg_corr(Pointer proc, int numPairs, int s0,int s1,int s2,int s3, int tp_proc_setup_rbg_corr(Pointer proc, int numPairs, int s0,int s1,int s2,int s3,
float cw0,float cw1,float cw2, int corrOutRad); float cw0,float cw1,float cw2, int corrOutRad);
int tp_proc_exec_imclt(Pointer proc, int applyLpf); int tp_proc_exec_imclt(Pointer proc, int applyLpf, int useRef);
int tp_proc_get_rbg(Pointer proc, int cam, float[] out); int tp_proc_get_rbg(Pointer proc, int cam, float[] out);
int tp_proc_exec_corr2d(Pointer proc, double fatZero); int tp_proc_exec_corr2d(Pointer proc, double fatZero);
/** de-pitch quad correlation; returns num_corr_combo. */ /** de-pitch quad correlation; returns num_corr_combo. */
......
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