Commit e64fe051 authored by Andrey Filippov's avatar Andrey Filippov

updated version working

parent 7f9773fb
...@@ -175,7 +175,7 @@ public class ComboMatch { ...@@ -175,7 +175,7 @@ public class ComboMatch {
boolean display_pairs = false; boolean display_pairs = false;
boolean create_map = false; boolean create_map = false;
boolean create_equalize = false; boolean create_equalize = false;
boolean use_saved_collection = false; // true; // false; boolean use_saved_collection = true; // false;
boolean save_collection = false; // true; boolean save_collection = false; // true;
boolean process_correlation = true; // use false to save new version of data boolean process_correlation = true; // use false to save new version of data
int num_tries_fit = 10; int num_tries_fit = 10;
...@@ -339,7 +339,7 @@ public class ComboMatch { ...@@ -339,7 +339,7 @@ public class ComboMatch {
maps_collection = OrthoMapsCollection.readOrthoMapsCollection (orthoMapsCollection_path); maps_collection = OrthoMapsCollection.readOrthoMapsCollection (orthoMapsCollection_path);
} catch (ClassNotFoundException | IOException e) { } catch (ClassNotFoundException | IOException e) {
use_files_list = true; use_files_list = true;
System.out.println("Saved data not found: "+orthoMapsCollection_path+", building from a list "+files_list_path); System.out.println("Saved data not found (or is corrupt): "+orthoMapsCollection_path+", building from a list "+files_list_path);
} }
//files_list_path //files_list_path
if (!use_files_list) { if (!use_files_list) {
...@@ -361,10 +361,12 @@ public class ComboMatch { ...@@ -361,10 +361,12 @@ public class ComboMatch {
} }
if (import_export) { if (import_export) {
return updateImportExport( boolean OK = updateImportExport(
omtch_img_set, // String files_base omtch_img_set, // String files_base
maps_collection); // OrthoMapsCollection maps_collection maps_collection); // OrthoMapsCollection maps_collection
if (!OK) {
return false;
}
} }
...@@ -867,7 +869,7 @@ public class ComboMatch { ...@@ -867,7 +869,7 @@ public class ComboMatch {
maps_collection.processComboMap( maps_collection.processComboMap(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
debugLevel); debugLevel);
return true; // return true; // need to save AGL?
} }
// for all modes - needed for create_overlaps || process_correlation || render_match || pattern_match // for all modes - needed for create_overlaps || process_correlation || render_match || pattern_match
...@@ -2689,7 +2691,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341 ...@@ -2689,7 +2691,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341
gd.addStringField ("Scene affines full path", affines_path, 150, "Path to import/export scenes affines."); gd.addStringField ("Scene affines full path", affines_path, 150, "Path to import/export scenes affines.");
gd.addStringField ("Pairwise affines full path", affines2_path, 150, "Path to import/export scenes pairs affines."); gd.addStringField ("Pairwise affines full path", affines2_path, 150, "Path to import/export scenes pairs affines.");
gd.addCheckbox ("Update scene files", update_files, "Re-read files as specified in .list file, possibly changing versions"); gd.addCheckbox ("Update scene files", update_files, "Re-read files as specified in .list file, possibly changing versions");
gd.addCheckbox ("Update files metadata", update_lla, "Re-read files metadata (if it was modified)"); gd.addCheckbox ("Update files metadata", update_lla, "Re-read files metadata (if it was modified), needed to calculate AGL.");
gd.addCheckbox ("Update kernels/patterns", update_kernel_patterns, "Re-read kernels and patterns from *.list file"); gd.addCheckbox ("Update kernels/patterns", update_kernel_patterns, "Re-read kernels and patterns from *.list file");
gd.addCheckbox ("Export scene affines", export_affine, "Export per-scene affines in text format for migration."); gd.addCheckbox ("Export scene affines", export_affine, "Export per-scene affines in text format for migration.");
gd.addCheckbox ("Export pairs affines", export_affine2, "Export per-pair affines in text format for migration."); gd.addCheckbox ("Export pairs affines", export_affine2, "Export per-pair affines in text format for migration.");
...@@ -2726,7 +2728,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341 ...@@ -2726,7 +2728,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341
if (update_lla) { if (update_lla) {
System.out.println("Updating map files metadata"); System.out.println("Updating map files metadata");
maps_collection.updateLLA(); maps_collection.updateLLA();
maps_collection.updateNumberScenes(); // maps_collection.updateNumberScenes(); It is very long
maps_collection.updateSfmGain(); maps_collection.updateSfmGain();
} }
if (update_kernel_patterns) { if (update_kernel_patterns) {
...@@ -2807,14 +2809,14 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341 ...@@ -2807,14 +2809,14 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341
} }
} }
} }
maps_collection.updateNumberScenes(); // maps_collection.updateNumberScenes();
System.out.println("Updated "+num_updated_affines+" affines of "+affine_import.size()+" specified. There are "+ System.out.println("Updated "+num_updated_affines+" affines of "+affine_import.size()+" specified. There are "+
maps_collection.ortho_maps.length+" maps in the system."); maps_collection.ortho_maps.length+" maps in the system.");
} }
if (import_affine2) { if (import_affine2) {
ArrayList<Affine2Import> affine2_import = new ArrayList<Affine2Import>(); ArrayList<Affine2Import> affine2_import = new ArrayList<Affine2Import>();
OrthoMapsCollection.getPathsAndScenesFromSourceList( OrthoMapsCollection.getPathsAndScenesFromSourceList(
affines_path, affines2_path,
null, // scenes0, null, // scenes0,
null, // ArrayList<AltitudeMismatchKernel> kernels, null, // ArrayList<AltitudeMismatchKernel> kernels,
null, // ArrayList<GroundObjectPattern> patterns); null, // ArrayList<GroundObjectPattern> patterns);
...@@ -2823,6 +2825,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341 ...@@ -2823,6 +2825,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341
null, // ArrayList<AffineImport> affine_import, null, // ArrayList<AffineImport> affine_import,
affine2_import); // ArrayList<Affine2Import> affine2_import) { affine2_import); // ArrayList<Affine2Import> affine2_import) {
int num_updated_affines = 0; int num_updated_affines = 0;
int num_new_affines = 0;
for (Affine2Import affine2Import: affine2_import) { for (Affine2Import affine2Import: affine2_import) {
OrthoMap map = maps_collection.getMap(affine2Import.name1); OrthoMap map = maps_collection.getMap(affine2Import.name1);
if (map != null) { if (map != null) {
...@@ -2831,6 +2834,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341 ...@@ -2831,6 +2834,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341
if (overwrite_affine || !pom.isAffineNonTrivial()) { if (overwrite_affine || !pom.isAffineNonTrivial()) {
pom.setOverlap(affine2Import.overlap); pom.setOverlap(affine2Import.overlap);
pom.setAffine(affine2Import.affine); // does not clone - OK pom.setAffine(affine2Import.affine); // does not clone - OK
num_updated_affines++;
} }
} else { } else {
OrthoMap map2 = maps_collection.getMap(affine2Import.name2); OrthoMap map2 = maps_collection.getMap(affine2Import.name2);
...@@ -2841,15 +2845,12 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341 ...@@ -2841,15 +2845,12 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341
Double.NaN, // double rms, Double.NaN, // double rms,
zoom_lev, // int zoom_lev, zoom_lev, // int zoom_lev,
affine2Import.overlap); // double overlap) affine2Import.overlap); // double overlap)
map.setMatch(map2.getName(), pom);
num_new_affines++;
} }
} }
} }
System.out.println("Updated "+num_updated_affines+" pairwise affines, setup new "+num_new_affines+" matches. Specified "+affine2_import.size()+" matches.");
} }
if (update_bl_bc) { if (update_bl_bc) {
......
...@@ -201,16 +201,16 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ ...@@ -201,16 +201,16 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
} }
public int getWidth() { public int getWidth() {
return getImageData().getWidth(); // orig_width; return getImage().getWidth(); // orig_width;
} }
public int getHeight() { public int getHeight() {
return getImageData().getHeight(); //orig_height; return getImage().getHeight(); //orig_height;
} }
public int getAltWidth() { public int getAltWidth() {
return getAltData().getWidth(); // orig_width; return getAlt().getWidth(); // orig_width;
} }
public int getAltHeight() { public int getAltHeight() {
return getAltData().getHeight(); //orig_height; return getAlt().getHeight(); //orig_height;
} }
public void setMatch( public void setMatch(
......
...@@ -62,8 +62,9 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -62,8 +62,9 @@ public class OrthoMapsCollection implements Serializable{
public static final int VERSION_PRE_ORIENT = 100; public static final int VERSION_PRE_ORIENT = 100;
public static final int VERSION_POST_ORIENT = 101; public static final int VERSION_POST_ORIENT = 101;
public static final int VERSION_ORANGE = 102;
public static int LATEST_VERSION = VERSION_POST_ORIENT; // 100; // use when read from .list public static int LATEST_VERSION = VERSION_ORANGE; // 100; // use when read from .list
/// public transient int current_version = LATEST_VERSION; /// public transient int current_version = LATEST_VERSION;
public static int CURRENT_VERSION = LATEST_VERSION; public static int CURRENT_VERSION = LATEST_VERSION;
...@@ -341,14 +342,19 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -341,14 +342,19 @@ public class OrthoMapsCollection implements Serializable{
System.out.println("updateLLa(): n="+n); System.out.println("updateLLa(): n="+n);
} }
ortho_maps[n].updateLLA(); ortho_maps[n].updateLLA();
IJ.showStatus("Updating LLA "+n+" of "+ortho_maps.length);
IJ.showProgress(1.0*n/ortho_maps.length);
} }
updateAGL(); updateAGL();
} }
public void updateAGL() { public void updateAGL() {
for (int n = 0; n < ortho_maps.length; n++) { for (int n = 0; n < ortho_maps.length; n++) {
IJ.showStatus("Updating AGL "+n+" of "+ortho_maps.length);
ortho_maps[n].agl = Double.NaN; ortho_maps[n].agl = Double.NaN;
ortho_maps[n].agl = ortho_maps[n].getAGL(); ortho_maps[n].agl = ortho_maps[n].getAGL();
IJ.showProgress(1.0*n/ortho_maps.length);
} }
} }
...@@ -7122,7 +7128,11 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -7122,7 +7128,11 @@ public class OrthoMapsCollection implements Serializable{
for (int nscene=0; nscene<indices.length; nscene++) { for (int nscene=0; nscene<indices.length; nscene++) {
int indx = indices[nscene]; int indx = indices[nscene];
System.out.println("Scene="+indx+", agl="+ortho_maps[indx].getAGL()); System.out.println("Scene="+indx+", agl="+ortho_maps[indx].getAGL());
double [] qorient = ortho_maps[indx].getQOrinet(); // QuatUtils.invert(ortho_maps[indx].getQOrinet()); double [] qorient = ortho_maps[indx].getQOrinet(); // QuatUtils.invert(ortho_maps[indx].getQOrinet());
if (qorient == null) {
qorient = new double [] {1,0,0,0};
}
final int src_width = ortho_maps[indx].getImageData().width; // assuming same image size for alt and texture final int src_width = ortho_maps[indx].getImageData().width; // assuming same image size for alt and texture
final int src_height = ortho_maps[indx].getImageData().height; // assuming same image size for alt and texture final int src_height = ortho_maps[indx].getImageData().height; // assuming same image size for alt and texture
final double [] image_data = ortho_maps[indx].getImageData().getDData(); final double [] image_data = ortho_maps[indx].getImageData().getDData();
......
...@@ -49,9 +49,13 @@ public class PairwiseOrthoMatch implements Serializable { ...@@ -49,9 +49,13 @@ public class PairwiseOrthoMatch implements Serializable {
private void writeObject(ObjectOutputStream oos) throws IOException { private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject(); oos.defaultWriteObject();
for (int i = 0; i < jtj.length; i++) { if (jtj == null) {
for (int j = i; j < jtj[i].length; j++) { oos.writeObject(Double.NaN);
oos.writeObject(jtj[i][j]); } else {
for (int i = 0; i < jtj.length; i++) {
for (int j = i; j < jtj[i].length; j++) {
oos.writeObject(jtj[i][j]);
}
} }
} }
// oos.writeObject(overlap); // oos.writeObject(overlap);
...@@ -64,14 +68,19 @@ public class PairwiseOrthoMatch implements Serializable { ...@@ -64,14 +68,19 @@ public class PairwiseOrthoMatch implements Serializable {
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject(); ois.defaultReadObject();
jtj = new double [6][6]; // readObject does not use constructor! jtj = new double [6][6]; // readObject does not use constructor!
for (int i = 0; i < jtj.length; i++) { readjtj:
for (int j = i; j < jtj[i].length; j++) { for (int i = 0; i < jtj.length; i++) {
jtj[i][j] = (Double) ois.readObject(); for (int j = i; j < jtj[i].length; j++) {
if (j > i) { jtj[i][j] = (Double) ois.readObject();
jtj[j][i] = jtj[i][j]; if (Double.isNaN(jtj[0][0]) && (i==0) && (j==0)) {
jtj=null;
break readjtj;
}
if (j > i) {
jtj[j][i] = jtj[i][j];
}
} }
} }
}
// overlap = (Double) ois.readObject(); // overlap = (Double) ois.readObject();
// equalize1to0 = new double[] {1,0}; // equalize1to0 = new double[] {1,0};
// equalize1to0 = (double[]) ois.readObject(); // equalize1to0 = (double[]) ois.readObject();
...@@ -79,8 +88,8 @@ public class PairwiseOrthoMatch implements Serializable { ...@@ -79,8 +88,8 @@ public class PairwiseOrthoMatch implements Serializable {
// alt_data = (double[]) ois.readObject(); // alt_data = (double[]) ois.readObject();
// } // }
// if (OrthoMapsCollection.CURRENT_VERSION >= OrthoMapsCollection.VERSION_POST_ORIENT) { // if (OrthoMapsCollection.CURRENT_VERSION >= OrthoMapsCollection.VERSION_POST_ORIENT) {
quat= (double[]) ois.readObject(); // quat= (double[]) ois.readObject();
qaffine = (double[][]) ois.readObject(); // qaffine = (double[][]) ois.readObject();
// } // }
} }
......
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