Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
c430b2f4
Commit
c430b2f4
authored
May 26, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more cleanup
parent
95647831
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
585 additions
and
88 deletions
+585
-88
EyesisCorrectionParameters.java
...com/elphel/imagej/cameras/EyesisCorrectionParameters.java
+20
-3
CLTPass3d.java
src/main/java/com/elphel/imagej/tileprocessor/CLTPass3d.java
+3
-1
IntersceneMatchParameters.java
...lphel/imagej/tileprocessor/IntersceneMatchParameters.java
+75
-2
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+294
-27
QuadCLT.java
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
+3
-4
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+169
-47
TwoQuadCLT.java
...main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
+21
-4
No files found.
src/main/java/com/elphel/imagej/cameras/EyesisCorrectionParameters.java
View file @
c430b2f4
...
@@ -138,6 +138,9 @@ public class EyesisCorrectionParameters {
...
@@ -138,6 +138,9 @@ public class EyesisCorrectionParameters {
public
String
x3dSubdirSuffix
=
""
;
public
String
x3dSubdirSuffix
=
""
;
// CLT 3d batch parameters
// CLT 3d batch parameters
public
boolean
process_main_sources
=
false
;
public
boolean
process_aux_sources
=
true
;
public
int
rig_batch_adjust_main
=
0
;
public
int
rig_batch_adjust_main
=
0
;
public
int
rig_batch_adjust_aux
=
0
;
public
int
rig_batch_adjust_aux
=
0
;
public
int
rig_batch_adjust_rig
=
0
;
public
int
rig_batch_adjust_rig
=
0
;
...
@@ -298,6 +301,10 @@ public class EyesisCorrectionParameters {
...
@@ -298,6 +301,10 @@ public class EyesisCorrectionParameters {
cp
.
x3dModelVersion
=
this
.
x3dModelVersion
;
cp
.
x3dModelVersion
=
this
.
x3dModelVersion
;
cp
.
jp4SubDir
=
this
.
jp4SubDir
;
cp
.
jp4SubDir
=
this
.
jp4SubDir
;
cp
.
process_main_sources
=
this
.
process_main_sources
;
cp
.
process_aux_sources
=
this
.
process_aux_sources
;
cp
.
rig_batch_adjust_main
=
this
.
rig_batch_adjust_main
;
cp
.
rig_batch_adjust_main
=
this
.
rig_batch_adjust_main
;
cp
.
rig_batch_adjust_aux
=
this
.
rig_batch_adjust_aux
;
cp
.
rig_batch_adjust_aux
=
this
.
rig_batch_adjust_aux
;
cp
.
rig_batch_adjust_rig
=
this
.
rig_batch_adjust_rig
;
cp
.
rig_batch_adjust_rig
=
this
.
rig_batch_adjust_rig
;
...
@@ -498,6 +505,9 @@ public class EyesisCorrectionParameters {
...
@@ -498,6 +505,9 @@ public class EyesisCorrectionParameters {
properties
.
setProperty
(
prefix
+
"mlDirectory"
,
this
.
mlDirectory
);
properties
.
setProperty
(
prefix
+
"mlDirectory"
,
this
.
mlDirectory
);
properties
.
setProperty
(
prefix
+
"process_main_sources"
,
this
.
process_main_sources
+
""
);
properties
.
setProperty
(
prefix
+
"process_aux_sources"
,
this
.
process_aux_sources
+
""
);
properties
.
setProperty
(
prefix
+
"rig_batch_adjust_main"
,
this
.
rig_batch_adjust_main
+
""
);
properties
.
setProperty
(
prefix
+
"rig_batch_adjust_main"
,
this
.
rig_batch_adjust_main
+
""
);
properties
.
setProperty
(
prefix
+
"rig_batch_adjust_aux"
,
this
.
rig_batch_adjust_aux
+
""
);
properties
.
setProperty
(
prefix
+
"rig_batch_adjust_aux"
,
this
.
rig_batch_adjust_aux
+
""
);
properties
.
setProperty
(
prefix
+
"rig_batch_adjust_rig"
,
this
.
rig_batch_adjust_rig
+
""
);
properties
.
setProperty
(
prefix
+
"rig_batch_adjust_rig"
,
this
.
rig_batch_adjust_rig
+
""
);
...
@@ -680,6 +690,9 @@ public class EyesisCorrectionParameters {
...
@@ -680,6 +690,9 @@ public class EyesisCorrectionParameters {
if
(
properties
.
getProperty
(
prefix
+
"mlDirectory"
)!=
null
)
this
.
mlDirectory
=
properties
.
getProperty
(
prefix
+
"mlDirectory"
);
if
(
properties
.
getProperty
(
prefix
+
"mlDirectory"
)!=
null
)
this
.
mlDirectory
=
properties
.
getProperty
(
prefix
+
"mlDirectory"
);
if
(
properties
.
getProperty
(
prefix
+
"process_main_sources"
)!=
null
)
this
.
process_main_sources
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"process_main_sources"
));
if
(
properties
.
getProperty
(
prefix
+
"process_aux_sources"
)!=
null
)
this
.
process_aux_sources
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"process_aux_sources"
));
if
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_main"
)!=
null
)
this
.
rig_batch_adjust_main
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_main"
));
if
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_main"
)!=
null
)
this
.
rig_batch_adjust_main
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_main"
));
if
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_aux"
)!=
null
)
this
.
rig_batch_adjust_aux
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_aux"
));
if
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_aux"
)!=
null
)
this
.
rig_batch_adjust_aux
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_aux"
));
if
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_rig"
)!=
null
)
this
.
rig_batch_adjust_rig
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_rig"
));
if
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_rig"
)!=
null
)
this
.
rig_batch_adjust_rig
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"rig_batch_adjust_rig"
));
...
@@ -1069,9 +1082,10 @@ public class EyesisCorrectionParameters {
...
@@ -1069,9 +1082,10 @@ public class EyesisCorrectionParameters {
gd
.
addStringField
(
"Aux x3d subdirectory suffix"
,
this
.
aux_camera
.
x3dSubdirSuffix
,
10
,
// 20ba
gd
.
addStringField
(
"Aux x3d subdirectory suffix"
,
this
.
aux_camera
.
x3dSubdirSuffix
,
10
,
// 20ba
"When using timestamp as a subdirectory, add this suffix"
);
"When using timestamp as a subdirectory, add this suffix"
);
gd
.
addTab
(
"Batch"
,
"Select Batch parameters"
);
gd
.
addTab
(
"Batch"
,
"Select Batch parameters"
);
gd
.
addCheckbox
(
"Process main camera source images (false - ignore)"
,
this
.
process_main_sources
);
// 20c
gd
.
addCheckbox
(
"Process AUX camera source images (false - ignore)"
,
this
.
process_aux_sources
);
// 20d
gd
.
addNumericField
(
"Repeat main camera field adjustment (early, before rig)"
,
this
.
rig_batch_adjust_main
,
0
);
gd
.
addNumericField
(
"Repeat main camera field adjustment (early, before rig)"
,
this
.
rig_batch_adjust_main
,
0
);
gd
.
addNumericField
(
"Repeat aux camera field adjustment (early, before rig)"
,
this
.
rig_batch_adjust_aux
,
0
);
gd
.
addNumericField
(
"Repeat aux camera field adjustment (early, before rig)"
,
this
.
rig_batch_adjust_aux
,
0
);
gd
.
addNumericField
(
"Repeat 2-quad camera rig field adjustment (early, before late main/aux)"
,
this
.
rig_batch_adjust_rig
,
0
);
gd
.
addNumericField
(
"Repeat 2-quad camera rig field adjustment (early, before late main/aux)"
,
this
.
rig_batch_adjust_rig
,
0
);
...
@@ -1209,7 +1223,10 @@ public class EyesisCorrectionParameters {
...
@@ -1209,7 +1223,10 @@ public class EyesisCorrectionParameters {
this
.
aux_camera
.
cltSuffix
=
gd
.
getNextString
();
// 20b
this
.
aux_camera
.
cltSuffix
=
gd
.
getNextString
();
// 20b
this
.
aux_camera
.
x3dSubdirSuffix
=
gd
.
getNextString
();
// 20ba
this
.
aux_camera
.
x3dSubdirSuffix
=
gd
.
getNextString
();
// 20ba
this
.
rig_batch_adjust_main
=
(
int
)
gd
.
getNextNumber
();
this
.
process_main_sources
=
gd
.
getNextBoolean
();
// 20c
this
.
process_aux_sources
=
gd
.
getNextBoolean
();
// 20d
this
.
rig_batch_adjust_main
=
(
int
)
gd
.
getNextNumber
();
this
.
rig_batch_adjust_aux
=
(
int
)
gd
.
getNextNumber
();
this
.
rig_batch_adjust_aux
=
(
int
)
gd
.
getNextNumber
();
this
.
rig_batch_adjust_rig
=
(
int
)
gd
.
getNextNumber
();
this
.
rig_batch_adjust_rig
=
(
int
)
gd
.
getNextNumber
();
...
...
src/main/java/com/elphel/imagej/tileprocessor/CLTPass3d.java
View file @
c430b2f4
...
@@ -767,7 +767,9 @@ public class CLTPass3d{
...
@@ -767,7 +767,9 @@ public class CLTPass3d{
double
[]
strength
)
{
double
[]
strength
)
{
this
.
calc_disparity
=
disparity
;
this
.
calc_disparity
=
disparity
;
this
.
strength
=
strength
;
this
.
strength
=
strength
;
calc_disparity_combo
=
calc_disparity
.
clone
();
if
(
calc_disparity_combo
!=
null
)
{
calc_disparity_combo
=
calc_disparity
.
clone
();
}
}
}
/**
/**
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java
View file @
c430b2f4
...
@@ -30,6 +30,18 @@ import com.elphel.imagej.common.GenericJTabbedDialog;
...
@@ -30,6 +30,18 @@ import com.elphel.imagej.common.GenericJTabbedDialog;
public
class
IntersceneMatchParameters
{
public
class
IntersceneMatchParameters
{
// Maybe add parameters to make sure there is enough data? Enough in each zone? Enough spread?
// Maybe add parameters to make sure there is enough data? Enough in each zone? Enough spread?
public
boolean
force_ref_dsi
=
false
;
// true;
public
boolean
force_orientations
=
false
;
public
boolean
force_interscene
=
false
;
// true;
public
boolean
export_images
=
true
;
// 16-slice images (same disparity, COMBO_DSN_INDX_DISP_FG and COMBO_DSN_INDX_DISP_BG_ALL,
public
boolean
show_images
=
false
;
public
boolean
show_ranges
=
true
;
public
double
range_disparity_offset
=
-
0.08
;
public
double
range_min_strength
=
0.5
;
public
double
range_max
=
5000.0
;
// Some "AGC" to adjust how much to discard
// Some "AGC" to adjust how much to discard
public
int
margin
=
1
;
// do not use tiles if their centers are closer to the image edge
public
int
margin
=
1
;
// do not use tiles if their centers are closer to the image edge
public
int
sensor_mask_inter
=
-
1
;
// bitmask of the sensors to use (-1 - all)
public
int
sensor_mask_inter
=
-
1
;
// bitmask of the sensors to use (-1 - all)
...
@@ -85,6 +97,28 @@ public class IntersceneMatchParameters {
...
@@ -85,6 +97,28 @@ public class IntersceneMatchParameters {
public
void
dialogQuestions
(
GenericJTabbedDialog
gd
)
{
public
void
dialogQuestions
(
GenericJTabbedDialog
gd
)
{
// gd.addMessage ("Scene parameters selection");
// gd.addMessage ("Scene parameters selection");
gd
.
addMessage
(
"Build series options"
);
gd
.
addCheckbox
(
"Force reference scene DSI calculation"
,
this
.
force_ref_dsi
,
"Calculate reference scene DSI even if the file exists."
);
gd
.
addCheckbox
(
"Force egomotion calculation"
,
this
.
force_orientations
,
"Calculate relative poses of each scene camera relative to the reference scene even if the data exists."
);
gd
.
addCheckbox
(
"Force interscene DSI accumulation"
,
this
.
force_interscene
,
"Force interscene calculation (+ML export) even if it was performed before."
);
gd
.
addCheckbox
(
"Export all-sensor images"
,
this
.
export_images
,
"Export multi-slice images: with constant disparity, with foreground disparity, and with background disparity"
);
gd
.
addCheckbox
(
"Show exported images"
,
this
.
show_images
,
"Display generated/saved images"
);
gd
.
addCheckbox
(
"Show distances in meters"
,
this
.
show_ranges
,
"Calculate strength, distance, X, and Y in meters"
);
gd
.
addNumericField
(
"Disparity at infinity"
,
this
.
range_disparity_offset
,
5
,
7
,
"pix"
,
"Disparity at infinity - subtract from measured disparity when converting to ranges."
);
gd
.
addNumericField
(
"Minimal strength for range calculation"
,
this
.
range_min_strength
,
5
,
7
,
""
,
"Disregard weaker results when measuring range."
);
gd
.
addNumericField
(
"Maximal displayed range"
,
this
.
range_max
,
5
,
7
,
"m"
,
"Do not display extremely far objects."
);
gd
.
addMessage
(
"Interscene match parameters"
);
gd
.
addNumericField
(
"Image margin"
,
this
.
margin
,
0
,
5
,
"pix"
,
gd
.
addNumericField
(
"Image margin"
,
this
.
margin
,
0
,
5
,
"pix"
,
"Do not use tiles if their centers are closer to the virtual image edge"
);
"Do not use tiles if their centers are closer to the virtual image edge"
);
gd
.
addNumericField
(
"Used sensors mask"
,
this
.
sensor_mask_inter
,
0
,
5
,
""
,
gd
.
addNumericField
(
"Used sensors mask"
,
this
.
sensor_mask_inter
,
0
,
5
,
""
,
...
@@ -112,7 +146,7 @@ public class IntersceneMatchParameters {
...
@@ -112,7 +146,7 @@ public class IntersceneMatchParameters {
gd
.
addNumericField
(
"Difference from neighbors average "
,
this
.
half_avg_diff
,
5
,
7
,
""
,
gd
.
addNumericField
(
"Difference from neighbors average "
,
this
.
half_avg_diff
,
5
,
7
,
""
,
"Reduce twice for high difference from neighbors average."
);
"Reduce twice for high difference from neighbors average."
);
gd
.
addMessage
(
"Initial search for the int
re
-scene match"
);
gd
.
addMessage
(
"Initial search for the int
er
-scene match"
);
gd
.
addNumericField
(
"Azimuth/tilt step"
,
this
.
pix_step
,
0
,
3
,
"pix"
,
gd
.
addNumericField
(
"Azimuth/tilt step"
,
this
.
pix_step
,
0
,
3
,
"pix"
,
"Search in a spiral starting with no-shift with this step between probes, in approximate pixels"
);
"Search in a spiral starting with no-shift with this step between probes, in approximate pixels"
);
gd
.
addNumericField
(
"Search spiral radius"
,
this
.
search_rad
,
0
,
3
,
"steps"
,
gd
.
addNumericField
(
"Search spiral radius"
,
this
.
search_rad
,
0
,
3
,
"steps"
,
...
@@ -173,6 +207,16 @@ public class IntersceneMatchParameters {
...
@@ -173,6 +207,16 @@ public class IntersceneMatchParameters {
}
}
public
void
dialogAnswers
(
GenericJTabbedDialog
gd
)
{
public
void
dialogAnswers
(
GenericJTabbedDialog
gd
)
{
this
.
force_ref_dsi
=
gd
.
getNextBoolean
();
this
.
force_orientations
=
gd
.
getNextBoolean
();
this
.
force_interscene
=
gd
.
getNextBoolean
();
this
.
export_images
=
gd
.
getNextBoolean
();
this
.
show_images
=
gd
.
getNextBoolean
();
this
.
show_ranges
=
gd
.
getNextBoolean
();
this
.
range_disparity_offset
=
gd
.
getNextNumber
();
this
.
range_min_strength
=
gd
.
getNextNumber
();
this
.
range_max
=
gd
.
getNextNumber
();
this
.
margin
=
(
int
)
gd
.
getNextNumber
();
this
.
margin
=
(
int
)
gd
.
getNextNumber
();
this
.
sensor_mask_inter
=
(
int
)
gd
.
getNextNumber
();
this
.
sensor_mask_inter
=
(
int
)
gd
.
getNextNumber
();
this
.
use_partial
=
gd
.
getNextBoolean
();
this
.
use_partial
=
gd
.
getNextBoolean
();
...
@@ -214,6 +258,17 @@ public class IntersceneMatchParameters {
...
@@ -214,6 +258,17 @@ public class IntersceneMatchParameters {
}
}
public
void
setProperties
(
String
prefix
,
Properties
properties
){
public
void
setProperties
(
String
prefix
,
Properties
properties
){
properties
.
setProperty
(
prefix
+
"force_ref_dsi"
,
this
.
force_ref_dsi
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"force_orientations"
,
this
.
force_orientations
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"force_interscene"
,
this
.
force_interscene
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"export_images"
,
this
.
export_images
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"show_images"
,
this
.
show_images
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"show_ranges"
,
this
.
show_ranges
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"range_disparity_offset"
,
this
.
range_disparity_offset
+
""
);
// double
properties
.
setProperty
(
prefix
+
"range_min_strength"
,
this
.
range_min_strength
+
""
);
// double
properties
.
setProperty
(
prefix
+
"range_max"
,
this
.
range_max
+
""
);
// double
properties
.
setProperty
(
prefix
+
"margin"
,
this
.
margin
+
""
);
// int
properties
.
setProperty
(
prefix
+
"margin"
,
this
.
margin
+
""
);
// int
properties
.
setProperty
(
prefix
+
"sensor_mask_inter"
,
this
.
sensor_mask_inter
+
""
);
// int
properties
.
setProperty
(
prefix
+
"sensor_mask_inter"
,
this
.
sensor_mask_inter
+
""
);
// int
properties
.
setProperty
(
prefix
+
"use_partial"
,
this
.
use_partial
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"use_partial"
,
this
.
use_partial
+
""
);
// boolean
...
@@ -253,12 +308,21 @@ public class IntersceneMatchParameters {
...
@@ -253,12 +308,21 @@ public class IntersceneMatchParameters {
}
}
public
void
getProperties
(
String
prefix
,
Properties
properties
){
public
void
getProperties
(
String
prefix
,
Properties
properties
){
if
(
properties
.
getProperty
(
prefix
+
"force_ref_dsi"
)!=
null
)
this
.
force_ref_dsi
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"force_ref_dsi"
));
if
(
properties
.
getProperty
(
prefix
+
"force_orientations"
)!=
null
)
this
.
force_orientations
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"force_orientations"
));
if
(
properties
.
getProperty
(
prefix
+
"force_interscene"
)!=
null
)
this
.
force_interscene
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"force_interscene"
));
if
(
properties
.
getProperty
(
prefix
+
"export_images"
)!=
null
)
this
.
export_images
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"export_images"
));
if
(
properties
.
getProperty
(
prefix
+
"show_images"
)!=
null
)
this
.
show_images
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"show_images"
));
if
(
properties
.
getProperty
(
prefix
+
"show_ranges"
)!=
null
)
this
.
show_images
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"show_ranges"
));
if
(
properties
.
getProperty
(
prefix
+
"range_disparity_offset"
)!=
null
)
this
.
range_disparity_offset
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"range_disparity_offset"
));
if
(
properties
.
getProperty
(
prefix
+
"range_min_strength"
)!=
null
)
this
.
range_min_strength
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"range_min_strength"
));
if
(
properties
.
getProperty
(
prefix
+
"range_max"
)!=
null
)
this
.
range_max
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"range_max"
));
if
(
properties
.
getProperty
(
prefix
+
"margin"
)!=
null
)
this
.
margin
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"margin"
));
if
(
properties
.
getProperty
(
prefix
+
"margin"
)!=
null
)
this
.
margin
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"margin"
));
if
(
properties
.
getProperty
(
prefix
+
"sensor_mask_inter"
)!=
null
)
this
.
sensor_mask_inter
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"sensor_mask_inter"
));
if
(
properties
.
getProperty
(
prefix
+
"sensor_mask_inter"
)!=
null
)
this
.
sensor_mask_inter
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"sensor_mask_inter"
));
if
(
properties
.
getProperty
(
prefix
+
"use_partial"
)!=
null
)
this
.
use_partial
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"use_partial"
));
if
(
properties
.
getProperty
(
prefix
+
"use_partial"
)!=
null
)
this
.
use_partial
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"use_partial"
));
if
(
properties
.
getProperty
(
prefix
+
"run_poly"
)!=
null
)
this
.
run_poly
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"run_poly"
));
if
(
properties
.
getProperty
(
prefix
+
"run_poly"
)!=
null
)
this
.
run_poly
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"run_poly"
));
if
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
)!=
null
)
this
.
centroid_radius
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
));
if
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
)!=
null
)
this
.
centroid_radius
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
));
if
(
properties
.
getProperty
(
prefix
+
"
margin"
)!=
null
)
this
.
margin
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"margin
"
));
if
(
properties
.
getProperty
(
prefix
+
"
n_recenter"
)!=
null
)
this
.
n_recenter
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"n_recenter
"
));
if
(
properties
.
getProperty
(
prefix
+
"min_str"
)!=
null
)
this
.
min_str
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"min_str"
));
if
(
properties
.
getProperty
(
prefix
+
"min_str"
)!=
null
)
this
.
min_str
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"min_str"
));
if
(
properties
.
getProperty
(
prefix
+
"min_str_sum"
)!=
null
)
this
.
min_str_sum
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"min_str_sum"
));
if
(
properties
.
getProperty
(
prefix
+
"min_str_sum"
)!=
null
)
this
.
min_str_sum
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"min_str_sum"
));
if
(
properties
.
getProperty
(
prefix
+
"min_neibs"
)!=
null
)
this
.
min_neibs
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"min_neibs"
));
if
(
properties
.
getProperty
(
prefix
+
"min_neibs"
)!=
null
)
this
.
min_neibs
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"min_neibs"
));
...
@@ -294,6 +358,15 @@ public class IntersceneMatchParameters {
...
@@ -294,6 +358,15 @@ public class IntersceneMatchParameters {
@Override
@Override
public
IntersceneMatchParameters
clone
()
throws
CloneNotSupportedException
{
public
IntersceneMatchParameters
clone
()
throws
CloneNotSupportedException
{
IntersceneMatchParameters
imp
=
new
IntersceneMatchParameters
();
IntersceneMatchParameters
imp
=
new
IntersceneMatchParameters
();
imp
.
force_ref_dsi
=
this
.
force_ref_dsi
;
imp
.
force_orientations
=
this
.
force_orientations
;
imp
.
force_interscene
=
this
.
force_interscene
;
imp
.
export_images
=
this
.
export_images
;
imp
.
show_images
=
this
.
show_images
;
imp
.
show_ranges
=
this
.
show_ranges
;
imp
.
range_disparity_offset
=
this
.
range_disparity_offset
;
imp
.
range_min_strength
=
this
.
range_min_strength
;
imp
.
range_max
=
this
.
range_max
;
imp
.
margin
=
this
.
margin
;
imp
.
margin
=
this
.
margin
;
imp
.
sensor_mask_inter
=
this
.
sensor_mask_inter
;
imp
.
sensor_mask_inter
=
this
.
sensor_mask_inter
;
imp
.
use_partial
=
this
.
use_partial
;
imp
.
use_partial
=
this
.
use_partial
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
c430b2f4
...
@@ -2664,6 +2664,54 @@ public class OpticalFlow {
...
@@ -2664,6 +2664,54 @@ public class OpticalFlow {
}
}
return
disparity_strength
;
return
disparity_strength
;
}
}
/**
* Transform disparity to world XYZ to test distance in meters
* @param disparity_ref [tilesX * tilesY] per-tile disparity
* @param quadClt scene
* @param threadsMax
* @return per tile array (with possible nulls) of X,Y,Z triplets in meters (left, up, negative distance)
*/
public
static
double
[][]
transformToWorldXYZ
(
final
double
[]
disparity_ref
,
// invalid tiles - NaN in disparity
final
QuadCLT
quadClt
,
// now - may be null - for testing if scene is rotated ref
int
threadsMax
)
{
TileProcessor
tp
=
quadClt
.
getTileProcessor
();
final
int
tilesX
=
tp
.
getTilesX
();
final
int
tilesY
=
tp
.
getTilesY
();
final
int
tiles
=
tilesX
*
tilesY
;
final
int
transform_size
=
tp
.
getTileSize
();
final
double
[][]
world_xyz
=
new
double
[
tiles
][];
final
ErsCorrection
ersCorrection
=
quadClt
.
getErsCorrection
();
ersCorrection
.
setupERS
();
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
tiles
;
nTile
=
ai
.
getAndIncrement
())
if
(!
Double
.
isNaN
(
disparity_ref
[
nTile
]))
{
double
disparity
=
disparity_ref
[
nTile
];
int
tileY
=
nTile
/
tilesX
;
int
tileX
=
nTile
%
tilesX
;
double
centerX
=
tileX
*
transform_size
+
transform_size
/
2
;
// - shiftX;
double
centerY
=
tileY
*
transform_size
+
transform_size
/
2
;
// - shiftY;
world_xyz
[
nTile
]
=
ersCorrection
.
getWorldCoordinatesERS
(
// ersCorrection - reference
centerX
,
// double px, // pixel coordinate X in the reference view
centerY
,
// double py, // pixel coordinate Y in the reference view
disparity
,
// double disparity, // reference disparity
true
,
// boolean distortedView, // This camera view is distorted (diff.rect), false - rectilinear
ZERO3
,
// double [] reference_xyz, // this view position in world coordinates (typically ZERO3)
ZERO3
);
// double [] reference_atr, // this view orientation relative to world frame (typically ZERO3)
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
return
world_xyz
;
}
public
double
[][]
transformToScenePxPyD
(
public
double
[][]
transformToScenePxPyD
(
final
double
[]
disparity_ref
,
// invalid tiles - NaN in disparity
final
double
[]
disparity_ref
,
// invalid tiles - NaN in disparity
...
@@ -3789,7 +3837,7 @@ public class OpticalFlow {
...
@@ -3789,7 +3837,7 @@ public class OpticalFlow {
QuadCLT
quadCLT_main
,
// tiles should be set
QuadCLT
quadCLT_main
,
// tiles should be set
int
ref_index
,
// -1 - last
int
ref_index
,
// -1 - last
int
ref_step
,
int
ref_step
,
CLTParameters
clt_parameters
,
CLTParameters
clt_parameters
,
EyesisCorrectionParameters
.
DebayerParameters
debayerParameters
,
EyesisCorrectionParameters
.
DebayerParameters
debayerParameters
,
ColorProcParameters
colorProcParameters
,
ColorProcParameters
colorProcParameters
,
CorrectionColorProc
.
ColorGainsParameters
channelGainParameters
,
CorrectionColorProc
.
ColorGainsParameters
channelGainParameters
,
...
@@ -3801,11 +3849,18 @@ public class OpticalFlow {
...
@@ -3801,11 +3849,18 @@ public class OpticalFlow {
final
boolean
updateStatus
,
final
boolean
updateStatus
,
final
int
debugLevel
)
throws
Exception
final
int
debugLevel
)
throws
Exception
{
{
boolean
build_ref_dsi
=
false
;
// true;
boolean
build_ref_dsi
=
clt_parameters
.
imp
.
force_ref_dsi
;
boolean
build_orientations
=
false
;
boolean
build_orientations
=
clt_parameters
.
imp
.
force_orientations
;
boolean
build_interscene
=
false
;
// true;
boolean
build_interscene
=
clt_parameters
.
imp
.
force_interscene
;
boolean
export_images
=
true
;
// 16-slice images (same disparity, COMBO_DSN_INDX_DISP_FG and COMBO_DSN_INDX_DISP_BG_ALL,
boolean
export_images
=
clt_parameters
.
imp
.
export_images
;
boolean
show_images
=
true
;
boolean
export_dsi_image
=
clt_parameters
.
imp
.
show_ranges
;
boolean
show_images
=
clt_parameters
.
imp
.
show_images
;
double
range_disparity_offset
=
clt_parameters
.
imp
.
range_disparity_offset
;
// -0.08;
double
range_min_strength
=
clt_parameters
.
imp
.
range_min_strength
;
// 0.5;
double
range_max
=
clt_parameters
.
imp
.
range_max
;
// 5000.0;
final
int
debugLevelInner
=
clt_parameters
.
batch_run
?
-
2
:
debugLevel
;
// copied from TQ
final
int
debugLevelInner
=
clt_parameters
.
batch_run
?
-
2
:
debugLevel
;
// copied from TQ
if
((
quadCLT_main
!=
null
)
&&
(
quadCLT_main
.
getGPU
()
!=
null
))
{
if
((
quadCLT_main
!=
null
)
&&
(
quadCLT_main
.
getGPU
()
!=
null
))
{
...
@@ -3822,11 +3877,27 @@ public class OpticalFlow {
...
@@ -3822,11 +3877,27 @@ public class OpticalFlow {
}
}
QuadCLT
.
SetChannels
[]
set_channels
=
quadCLT_main
.
setChannels
(
debugLevel
);
QuadCLT
.
SetChannels
[]
set_channels
=
quadCLT_main
.
setChannels
(
debugLevel
);
QuadCLT
[]
quadCLTs
=
new
QuadCLT
[
set_channels
.
length
];
QuadCLT
[]
quadCLTs
=
new
QuadCLT
[
set_channels
.
length
];
if
(
ref_index
<
0
)
{
if
(
ref_index
<
0
)
{
ref_index
+=
quadCLTs
.
length
;
ref_index
+=
quadCLTs
.
length
;
}
}
double
[][][]
scenes_xyzatr
=
new
double
[
quadCLTs
.
length
][][];
// previous scene relative to the next one
double
[][][]
scenes_xyzatr
=
new
double
[
quadCLTs
.
length
][][];
// previous scene relative to the next one
scenes_xyzatr
[
ref_index
]
=
new
double
[
2
][
3
];
// all zeros
scenes_xyzatr
[
ref_index
]
=
new
double
[
2
][
3
];
// all zeros
// See if build_ref_dsi is needed
if
(!
build_ref_dsi
)
{
quadCLTs
[
ref_index
]
=
(
QuadCLT
)
quadCLT_main
.
spawnNoModelQuadCLT
(
// will conditionImageSet
set_channels
[
ref_index
].
set_name
,
clt_parameters
,
colorProcParameters
,
//
threadsMax
,
debugLevel
-
2
);
if
((
quadCLTs
[
ref_index
]
==
null
)
||
!
quadCLTs
[
ref_index
].
dsiExists
())
{
if
(
debugLevel
>-
2
)
{
System
.
out
.
println
(
"DSI data for scene "
+
set_channels
[
ref_index
].
set_name
+
" does not exist, forcing its calculation."
);
}
build_ref_dsi
=
true
;
}
}
if
(
build_ref_dsi
)
{
if
(
build_ref_dsi
)
{
TwoQuadCLT
.
copyJP4src
(
// actually there is no sense to process multiple image sets. Combine with other
TwoQuadCLT
.
copyJP4src
(
// actually there is no sense to process multiple image sets. Combine with other
...
@@ -3917,9 +3988,19 @@ public class OpticalFlow {
...
@@ -3917,9 +3988,19 @@ public class OpticalFlow {
threadsMax
,
// int threadsMax, // maximal number of threads to launch
threadsMax
,
// int threadsMax, // maximal number of threads to launch
updateStatus
,
// boolean updateStatus,
updateStatus
,
// boolean updateStatus,
debugLevel
);
// int debugLevel)
debugLevel
);
// int debugLevel)
QuadCLT
reference_QuadClt
=
quadCLTs
[
ref_index
];
// QuadCLT reference_QuadClt = quadCLTs[ref_index];
ErsCorrection
ers_reference
=
reference_QuadClt
.
getErsCorrection
();
ErsCorrection
ers_reference
=
quadCLTs
[
ref_index
].
getErsCorrection
();
if
(!
build_orientations
)
{
if
(!
quadCLTs
[
ref_index
].
propertiesContainString
(
".scenes_"
)){
if
(
debugLevel
>-
2
)
{
System
.
out
.
println
(
"Egomotion data for scene "
+
set_channels
[
ref_index
].
set_name
+
" does not exist, forcing its calculation."
);
}
build_orientations
=
true
;
}
}
if
(
build_orientations
)
{
if
(
build_orientations
)
{
double
maximal_series_rms
=
0.0
;
double
[]
lma_rms
=
new
double
[
2
];
double
[]
lma_rms
=
new
double
[
2
];
double
[]
use_atr
=
null
;
double
[]
use_atr
=
null
;
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
...
@@ -3937,7 +4018,7 @@ public class OpticalFlow {
...
@@ -3937,7 +4018,7 @@ public class OpticalFlow {
if
(
scene_index
==
ref_index
-
1
)
{
// search around for the best fit
if
(
scene_index
==
ref_index
-
1
)
{
// search around for the best fit
use_atr
=
spiralSearchATR
(
use_atr
=
spiralSearchATR
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadClt,
quadCLTs
[
ref_index
]
,
// QuadCLT reference_QuadClt,
scene_QuadClt
,
// QuadCLT scene_QuadClt,
scene_QuadClt
,
// QuadCLT scene_QuadClt,
debugLevel
);
debugLevel
);
if
(
use_atr
==
null
)
{
if
(
use_atr
==
null
)
{
...
@@ -3955,7 +4036,7 @@ public class OpticalFlow {
...
@@ -3955,7 +4036,7 @@ public class OpticalFlow {
// Refine with LMA
// Refine with LMA
scenes_xyzatr
[
scene_index
]
=
adjustPairsLMAInterscene
(
scenes_xyzatr
[
scene_index
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
quadCLTs
[
ref_index
]
,
// QuadCLT reference_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
scenes_xyzatr
[
scene_index
][
0
],
// xyz
scenes_xyzatr
[
scene_index
][
0
],
// xyz
scenes_xyzatr
[
scene_index
][
1
],
// atr
scenes_xyzatr
[
scene_index
][
1
],
// atr
...
@@ -3971,10 +4052,14 @@ public class OpticalFlow {
...
@@ -3971,10 +4052,14 @@ public class OpticalFlow {
ZERO3
,
// ers_scene.getErsXYZ_dt(),
ZERO3
,
// ers_scene.getErsXYZ_dt(),
ZERO3
// ers_scene.getErsATR_dt()
ZERO3
// ers_scene.getErsATR_dt()
);
);
if
(
lma_rms
[
0
]
>
maximal_series_rms
)
{
maximal_series_rms
=
lma_rms
[
0
];
}
if
(
debugLevel
>
-
3
)
{
if
(
debugLevel
>
-
3
)
{
System
.
out
.
println
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
println
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done."
);
quadCLTs
[
ref_index
].
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
maximal_series_rms
);
}
}
/*
/*
if (delete_scene_asap) {
if (delete_scene_asap) {
...
@@ -3982,11 +4067,24 @@ public class OpticalFlow {
...
@@ -3982,11 +4067,24 @@ public class OpticalFlow {
}
}
*/
*/
}
}
reference_QuadClt
.
saveInterProperties
(
// save properties for interscene processing (extrinsics, ers, ...)
if
(
debugLevel
>
-
4
)
{
System
.
out
.
println
(
"All multi scene passes are Done. Maximal RMSE was "
+
maximal_series_rms
);
}
quadCLTs
[
ref_index
].
saveInterProperties
(
// save properties for interscene processing (extrinsics, ers, ...)
null
,
// String path, // full name with extension or w/o path to use x3d directory
null
,
// String path, // full name with extension or w/o path to use x3d directory
debugLevel
+
1
);
debugLevel
+
1
);
}
// if (build_orientations) {
}
// if (build_orientations) {
double
[][]
combo_dsn_final
=
null
;
double
[][]
combo_dsn_final
=
null
;
if
(!
build_interscene
)
{
if
(!
quadCLTs
[
ref_index
].
interDsiExists
())
{
if
(
debugLevel
>-
2
)
{
System
.
out
.
println
(
"Interscene DSI data for scene "
+
set_channels
[
ref_index
].
set_name
+
" does not exist, forcing its calculation."
);
}
build_interscene
=
true
;
}
}
if
(
build_interscene
)
{
if
(
build_interscene
)
{
if
(!
build_orientations
)
{
if
(!
build_orientations
)
{
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
...
@@ -4006,6 +4104,7 @@ public class OpticalFlow {
...
@@ -4006,6 +4104,7 @@ public class OpticalFlow {
colorProcParameters
,
// ColorProcParameters colorProcParameters,
colorProcParameters
,
// ColorProcParameters colorProcParameters,
debugLevel
);
// int debug_level
debugLevel
);
// int debug_level
}
}
if
(
export_images
)
{
if
(
export_images
)
{
if
(
combo_dsn_final
==
null
)
{
if
(
combo_dsn_final
==
null
)
{
combo_dsn_final
=
quadCLTs
[
ref_index
].
readDoubleArrayFromModelDirectory
(
combo_dsn_final
=
quadCLTs
[
ref_index
].
readDoubleArrayFromModelDirectory
(
...
@@ -4013,8 +4112,55 @@ public class OpticalFlow {
...
@@ -4013,8 +4112,55 @@ public class OpticalFlow {
0
,
// int num_slices, // (0 - all)
0
,
// int num_slices, // (0 - all)
null
);
// int [] wh);
null
);
// int [] wh);
}
}
double
[]
fg_disparity
=
combo_dsn_final
[
COMBO_DSN_INDX_DISP_FG
];
// re-load
double
[]
bg_disparity
=
combo_dsn_final
[
COMBO_DSN_INDX_DISP_BG_ALL
];
/*
quadCLTs[ref_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
set_channels[ref_index].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel);
*/
double
[][]
dls
=
{
combo_dsn_final
[
COMBO_DSN_INDX_DISP
],
combo_dsn_final
[
COMBO_DSN_INDX_LMA
],
combo_dsn_final
[
COMBO_DSN_INDX_STRENGTH
]
};
double
[][]
ds
=
conditionInitialDS
(
clt_parameters
,
// CLTParameters clt_parameters,
dls
,
// double [][] dls
quadCLTs
[
ref_index
],
// QuadCLT scene,
debugLevel
);
double
[]
fg_disparity
=
ds
[
0
];
// combo_dsn_final[COMBO_DSN_INDX_DISP_FG];
double
[]
bg_lma
=
combo_dsn_final
[
COMBO_DSN_INDX_DISP_BG_ALL
].
clone
();
double
[]
bg_str
=
combo_dsn_final
[
COMBO_DSN_INDX_STRENGTH
].
clone
();
for
(
int
i
=
0
;
i
<
bg_lma
.
length
;
i
++)
{
if
(
Double
.
isNaN
(
combo_dsn_final
[
COMBO_DSN_INDX_LMA
][
i
])){
bg_lma
[
i
]
=
Double
.
NaN
;
}
if
(!
Double
.
isNaN
(
combo_dsn_final
[
COMBO_DSN_INDX_DISP_BG
][
i
])){
bg_lma
[
i
]
=
combo_dsn_final
[
COMBO_DSN_INDX_LMA_BG
][
i
];
}
if
(!
Double
.
isNaN
(
combo_dsn_final
[
COMBO_DSN_INDX_STRENGTH_BG
][
i
])){
bg_str
[
i
]
=
combo_dsn_final
[
COMBO_DSN_INDX_STRENGTH_BG
][
i
];
}
}
double
[][]
dls_bg
=
{
combo_dsn_final
[
COMBO_DSN_INDX_DISP_BG_ALL
],
bg_lma
,
bg_str
};
double
[][]
ds_bg
=
conditionInitialDS
(
clt_parameters
,
// CLTParameters clt_parameters,
dls_bg
,
// double [][] dls
quadCLTs
[
ref_index
],
// QuadCLT scene,
debugLevel
);
double
[]
bg_disparity
=
ds_bg
[
0
];
// combo_dsn_final[COMBO_DSN_INDX_DISP_FG];
double
[]
constant_disparity
=
new
double
[
fg_disparity
.
length
];
double
[]
constant_disparity
=
new
double
[
fg_disparity
.
length
];
Arrays
.
fill
(
constant_disparity
,
clt_parameters
.
disparity
);
Arrays
.
fill
(
constant_disparity
,
clt_parameters
.
disparity
);
ImagePlus
imp_constant
=
QuadCLT
.
renderGPUFromDSI
(
ImagePlus
imp_constant
=
QuadCLT
.
renderGPUFromDSI
(
...
@@ -4064,12 +4210,94 @@ public class OpticalFlow {
...
@@ -4064,12 +4210,94 @@ public class OpticalFlow {
imp_bg
.
show
();
imp_bg
.
show
();
}
}
}
}
if
(
export_dsi_image
)
{
if
(
combo_dsn_final
==
null
)
{
combo_dsn_final
=
quadCLTs
[
ref_index
].
readDoubleArrayFromModelDirectory
(
"-INTER-INTRA-LMA"
,
// String suffix,
0
,
// int num_slices, // (0 - all)
null
);
// int [] wh);
}
// re-load , should create quadCLTs[ref_index].dsi
/*
quadCLTs[ref_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
set_channels[ref_index].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel);
*/
// TODO:********************
// double [] disparity = combo_dsn_final[COMBO_DSN_INDX_DISP].clone();
// double [] strength = combo_dsn_final[COMBO_DSN_INDX_STRENGTH];
double
[][]
dls
=
{
combo_dsn_final
[
COMBO_DSN_INDX_DISP
],
combo_dsn_final
[
COMBO_DSN_INDX_LMA
],
combo_dsn_final
[
COMBO_DSN_INDX_STRENGTH
]
};
double
[][]
ds
=
conditionInitialDS
(
clt_parameters
,
// CLTParameters clt_parameters,
dls
,
// double [][] dls
quadCLTs
[
ref_index
],
// QuadCLT scene,
debugLevel
);
// int debug_level)
double
[]
disparity
=
ds
[
0
];
double
[]
strength
=
ds
[
1
];
double
[][]
szxy
=
getSceneSZXY
(
quadCLTs
[
ref_index
],
// QuadCLT scene,
range_disparity_offset
,
// double disparity_offset,
range_min_strength
,
// double min_strength,
range_max
,
// double max_range,
disparity
,
// double [] disparity,
strength
);
// double [] strength)
String
[]
szxy_titles
=
{
"strength"
,
"Z(m)"
,
"X(m)"
,
"Y(m)"
};
TileProcessor
tp
=
quadCLTs
[
ref_index
].
getTileProcessor
();
int
tilesX
=
tp
.
getTilesX
();
int
tilesY
=
tp
.
getTilesY
();
(
new
ShowDoubleFloatArrays
()).
showArrays
(
szxy
,
tilesX
,
tilesY
,
true
,
quadCLTs
[
ref_index
].
getImageName
()+
"_SZXY"
,
szxy_titles
);
}
// Add 16-images:
// Add 16-images:
//disparity = 0, FG, BG
//disparity = 0, FG, BG
System
.
out
.
println
(
"buildSeries(): DONE"
);
//
System
.
out
.
println
(
"buildSeries(): DONE"
);
//
return
true
;
return
true
;
}
}
public
double
[][]
getSceneSZXY
(
QuadCLT
scene
,
double
disparity_offset
,
double
min_strength
,
double
max_range
,
double
[]
disparity0
,
double
[]
strength
){
// may be null
double
[]
disparity
=
disparity0
.
clone
();
for
(
int
i
=
0
;
i
<
disparity
.
length
;
i
++)
{
disparity
[
i
]
-=
disparity_offset
;
}
double
[][]
xyz
=
transformToWorldXYZ
(
disparity
,
// [final double [] disparity_ref, // invalid tiles - NaN in disparity
scene
,
// final QuadCLT quadClt, // now - may be null - for testing if scene is rotated ref
threadsMax
);
// int threadsMax);
double
[][]
szxy
=
new
double
[
4
][
disparity
.
length
];
szxy
[
0
]
=
strength
;
for
(
int
i
=
1
;
i
<
szxy
.
length
;
i
++)
{
Arrays
.
fill
(
szxy
[
i
],
Double
.
NaN
);
}
for
(
int
nTile
=
0
;
nTile
<
xyz
.
length
;
nTile
++)
if
(
xyz
[
nTile
]
!=
null
)
{
if
((
xyz
[
nTile
][
2
]
<
0
)
&&
(
xyz
[
nTile
][
2
]
>
-
max_range
)
&&
((
strength
==
null
)
||(
strength
[
nTile
]
>=
min_strength
)))
{
szxy
[
1
][
nTile
]
=
-
xyz
[
nTile
][
2
];
szxy
[
2
][
nTile
]
=
xyz
[
nTile
][
0
];
szxy
[
3
][
nTile
]
=
xyz
[
nTile
][
1
];
}
}
return
szxy
;
}
public
double
[]
spiralSearchATR
(
public
double
[]
spiralSearchATR
(
...
@@ -4311,6 +4539,8 @@ public class OpticalFlow {
...
@@ -4311,6 +4539,8 @@ public class OpticalFlow {
Arrays
.
fill
(
dbg_rms_pre
,
Double
.
NaN
);
Arrays
.
fill
(
dbg_rms_pre
,
Double
.
NaN
);
// process scenes before reference
// process scenes before reference
int
dbg_ref_index
=
10
;
// wait for ref_index <= dbg_ref_index and print (manually update dbg_ref_index
int
dbg_ref_index
=
10
;
// wait for ref_index <= dbg_ref_index and print (manually update dbg_ref_index
double
maximal_series_rms
=
0.0
;
double
maximal_series_rms1
=
0.0
;
if
(
ref_index
>
1
)
{
if
(
ref_index
>
1
)
{
for
(
int
i
=
ref_index
-
2
;
i
>=
0
;
i
--)
{
for
(
int
i
=
ref_index
-
2
;
i
>=
0
;
i
--)
{
QuadCLT
scene_QuadClt
=
scenes
[
i
];
QuadCLT
scene_QuadClt
=
scenes
[
i
];
...
@@ -4381,6 +4611,9 @@ public class OpticalFlow {
...
@@ -4381,6 +4611,9 @@ public class OpticalFlow {
}
}
}
}
}
}
if
(
lma_rms
[
0
]
>
maximal_series_rms
)
{
maximal_series_rms
=
lma_rms
[
0
];
}
dbg_rms_pre
[
i
]
=
lma_rms
[
0
];
dbg_rms_pre
[
i
]
=
lma_rms
[
0
];
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
scenes_xyzatr
[
i
][
0
],
scenes_xyzatr
[
i
][
0
],
...
@@ -4396,7 +4629,8 @@ public class OpticalFlow {
...
@@ -4396,7 +4629,8 @@ public class OpticalFlow {
ers_scene
.
setupERS
();
ers_scene
.
setupERS
();
if
(
debug_level
>
-
1
)
{
if
(
debug_level
>
-
1
)
{
System
.
out
.
println
(
"Pass multi scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
System
.
out
.
println
(
"Pass multi scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done."
);
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
maximal_series_rms
);
}
}
if
(
delete_scene_asap
)
{
if
(
delete_scene_asap
)
{
scenes
[
i
+
1
]
=
null
;
scenes
[
i
+
1
]
=
null
;
...
@@ -4471,6 +4705,9 @@ public class OpticalFlow {
...
@@ -4471,6 +4705,9 @@ public class OpticalFlow {
0.0
,
// double max_rms,
0.0
,
// double max_rms,
debug_level
);
// int debug_level)
debug_level
);
// int debug_level)
}
}
if
(
lma_rms
[
0
]
>
maximal_series_rms
)
{
maximal_series_rms
=
lma_rms
[
0
];
}
dbg_rms_pre
[
i
]
=
lma_rms
[
0
];
dbg_rms_pre
[
i
]
=
lma_rms
[
0
];
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
scenes_xyzatr
[
i
][
0
],
scenes_xyzatr
[
i
][
0
],
...
@@ -4486,13 +4723,18 @@ public class OpticalFlow {
...
@@ -4486,13 +4723,18 @@ public class OpticalFlow {
ers_scene
.
setupERS
();
ers_scene
.
setupERS
();
if
(
debug_level
>
-
1
)
{
if
(
debug_level
>
-
1
)
{
System
.
out
.
println
(
"Pass multi scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
System
.
out
.
println
(
"Pass multi scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done."
);
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
maximal_series_rms
);
}
}
if
(
delete_scene_asap
)
{
if
(
delete_scene_asap
)
{
scenes
[
i
-
1
]
=
null
;
scenes
[
i
-
1
]
=
null
;
}
}
}
}
}
}
if
(
debug_level
>
-
3
)
{
System
.
out
.
println
(
"All multi scene passes are Done. Maximal RMSE was "
+
maximal_series_rms
);
}
// boolean show_results = true;
// boolean show_results = true;
if
(
show_results
)
{
if
(
show_results
)
{
int
dbg_w
=
scenes_xyzatr
.
length
;
int
dbg_w
=
scenes_xyzatr
.
length
;
...
@@ -4601,6 +4843,9 @@ public class OpticalFlow {
...
@@ -4601,6 +4843,9 @@ public class OpticalFlow {
0.0
,
// double max_rms,
0.0
,
// double max_rms,
debug_level
);
// int debug_level)
debug_level
);
// int debug_level)
}
}
if
(
lma_rms
[
0
]
>
maximal_series_rms1
)
{
maximal_series_rms1
=
lma_rms
[
0
];
}
dbg_rms
[
i
]
=
lma_rms
[
0
];
dbg_rms
[
i
]
=
lma_rms
[
0
];
ers_reference
.
addScene
(
ers_reference
.
addScene
(
scene_ts
,
scene_ts
,
...
@@ -4619,7 +4864,8 @@ public class OpticalFlow {
...
@@ -4619,7 +4864,8 @@ public class OpticalFlow {
*/
*/
if
(
debug_level
>
-
1
)
{
if
(
debug_level
>
-
1
)
{
System
.
out
.
println
(
"Pass 2 multi scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
System
.
out
.
println
(
"Pass 2 multi scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_ts
+
" Done."
);
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_ts
+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
maximal_series_rms
);
}
}
if
(
delete_scene_asap
)
{
if
(
delete_scene_asap
)
{
scenes
[
i
-
1
]
=
null
;
scenes
[
i
-
1
]
=
null
;
...
@@ -4638,8 +4884,9 @@ public class OpticalFlow {
...
@@ -4638,8 +4884,9 @@ public class OpticalFlow {
}
}
rms_pre_mean
/=
rms_pre_num
;
rms_pre_mean
/=
rms_pre_num
;
rms_mean
/=
rms_num
;
rms_mean
/=
rms_num
;
if
(
debug_level
>
-
1
)
{
if
(
debug_level
>
-
3
)
{
System
.
out
.
println
(
"adjustSeries() rms_pre_mean="
+
rms_pre_mean
+
", rms_mean="
+
rms_mean
);
System
.
out
.
println
(
"adjustSeries() rms_pre_mean="
+
rms_pre_mean
+
", rms_mean="
+
rms_mean
+
", maximal RMSE="
+
maximal_series_rms1
);
}
}
if
(
show_results
)
{
if
(
show_results
)
{
...
@@ -4798,8 +5045,9 @@ public class OpticalFlow {
...
@@ -4798,8 +5045,9 @@ public class OpticalFlow {
scenes
,
// QuadCLT [] scenes,
scenes
,
// QuadCLT [] scenes,
8
);
// int iscale) // 8
8
);
// int iscale) // 8
}
}
if
(
debug_level
>
-
1
)
{
if
(
debug_level
>
-
3
)
{
System
.
out
.
println
(
"adjustSeries() Done."
);
System
.
out
.
println
(
"adjustSeries() Done. Maximal RMSE in pass1 was "
+
maximal_series_rms
+
", in pass2 - "
+
maximal_series_rms1
);
}
}
}
}
...
@@ -6668,8 +6916,8 @@ public class OpticalFlow {
...
@@ -6668,8 +6916,8 @@ public class OpticalFlow {
for
(
int
i
=
0
;
i
<
num_scenes
;
i
++)
{
for
(
int
i
=
0
;
i
<
num_scenes
;
i
++)
{
initial_ds
[
i
]
=
conditionInitialDS
(
initial_ds
[
i
]
=
conditionInitialDS
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
scenes
[
i
],
// QuadCLT scene,
scenes
[
i
],
// QuadCLT scene,
-
1
);
// int debug_level);
-
1
);
// int debug_level);
}
}
if
(
debug_level
>
-
1
)
{
if
(
debug_level
>
-
1
)
{
String
[]
dbg_titles
=
new
String
[
2
*
num_scenes
];
String
[]
dbg_titles
=
new
String
[
2
*
num_scenes
];
...
@@ -9092,9 +9340,27 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
...
@@ -9092,9 +9340,27 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
}
}
// what does it do?
// what does it do?
private
double
[][]
conditionInitialDS
(
private
double
[][]
conditionInitialDS
(
CLTParameters
clt_parameters
,
CLTParameters
clt_parameters
,
QuadCLT
scene
,
QuadCLT
scene
,
int
debug_level
){
double
[][]
dls
=
scene
.
getDLS
();
if
(
dls
==
null
)
{
return
null
;
}
return
conditionInitialDS
(
clt_parameters
,
dls
,
scene
,
debug_level
);
}
private
double
[][]
conditionInitialDS
(
CLTParameters
clt_parameters
,
double
[][]
dls
,
QuadCLT
scene
,
int
debug_level
)
int
debug_level
)
{
{
final
int
tilesX
=
scene
.
getTileProcessor
().
getTilesX
();
final
int
tilesX
=
scene
.
getTileProcessor
().
getTilesX
();
...
@@ -9125,7 +9391,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
...
@@ -9125,7 +9391,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
final
double
outliers_max_strength
=
0.1
;
/// 0.25;
final
double
outliers_max_strength
=
0.1
;
/// 0.25;
final
double
outliers_from_lma_max_strength
=
0.
5
;
final
double
outliers_from_lma_max_strength
=
0.
8
;
final
double
diff_from_lma_pos
=
100.0
;
final
double
diff_from_lma_pos
=
100.0
;
final
double
diff_from_lma_neg
=
2.0
;
final
double
diff_from_lma_neg
=
2.0
;
final
int
outliers_lma_nth_fromextrem
=
1
;
final
int
outliers_lma_nth_fromextrem
=
1
;
...
@@ -9136,11 +9402,12 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
...
@@ -9136,11 +9402,12 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
// if (dsrbg == null) {
// if (dsrbg == null) {
// return null;
// return null;
// }
// }
/*
double [][] dls = scene.getDLS();
double [][] dls = scene.getDLS();
if (dls == null) {
if (dls == null) {
return null;
return null;
}
}
*/
String
[]
dbg_titles
=
{
"str"
,
"lma"
,
"disp"
,
"-lma"
,
"by-lma"
,
"-nonlma"
,
"old-disp"
,
"old-sngl"
,
"weak"
,
"filled"
};
String
[]
dbg_titles
=
{
"str"
,
"lma"
,
"disp"
,
"-lma"
,
"by-lma"
,
"-nonlma"
,
"old-disp"
,
"old-sngl"
,
"weak"
,
"filled"
};
double
[][]
dbg_img
=
new
double
[
dbg_titles
.
length
][];
double
[][]
dbg_img
=
new
double
[
dbg_titles
.
length
][];
//Remove crazy LMA high-disparity tiles
//Remove crazy LMA high-disparity tiles
...
@@ -9172,7 +9439,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
...
@@ -9172,7 +9439,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
// mostly filter infinity, clouds, sky
// mostly filter infinity, clouds, sky
disp_outliers
=
QuadCLT
.
removeDisparityLMAOutliers
(
// filter non-lma tiles
disp_outliers
=
QuadCLT
.
removeDisparityLMAOutliers
(
// filter non-lma tiles
true
,
// final boolean non_ma,
true
,
// final boolean non_ma,
dls
,
//final double [][] dls,
new
double
[][]
{
disp_outliers
,
dls
[
1
],
dls
[
2
]}
,
//final double [][] dls,
outliers_lma_max_strength
,
// final double max_strength, // do not touch stronger
outliers_lma_max_strength
,
// final double max_strength, // do not touch stronger
outliers_lma_nth_fromextrem
,
// final int nth_fromextrem, // 0 - compare to max/min. 1 - second max/min, ...
outliers_lma_nth_fromextrem
,
// final int nth_fromextrem, // 0 - compare to max/min. 1 - second max/min, ...
outliers_tolerance_absolute
,
// final double tolerance_absolute,
outliers_tolerance_absolute
,
// final double tolerance_absolute,
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
View file @
c430b2f4
...
@@ -238,7 +238,7 @@ public class QuadCLT extends QuadCLTCPU {
...
@@ -238,7 +238,7 @@ public class QuadCLT extends QuadCLTCPU {
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
threadsMax
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
anum_updated
=
new
AtomicInteger
(
0
);
final
AtomicInteger
anum_updated
=
new
AtomicInteger
(
0
);
final
int
dbg_tile
=
1
066
;
final
int
dbg_tile
=
1
235
;
anum_updated
.
set
(
0
);
anum_updated
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
threads
[
ithread
]
=
new
Thread
()
{
...
@@ -5847,7 +5847,7 @@ if (debugLevel < -100) {
...
@@ -5847,7 +5847,7 @@ if (debugLevel < -100) {
{
{
QuadCLT
quadCLT
=
new
QuadCLT
(
this
,
set_name
);
//null
QuadCLT
quadCLT
=
new
QuadCLT
(
this
,
set_name
);
//null
quadCLT
.
restoreNoModel
(
return
(
QuadCLT
)
quadCLT
.
restoreNoModel
(
clt_parameters
,
clt_parameters
,
colorProcParameters
,
colorProcParameters
,
null
,
// double [] noise_sigma_level,
null
,
// double [] noise_sigma_level,
...
@@ -5855,8 +5855,7 @@ if (debugLevel < -100) {
...
@@ -5855,8 +5855,7 @@ if (debugLevel < -100) {
null
,
// final QuadCLTCPU ref_scene, // may be null if scale_fpn <= 0
null
,
// final QuadCLTCPU ref_scene, // may be null if scale_fpn <= 0
threadsMax
,
threadsMax
,
debugLevel
);
debugLevel
);
// return quadCLT;
return
quadCLT
;
}
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
c430b2f4
...
@@ -88,6 +88,10 @@ import loci.formats.FormatException;
...
@@ -88,6 +88,10 @@ import loci.formats.FormatException;
public
class
QuadCLTCPU
{
public
class
QuadCLTCPU
{
public
static
final
String
[]
DSI_SUFFIXES
=
{
"-INTER-INTRA-LMA"
,
"-INTER-INTRA"
,
"-DSI_MAIN"
};
public
static
int
INDEX_INTER
=
0
;
public
static
int
INDEX_INTER_LMA
=
1
;
public
static
int
INDEX_DSI_MAIN
=
2
;
public
static
final
String
[]
FGBG_TITLES_ADJ
=
{
"disparity"
,
"strength"
};
public
static
final
String
[]
FGBG_TITLES_ADJ
=
{
"disparity"
,
"strength"
};
// public static final String [] FGBG_TITLES = {"disparity","strength", "rms","rms-split","fg-disp","fg-str","bg-disp","bg-str"};
// public static final String [] FGBG_TITLES = {"disparity","strength", "rms","rms-split","fg-disp","fg-str","bg-disp","bg-str"};
public
static
final
String
[]
FGBG_TITLES_AUX
=
{
"disparity"
,
"strength"
,
"rms"
,
"rms-split"
,
"fg-disp"
,
"fg-str"
,
"bg-disp"
,
"bg-str"
,
"aux-disp"
,
"aux-str"
};
public
static
final
String
[]
FGBG_TITLES_AUX
=
{
"disparity"
,
"strength"
,
"rms"
,
"rms-split"
,
"fg-disp"
,
"fg-str"
,
"bg-disp"
,
"bg-str"
,
"aux-disp"
,
"aux-str"
};
...
@@ -354,8 +358,47 @@ public class QuadCLTCPU {
...
@@ -354,8 +358,47 @@ public class QuadCLTCPU {
true
);
//newAllowed, // save
true
);
//newAllowed, // save
return
x3d_path
;
return
x3d_path
;
}
}
public
void
setDSI
(
double
[][]
dsi
)
{
this
.
dsi
=
dsi
;
}
public
void
setDSIFromCombo
(
double
[][]
combo_dsi
)
{
this
.
dsi
=
new
double
[
TwoQuadCLT
.
DSI_SLICES
.
length
][];
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_DISPARITY_AUX
:
TwoQuadCLT
.
DSI_DISPARITY_MAIN
]
=
combo_dsi
[
OpticalFlow
.
COMBO_DSN_INDX_DISP_FG
];
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_STRENGTH_AUX
:
TwoQuadCLT
.
DSI_STRENGTH_MAIN
]
=
combo_dsi
[
OpticalFlow
.
COMBO_DSN_INDX_STRENGTH
];
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_DISPARITY_AUX_LMA
:
TwoQuadCLT
.
DSI_DISPARITY_MAIN_LMA
]
=
combo_dsi
[
OpticalFlow
.
COMBO_DSN_INDX_LMA
];
}
public
boolean
dsiExists
()
{
int
num_slices
=
restoreDSI
(
DSI_SUFFIXES
[
INDEX_DSI_MAIN
],
// String suffix, // "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
null
,
// double [][] dsi, // if null - just check file exists
true
);
// boolean silent);
return
num_slices
>=
0
;
}
public
boolean
interDsiExists
()
{
int
num_slices
=
restoreDSI
(
DSI_SUFFIXES
[
INDEX_INTER_LMA
],
// String suffix, // "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
null
,
// double [][] dsi, // if null - just check file exists
true
);
// boolean silent);
if
(
num_slices
>=
0
)
{
return
true
;
}
num_slices
=
restoreDSI
(
DSI_SUFFIXES
[
INDEX_INTER
],
// String suffix, // "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
null
,
// double [][] dsi, // if null - just check file exists
true
);
// boolean silent);
return
num_slices
>=
0
;
}
public
int
restoreDSI
(
public
int
restoreDSI
(
String
suffix
,
String
suffix
,
boolean
silent
)
// "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
boolean
silent
)
// "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
...
@@ -395,19 +438,38 @@ public class QuadCLTCPU {
...
@@ -395,19 +438,38 @@ public class QuadCLTCPU {
}
}
return
-
1
;
return
-
1
;
}
}
if
(
dsi
==
null
)
{
return
0
;
// just check file exists
}
int
num_slices_read
=
0
;
int
num_slices_read
=
0
;
ImageStack
dsi_stack
=
imp
.
getStack
();
ImageStack
dsi_stack
=
imp
.
getStack
();
for
(
int
nl
=
0
;
nl
<
imp
.
getStackSize
();
nl
++)
{
for
(
int
nl
=
0
;
nl
<
imp
.
getStackSize
();
nl
++)
{
for
(
int
n
=
0
;
n
<
TwoQuadCLT
.
DSI_SLICES
.
length
;
n
++)
multiformat:
if
(
TwoQuadCLT
.
DSI_SLICES
[
n
].
equals
(
dsi_stack
.
getSliceLabel
(
nl
+
1
)))
{
{
float
[]
fpixels
=
(
float
[])
dsi_stack
.
getPixels
(
nl
+
1
);
for
(
int
n
=
0
;
n
<
TwoQuadCLT
.
DSI_SLICES
.
length
;
n
++)
{
dsi
[
n
]
=
new
double
[
fpixels
.
length
];
if
(
TwoQuadCLT
.
DSI_SLICES
[
n
].
equals
(
dsi_stack
.
getSliceLabel
(
nl
+
1
)))
{
for
(
int
i
=
0
;
i
<
fpixels
.
length
;
i
++)
{
float
[]
fpixels
=
(
float
[])
dsi_stack
.
getPixels
(
nl
+
1
);
dsi
[
n
][
i
]
=
fpixels
[
i
];
dsi
[
n
]
=
new
double
[
fpixels
.
length
];
for
(
int
i
=
0
;
i
<
fpixels
.
length
;
i
++)
{
dsi
[
n
][
i
]
=
fpixels
[
i
];
}
num_slices_read
++;
break
multiformat
;
}
}
num_slices_read
++;
break
;
}
}
for
(
int
n
=
0
;
n
<
OpticalFlow
.
COMBO_DSN_TITLES
.
length
;
n
++)
{
if
(
OpticalFlow
.
COMBO_DSN_TITLES
[
n
].
equals
(
dsi_stack
.
getSliceLabel
(
nl
+
1
)))
{
float
[]
fpixels
=
(
float
[])
dsi_stack
.
getPixels
(
nl
+
1
);
dsi
[
n
]
=
new
double
[
fpixels
.
length
];
for
(
int
i
=
0
;
i
<
fpixels
.
length
;
i
++)
{
dsi
[
n
][
i
]
=
fpixels
[
i
];
}
num_slices_read
++;
break
multiformat
;
}
}
}
}
}
return
num_slices_read
;
return
num_slices_read
;
}
}
...
@@ -476,6 +538,7 @@ public class QuadCLTCPU {
...
@@ -476,6 +538,7 @@ public class QuadCLTCPU {
public
Properties
restoreInterProperties
(
// restore properties for interscene processing (extrinsics, ers, ...)
public
Properties
restoreInterProperties
(
// restore properties for interscene processing (extrinsics, ers, ...)
String
path
,
// full name with extension or null to use x3d directory
String
path
,
// full name with extension or null to use x3d directory
boolean
all_properties
,
boolean
all_properties
,
int
debugLevel
)
int
debugLevel
)
{
{
if
(
path
==
null
)
{
if
(
path
==
null
)
{
...
@@ -505,8 +568,30 @@ public class QuadCLTCPU {
...
@@ -505,8 +568,30 @@ public class QuadCLTCPU {
ers
.
getPropertiesLineTime
(
prefix
,
properties
);
// will set old value if not in the file
ers
.
getPropertiesLineTime
(
prefix
,
properties
);
// will set old value if not in the file
System
.
out
.
println
(
"Restored interframe properties from :"
+
path
);
System
.
out
.
println
(
"Restored interframe properties from :"
+
path
);
return
properties
;
return
properties
;
}
}
public
boolean
propertiesContainString
(
String
needle
)
{
return
propertiesContainString
(
needle
,
this
.
properties
);
}
public
static
boolean
propertiesContainString
(
String
needle
,
Properties
properties
)
{
Set
<
String
>
set_keys
=
properties
.
stringPropertyNames
();
boolean
found
=
false
;
for
(
String
haystack:
set_keys
)
{
if
(
haystack
.
indexOf
(
needle
)
>=
0
)
{
found
=
true
;
break
;
}
}
return
found
;
}
// Moving here form QC:
// Moving here form QC:
public
double
[][]
getDSRBG
(){
public
double
[][]
getDSRBG
(){
...
@@ -524,7 +609,13 @@ public class QuadCLTCPU {
...
@@ -524,7 +609,13 @@ public class QuadCLTCPU {
boolean
updateStatus
,
boolean
updateStatus
,
int
debugLevel
)
int
debugLevel
)
{
{
setDSRBG
(
if
(
this
.
dsi
==
null
)
{
if
(
debugLevel
>
-
4
)
{
System
.
out
.
println
(
"--- No DSI available for "
+
this
.
getImageName
());
}
return
;
}
setDSRBG
(
// will likely not be used at all. Use getDLS() instead
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_DISPARITY_AUX
:
TwoQuadCLT
.
DSI_DISPARITY_MAIN
],
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_DISPARITY_AUX
:
TwoQuadCLT
.
DSI_DISPARITY_MAIN
],
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_STRENGTH_AUX
:
TwoQuadCLT
.
DSI_STRENGTH_MAIN
],
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_STRENGTH_AUX
:
TwoQuadCLT
.
DSI_STRENGTH_MAIN
],
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_DISPARITY_AUX_LMA
:
TwoQuadCLT
.
DSI_DISPARITY_MAIN_LMA
],
this
.
dsi
[
is_aux
?
TwoQuadCLT
.
DSI_DISPARITY_AUX_LMA
:
TwoQuadCLT
.
DSI_DISPARITY_MAIN_LMA
],
...
@@ -533,6 +624,7 @@ public class QuadCLTCPU {
...
@@ -533,6 +624,7 @@ public class QuadCLTCPU {
updateStatus
,
updateStatus
,
debugLevel
);
debugLevel
);
}
}
public
void
setDSRBG
(
public
void
setDSRBG
(
double
[]
disparity
,
double
[]
disparity
,
double
[]
strength
,
double
[]
strength
,
...
@@ -561,33 +653,38 @@ public class QuadCLTCPU {
...
@@ -561,33 +653,38 @@ public class QuadCLTCPU {
threadsMax
,
// maximal number of threads to launch
threadsMax
,
// maximal number of threads to launch
updateStatus
,
updateStatus
,
debugLevel
);
debugLevel
);
if
(
isMonochrome
())
{
// only [2] is non-zero
if
(
rbg
==
null
)
{
// will likely not be used at all. Use getDLS() instead
this
.
dsrbg
=
new
double
[][]
{
this
.
dsrbg
=
new
double
[][]
{
disparity
,
disparity
,
strength
,
strength
,
// disparity_lma,
disparity_lma
};
((
rbg
.
length
>
2
)?
rbg
[
2
]:
rbg
[
0
])};
// [2] - for old compatibility, [0] - new (2021)
}
else
{
}
else
{
this
.
dsrbg
=
new
double
[][]
{
if
(
isMonochrome
())
{
// only [2] is non-zero
disparity
,
this
.
dsrbg
=
new
double
[][]
{
strength
,
disparity
,
// disparity_lma,
strength
,
rbg
[
0
],
rbg
[
1
],
rbg
[
2
]};
// disparity_lma,
((
rbg
.
length
>
2
)?
rbg
[
2
]:
rbg
[
0
])};
// [2] - for old compatibility, [0] - new (2021)
}
else
{
this
.
dsrbg
=
new
double
[][]
{
disparity
,
strength
,
// disparity_lma,
rbg
[
0
],
rbg
[
1
],
rbg
[
2
]};
}
if
(
debugLevel
>
1
)
{
// -2) {
String
title
=
image_name
+
"-DSRBG"
;
String
[]
titles
=
getDSRGGTitles
();
(
new
ShowDoubleFloatArrays
()).
showArrays
(
this
.
dsrbg
,
tp
.
getTilesX
(),
tp
.
getTilesY
(),
true
,
title
,
titles
);
}
}
}
if
(
debugLevel
>
1
)
{
// -2) {
String
title
=
image_name
+
"-DSRBG"
;
String
[]
titles
=
getDSRGGTitles
();
(
new
ShowDoubleFloatArrays
()).
showArrays
(
this
.
dsrbg
,
tp
.
getTilesX
(),
tp
.
getTilesY
(),
true
,
title
,
titles
);
}
}
}
public
double
[][]
getTileRBG
(
public
double
[][]
getTileRBG
(
...
@@ -670,6 +767,12 @@ public class QuadCLTCPU {
...
@@ -670,6 +767,12 @@ public class QuadCLTCPU {
true
,
// smart,
true
,
// smart,
true
);
//newAllowed, // save
true
);
//newAllowed, // save
String
[]
sourceFiles
=
correctionsParameters
.
selectSourceFileInSet
(
jp4_copy_path
,
debugLevel
);
String
[]
sourceFiles
=
correctionsParameters
.
selectSourceFileInSet
(
jp4_copy_path
,
debugLevel
);
if
(
sourceFiles
.
length
<
getNumSensors
())
{
if
(
sourceFiles
.
length
>
0
)
{
System
.
out
.
println
(
"not enough source files ("
+
sourceFiles
.
length
+
") in "
+
jp4_copy_path
);
}
return
null
;
}
SetChannels
[]
set_channels
=
setChannels
(
SetChannels
[]
set_channels
=
setChannels
(
null
,
// single set name
null
,
// single set name
sourceFiles
,
sourceFiles
,
...
@@ -705,19 +808,32 @@ public class QuadCLTCPU {
...
@@ -705,19 +808,32 @@ public class QuadCLTCPU {
1
);
// debugLevel); // final int debug_level)
1
);
// debugLevel); // final int debug_level)
}
}
// try to restore DSI generated from interscene if available, if not use single-scene -DSI_MAIN
// try to restore DSI generated from interscene if available, if not use single-scene -DSI_MAIN
if
(
restoreDSI
(
int
dsi_result
=
-
1
;
"-DSI_INTER"
,
double
[][]
dsi_tmp
=
new
double
[
11
][];
true
// silent
for
(
int
i
=
0
;
i
<
DSI_SUFFIXES
.
length
;
i
++)
{
)
<
0
)
{
dsi_result
=
restoreDSI
(
restoreDSI
(
DSI_SUFFIXES
[
i
],
"-DSI_MAIN"
,
// "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
dsi_tmp
,
//double [][] dsi,
false
);
// silent
(
i
<
(
DSI_SUFFIXES
.
length
-
1
)));
// silent
if
(
dsi_result
>=
0
)
{
System
.
out
.
println
(
"Using "
+
getX3dDirectory
()+
Prefs
.
getFileSeparator
()
+
image_name
+
DSI_SUFFIXES
[
i
]
+
".tiff"
);
if
(
i
<
2
)
{
// DSI format for COMBO_DSN_INDX_* is different,
setDSIFromCombo
(
dsi_tmp
);
// reformat
}
else
{
setDSI
(
dsi_tmp
);
// as is
}
break
;
}
}
if
(
dsi_result
<
0
)
{
System
.
out
.
println
(
"No DSI data for the scene "
+
this
.
getImageName
()+
", setting this.dsi=null"
);
setDSI
(
null
);
}
else
{
restoreInterProperties
(
// restore properties for interscene processing (extrinsics, ers, ...) // get relative poses (98)
null
,
// String path, // full name with extension or null to use x3d directory
false
,
// boolean all_properties,// null, // Properties properties, // if null - will only save extrinsics)
debugLevel
);
}
}
restoreInterProperties
(
// restore properties for interscene processing (extrinsics, ers, ...) // get relative poses (98)
null
,
// String path, // full name with extension or null to use x3d directory
false
,
// boolean all_properties,// null, // Properties properties, // if null - will only save extrinsics)
debugLevel
);
// showDSIMain();
return
this
;
// can only be QuadCLT instance
return
this
;
// can only be QuadCLT instance
}
}
...
@@ -738,6 +854,12 @@ public class QuadCLTCPU {
...
@@ -738,6 +854,12 @@ public class QuadCLTCPU {
true
,
// smart,
true
,
// smart,
true
);
//newAllowed, // save
true
);
//newAllowed, // save
String
[]
sourceFiles
=
correctionsParameters
.
selectSourceFileInSet
(
jp4_copy_path
,
debugLevel
);
String
[]
sourceFiles
=
correctionsParameters
.
selectSourceFileInSet
(
jp4_copy_path
,
debugLevel
);
if
(
sourceFiles
.
length
<
getNumSensors
())
{
if
(
sourceFiles
.
length
>
0
)
{
System
.
out
.
println
(
"not enough source files ("
+
sourceFiles
.
length
+
") in "
+
jp4_copy_path
);
}
return
null
;
}
SetChannels
[]
set_channels
=
setChannels
(
SetChannels
[]
set_channels
=
setChannels
(
null
,
// single set name
null
,
// single set name
sourceFiles
,
sourceFiles
,
...
...
src/main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
View file @
c430b2f4
...
@@ -11311,7 +11311,7 @@ if (debugLevel > -100) return true; // temporarily !
...
@@ -11311,7 +11311,7 @@ if (debugLevel > -100) return true; // temporarily !
// QuadCLT last_scene = quadCLTs[last_scene_index];
// QuadCLT last_scene = quadCLTs[last_scene_index];
QuadCLT
ref_scene
=
quadCLTs
[
ref_scene_index
];
QuadCLT
ref_scene
=
quadCLTs
[
ref_scene_index
];
String
composite_suffix
=
"-INTER-INTRA-LMA"
;
String
composite_suffix
=
"-INTER-INTRA-LMA"
;
// is already read if available!
String
num_corr_max_suffix
=
"-NUM-CORR-MAX"
;
String
num_corr_max_suffix
=
"-NUM-CORR-MAX"
;
int
[]
wh
=
new
int
[
2
];
int
[]
wh
=
new
int
[
2
];
double
[][]
composite_ds
=
ref_scene
.
readDoubleArrayFromModelDirectory
(
double
[][]
composite_ds
=
ref_scene
.
readDoubleArrayFromModelDirectory
(
...
@@ -11337,7 +11337,7 @@ if (debugLevel > -100) return true; // temporarily !
...
@@ -11337,7 +11337,7 @@ if (debugLevel > -100) return true; // temporarily !
// int [] num_tiles = new int [clusters]; // may be null;; // null;
// int [] num_tiles = new int [clusters]; // may be null;; // null;
// boolean [] inf_cluster = new boolean [clusters]; // null;
// boolean [] inf_cluster = new boolean [clusters]; // null;
boolean
debug
=
debugLevel
>
-
2
;
boolean
debug
=
debugLevel
>
-
3
;
if
(
proc_infinity
)
{
if
(
proc_infinity
)
{
double
[]
inf_avg
=
new
double
[
1
];
double
[]
inf_avg
=
new
double
[
1
];
...
@@ -11666,6 +11666,8 @@ if (debugLevel > -100) return true; // temporarily !
...
@@ -11666,6 +11666,8 @@ if (debugLevel > -100) return true; // temporarily !
final
boolean
updateStatus
,
final
boolean
updateStatus
,
final
int
debugLevel
)
throws
Exception
final
int
debugLevel
)
throws
Exception
{
{
if
((
quadCLT_main
!=
null
)
&&
(
quadCLT_main
.
getGPU
()
!=
null
))
{
if
((
quadCLT_main
!=
null
)
&&
(
quadCLT_main
.
getGPU
()
!=
null
))
{
quadCLT_main
.
setQuadClt
();
// ignore previous result,
quadCLT_main
.
setQuadClt
();
// ignore previous result,
}
}
...
@@ -11673,6 +11675,7 @@ if (debugLevel > -100) return true; // temporarily !
...
@@ -11673,6 +11675,7 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_aux
.
setQuadClt
();
quadCLT_aux
.
setQuadClt
();
}
}
//quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt
// final boolean batch_mode = clt_parameters.batch_run;
// final boolean batch_mode = clt_parameters.batch_run;
// Reset dsi data (only 2 slices will be used)
// Reset dsi data (only 2 slices will be used)
...
@@ -11684,8 +11687,22 @@ if (debugLevel > -100) return true; // temporarily !
...
@@ -11684,8 +11687,22 @@ if (debugLevel > -100) return true; // temporarily !
this
.
startTime
=
System
.
nanoTime
();
this
.
startTime
=
System
.
nanoTime
();
String
[]
sourceFiles
=
quadCLT_main
.
correctionsParameters
.
getSourcePaths
();
String
[]
sourceFiles
=
quadCLT_main
.
correctionsParameters
.
getSourcePaths
();
QuadCLT
.
SetChannels
[]
set_channels_main
=
quadCLT_main
.
setChannels
(
debugLevel
);
boolean
process_main_sources
=
false
;
QuadCLT
.
SetChannels
[]
set_channels_aux
=
quadCLT_aux
.
setChannels
(
debugLevel
);
boolean
process_aux_sources
=
false
;
// TODO: clean up - are there duplicates
if
(
quadCLT_main
!=
null
)
{
process_main_sources
|=
quadCLT_main
.
correctionsParameters
.
process_main_sources
;
process_aux_sources
|=
quadCLT_main
.
correctionsParameters
.
process_aux_sources
;
}
if
(
quadCLT_aux
!=
null
)
{
process_aux_sources
|=
quadCLT_aux
.
correctionsParameters
.
process_main_sources
;
process_aux_sources
|=
quadCLT_aux
.
correctionsParameters
.
process_aux_sources
;
}
//quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt
QuadCLT
.
SetChannels
[]
set_channels_main
=
process_main_sources
?
quadCLT_main
.
setChannels
(
debugLevel
):
null
;
QuadCLT
.
SetChannels
[]
set_channels_aux
=
process_aux_sources
?
quadCLT_aux
.
setChannels
(
debugLevel
):
null
;
QuadCLT
.
SetChannels
[]
set_channels
=
set_channels_main
;
QuadCLT
.
SetChannels
[]
set_channels
=
set_channels_main
;
if
((
set_channels
==
null
)
||
((
set_channels_aux
!=
null
)
&&
(
set_channels_aux
.
length
>
set_channels
.
length
)))
{
if
((
set_channels
==
null
)
||
((
set_channels_aux
!=
null
)
&&
(
set_channels_aux
.
length
>
set_channels
.
length
)))
{
set_channels
=
set_channels_aux
;
set_channels
=
set_channels_aux
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment