Commit 58750471 authored by Andrey Filippov's avatar Andrey Filippov

Implementing/testing interscene accumulation

parent 605aa42c
......@@ -2305,7 +2305,11 @@ public class GpuQuad{ // quad camera description
final double [] max_py = new double[num_cams] ;
for (int i = 0; i < num_cams; i++) {
min_py [i] = margin + geometryCorrection.getWOITops()[i];
max_py [i] = geometryCorrection.getWOITops()[i] + geometryCorrection.getCameraHeights()[i] - 1 - margin;
// camera_heights array is only set during conditionImageSet(), not called by the intersceneAccumulate()
// That was correct, as all scenes should be conditioned
// max_py [i] = geometryCorrection.getWOITops()[i] + geometryCorrection.getCameraHeights()[i] - 1 - margin;
max_py [i] = geometryCorrection.getSensorWH()[1] - 1 - margin;
//.getSensorWH()[0]
}
if (valid_tiles!=null) {
Arrays.fill(valid_tiles, false);
......@@ -2334,17 +2338,18 @@ public class GpuQuad{ // quad camera description
tp_task.task = task_code;
double disparity = pXpYD[nTile][2] + disparity_corr;
tp_task.target_disparity = (float) disparity; // will it be used?
double [][] disp_dist_main = new double[quad_main][]; // used to correct 3D correlations (not yet used here)
double [][] disp_dist = new double[quad_main][]; // used to correct 3D correlations (not yet used here)
double [][] centersXY_main = geometryCorrection.getPortsCoordinatesAndDerivatives(
geometryCorrection, // GeometryCorrection gc_main,
false, // boolean use_rig_offsets,
corr_rots, // Matrix [] rots,
null, // Matrix [][] deriv_rots,
null, // double [][] pXYderiv, // if not null, should be double[8][]
disp_dist_main, // used to correct 3D correlations
disp_dist, // used to correct 3D correlations
pXpYD[nTile][0],
pXpYD[nTile][1],
disparity); // + disparity_corr);
tp_task.setDispDist(disp_dist);
tp_task.xy = new float [centersXY_main.length][2];
boolean bad_margins = false;
for (int i = 0; i < centersXY_main.length; i++) {
......
......@@ -54,6 +54,18 @@ public class TpTask {
public float [][] getDispDist(){
return disp_dist;
}
public void setDispDist(float [][] disp_dist){
this.disp_dist = disp_dist;
}
public void setDispDist(double [][] disp_dist){
this.disp_dist = new float [disp_dist.length][disp_dist[0].length];
for (int i = 0; i < disp_dist.length; i++) {
for (int j = 0; j < disp_dist[0].length; j++) {
this.disp_dist[i][j] = (float) disp_dist[i][j];
}
}
}
public double [][] getDoubleDispDist(){
if (disp_dist == null) { // can it happen?
return null;
......@@ -66,10 +78,11 @@ public class TpTask {
}
return ddisp_dist;
}
@Deprecated
public float [][] getXY(boolean use_aux){
return use_aux? xy_aux : xy;
}
@Deprecated
public double [][] getDoubleXY(boolean use_aux){
float [][] fXY = getXY(use_aux);
if (fXY == null) {
......@@ -83,6 +96,23 @@ public class TpTask {
}
return dXY;
}
public float [][] getXY(){
return xy;
}
public double [][] getDoubleXY(){
float [][] fXY = getXY();
if (fXY == null) {
return null;
}
double [][] dXY = new double [fXY.length][fXY[0].length];
for (int nsens = 0; nsens < fXY.length; nsens++) {
for (int i = 0; i < fXY[nsens].length; i++) {
dXY[nsens][i] = fXY[nsens][i];
}
}
return dXY;
}
......
......@@ -2024,7 +2024,7 @@ public class Corr2dLMA {
double lambda,
double [][] jt){
int num_pars = jt.length;
int nup_points = jt[0].length;
int nup_points = (num_pars > 0)? jt[0].length : 0;
double [][] wjtjl = new double [num_pars][num_pars];
for (int i = 0; i < num_pars; i++) {
for (int j = i; j < num_pars; j++) {
......
......@@ -274,6 +274,10 @@ public class Correlation2d {
return pair_start_end.length;
}
public static int getNumPairs(int numSensors) {
return numSensors * (numSensors-1) /2;
}
public void setCorrPairs(boolean [] sel) { // these pairs will be correlated
corr_pairs = sel.clone();
}
......@@ -782,7 +786,7 @@ public class Correlation2d {
true, // boolean normalize,
true, // boolean notch,
wndx_scale); // double scale);
int num_pairs = numSensors * (numSensors-1) /2;
int num_pairs = getNumPairs(numSensors);// numSensors * (numSensors-1) /2;
pair_start_end = new int [num_pairs][2];
pair_orient = new int [num_pairs][num_pairs];
pair_length = new int [num_pairs];
......
......@@ -371,7 +371,7 @@ public class ErsCorrection extends GeometryCorrection {
public void addScene(String timestamp, double [] xyz, double [] atr, double [] ers_xyz_dt, double [] ers_atr_dt) {
scenes_poses.put(timestamp, new XyzAtr(xyz, atr, ers_xyz_dt, ers_atr_dt));
}
//not used
public void addScene(String timestamp, double [] xyz, double [] atr, double [] ers_xyz_dt, double [] ers_atr_dt, double [] ers_xyz_d2t, double [] ers_atr_d2t) {
scenes_poses.put(timestamp, new XyzAtr(xyz, atr, ers_xyz_dt, ers_atr_dt, ers_xyz_d2t, ers_atr_d2t));
}
......
......@@ -336,7 +336,7 @@ public class ImageDtt extends ImageDttCPU {
fdisp_dist[task.getTileY()][task.getTileX()] = task.getDispDist();
}
if (fpxpy != null) {
fpxpy[task.getTileY()][task.getTileX()] = task.getXY(use_main); // boolean use_aux);
fpxpy[task.getTileY()][task.getTileX()] = task.getXY(); // use_main); // boolean use_aux);
}
} // end of tile
}
......@@ -1171,7 +1171,7 @@ public class ImageDtt extends ImageDttCPU {
fdisp_dist[task.getTileY()][task.getTileX()] = task.getDispDist();
}
if (fpxpy != null) {
fpxpy[task.getTileY()][task.getTileX()] = task.getXY(use_main); // boolean use_aux);
fpxpy[task.getTileY()][task.getTileX()] = task.getXY(); // use_main); // boolean use_aux);
}
} // end of tile
}
......@@ -1193,7 +1193,7 @@ public class ImageDtt extends ImageDttCPU {
for (int indx_tile = ai.getAndIncrement(); indx_tile < tp_tasks_full.length; indx_tile = ai.getAndIncrement()) {
TpTask task = tp_tasks_full[indx_tile];
if (fpxpy != null) {
fpxpy_test[task.getTileY()][task.getTileX()] = task.getXY(use_main); // boolean use_aux);
fpxpy_test[task.getTileY()][task.getTileX()] = task.getXY(); // use_main); // boolean use_aux);
}
} // end of tile
}
......
......@@ -28,6 +28,7 @@ import java.util.Properties;
import com.elphel.imagej.common.GenericJTabbedDialog;
public class OpticalFlowParameters {
public double scale_no_lma_disparity = 1.0; // multiply strength were disparity_lma = NaN;
public double k_prev = 0.75;
public double ers_to_pose_scale = 0.75;
public double tolerance_absolute_ref = 0.25; // absolute disparity half-range in each tile
......@@ -75,6 +76,8 @@ public class OpticalFlowParameters {
public boolean enable_debug_images = true;
public void dialogQuestions(GenericJTabbedDialog gd) {
gd.addNumericField("Scale strength for the tiles with no LMA disparity", this.scale_no_lma_disparity,3,6,"",
"Reduce strength (but kip less reliable CM-measured disparity for the tiles with no disparity measured with LMA");
gd.addMessage("Intraframe ERS to pose");
gd.addNumericField("Previous (in time) frame weight (0.75)", this.k_prev, 3,6,"",
"Earlier frame ERS was sampled closer to interframe");
......@@ -165,6 +168,7 @@ public class OpticalFlowParameters {
}
public void dialogAnswers(GenericJTabbedDialog gd) {
this.scale_no_lma_disparity = gd.getNextNumber();
this.k_prev = gd.getNextNumber();
this.ers_to_pose_scale = gd.getNextNumber();
this.tolerance_absolute_ref = gd.getNextNumber();
......@@ -209,6 +213,7 @@ public class OpticalFlowParameters {
}
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"scale_no_lma_disparity", this.scale_no_lma_disparity+"");
properties.setProperty(prefix+"k_prev", this.k_prev+"");
properties.setProperty(prefix+"ers_to_pose_scale", this.ers_to_pose_scale+"");
properties.setProperty(prefix+"tolerance_absolute_ref", this.tolerance_absolute_ref+"");
......@@ -250,6 +255,7 @@ public class OpticalFlowParameters {
}
public void getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"scale_no_lma_disparity")!=null) this.scale_no_lma_disparity=Double.parseDouble(properties.getProperty(prefix+"scale_no_lma_disparity"));
if (properties.getProperty(prefix+"k_prev")!=null) this.k_prev=Double.parseDouble(properties.getProperty(prefix+"k_prev"));
if (properties.getProperty(prefix+"ers_to_pose_scale")!=null) this.ers_to_pose_scale=Double.parseDouble(properties.getProperty(prefix+"ers_to_pose_scale"));
if (properties.getProperty(prefix+"tolerance_absolute_ref")!=null) this.tolerance_absolute_ref=Double.parseDouble(properties.getProperty(prefix+"tolerance_absolute_ref"));
......@@ -294,6 +300,7 @@ public class OpticalFlowParameters {
@Override
public OpticalFlowParameters clone() throws CloneNotSupportedException {
OpticalFlowParameters ofp = new OpticalFlowParameters();
ofp.scale_no_lma_disparity = this.scale_no_lma_disparity;
ofp.k_prev = this.k_prev;
ofp.ers_to_pose_scale = this.ers_to_pose_scale;
ofp.tolerance_absolute_ref = this.tolerance_absolute_ref;
......
......@@ -3491,7 +3491,7 @@ public class QuadCLT extends QuadCLTCPU {
double [][] ports_xy = new double [tilesY*tilesX][];
TpTask [] tp_tasks = gpuQuad.getTasks(use_aux); // use_aux);
for (TpTask tp_task:tp_tasks) {
float [][] txy = tp_task.getXY(use_aux);
float [][] txy = tp_task.getXY(); // use_aux);
double [] tile_ports_xy = new double [txy.length * txy[0].length];
int indx = 0;
for (int i = 0; i < txy.length; i++) {
......@@ -3616,6 +3616,7 @@ public class QuadCLT extends QuadCLTCPU {
return disparity_map;
}
@Deprecated
public double [][] CLTCorrDisparityMapCPUTasks(
String suffix,
CLTParameters clt_parameters,
......
......@@ -314,7 +314,7 @@ public class QuadCLTCPU {
System.out.println ("Failed to open "+file_path);
return -1;
}
System.out.println("restoreDSI(): got "+imp.getStackSize()+" slices");
System.out.println("restoreDSI(): got "+imp.getStackSize()+" slices from file: "+file_path);
if (imp.getStackSize() < 2) {
System.out.println ("Failed to read "+file_path);
return -1;
......@@ -359,7 +359,9 @@ public class QuadCLTCPU {
path = x3d_path+Prefs.getFileSeparator()+path;
}
Properties inter_properties = new Properties();
setProperties(QuadCLT.PREFIX,inter_properties);
String prefix = is_aux?PREFIX_AUX:PREFIX;
// setProperties(QuadCLT.PREFIX,inter_properties);
setProperties(prefix,inter_properties);
// quadCLT_aux.setProperties(QuadCLT.PREFIX_AUX,properties);
OutputStream os;
try {
......@@ -433,6 +435,7 @@ public class QuadCLTCPU {
ers.getPropertiesERS(prefix, properties);
ers.getPropertiesScenes(prefix, properties);
ers.getPropertiesLineTime(prefix, properties); // will set old value if not in the file
System.out.println("Restored interframe properties from :"+path);
return properties;
}
......@@ -443,8 +446,10 @@ public class QuadCLTCPU {
}
public String [] getDSRGGTiltes() {
return isMonochrome()?
(new String[]{"disparity","strength", "disparity_lma","Y"}):
(new String[]{"disparity","strength", "disparity_lma","R","B","G"});
// (new String[]{"disparity","strength", "disparity_lma","Y"}):
// (new String[]{"disparity","strength", "disparity_lma","R","B","G"});
(new String[]{"disparity","strength", "Y"}):
(new String[]{"disparity","strength", "R","B","G"});
}
public void setDSRBG(
......@@ -471,6 +476,17 @@ public class QuadCLTCPU {
boolean updateStatus,
int debugLevel)
{
double snld = clt_parameters.ofp.scale_no_lma_disparity;
if ((snld != 1.0) && (disparity_lma != null)) {
strength = strength.clone();
for (int i = 0; i < strength.length; i++) {
if (Double.isNaN(disparity_lma[i])) {
strength[i] *= snld;
}
}
}
double[][] rbg = getTileRBG(
clt_parameters,
disparity,
......@@ -483,13 +499,13 @@ public class QuadCLTCPU {
this.dsrbg = new double[][] {
disparity,
strength,
disparity_lma,
// disparity_lma,
rbg[2]};
} else {
this.dsrbg = new double[][] {
disparity,
strength,
disparity_lma,
// disparity_lma,
rbg[0],rbg[1],rbg[2]};
}
if (debugLevel > 1) { // -2) {
......@@ -943,15 +959,22 @@ public class QuadCLTCPU {
0); // int jpegQuality)
}
public void showDSIMain() {
showDSIMain(this.dsi);
showDSIMain(
this.dsi,
isAux());
}
public void showDSIMain(
double [][] dsi)
double [][] dsi,
boolean use_aux)
{
String title = image_name+"-DSI_MAIN";
String [] titles = {TwoQuadCLT.DSI_SLICES[TwoQuadCLT.DSI_DISPARITY_MAIN], TwoQuadCLT.DSI_SLICES[TwoQuadCLT.DSI_STRENGTH_MAIN]};
double [][] dsi_main = {dsi[TwoQuadCLT.DSI_DISPARITY_MAIN], dsi[TwoQuadCLT.DSI_STRENGTH_MAIN]};
String [] titles = {
TwoQuadCLT.DSI_SLICES[use_aux?TwoQuadCLT.DSI_DISPARITY_AUX:TwoQuadCLT.DSI_DISPARITY_MAIN],
TwoQuadCLT.DSI_SLICES[use_aux?TwoQuadCLT.DSI_STRENGTH_AUX:TwoQuadCLT.DSI_STRENGTH_MAIN]};
double [][] dsi_main = {
dsi[use_aux?TwoQuadCLT.DSI_DISPARITY_AUX:TwoQuadCLT.DSI_DISPARITY_MAIN],
dsi[use_aux?TwoQuadCLT.DSI_STRENGTH_AUX:TwoQuadCLT.DSI_STRENGTH_MAIN]};
(new ShowDoubleFloatArrays()).showArrays(dsi_main,tp.getTilesX(), tp.getTilesY(), true, title, titles);
}
......
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