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
23452c5b
Commit
23452c5b
authored
May 23, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing fast single-stage poses that require DSI for ref scene only
parent
57bfb4d6
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1393 additions
and
380 deletions
+1393
-380
Eyesis_Correction.java
.../java/com/elphel/imagej/correction/Eyesis_Correction.java
+107
-1
JP46_Reader_camera.java
src/main/java/com/elphel/imagej/jp4/JP46_Reader_camera.java
+1
-0
Correlation2d.java
...n/java/com/elphel/imagej/tileprocessor/Correlation2d.java
+11
-7
ErsCorrection.java
...n/java/com/elphel/imagej/tileprocessor/ErsCorrection.java
+17
-0
GeometryCorrection.java
...a/com/elphel/imagej/tileprocessor/GeometryCorrection.java
+3
-0
ImageDtt.java
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
+92
-4
IntersceneLma.java
...n/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
+4
-4
IntersceneMatchParameters.java
...lphel/imagej/tileprocessor/IntersceneMatchParameters.java
+86
-5
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+836
-310
QuadCLT.java
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
+21
-1
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+110
-16
TwoQuadCLT.java
...main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
+105
-32
No files found.
src/main/java/com/elphel/imagej/correction/Eyesis_Correction.java
View file @
23452c5b
...
...
@@ -737,6 +737,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
panelClt5aux
=
new
Panel
();
panelClt5aux
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
// rows, columns, vgap, hgap
addButton
(
"LIST extrinsics"
,
panelClt5aux
,
color_report
);
addButton
(
"Aux Build Series"
,
panelClt5aux
,
color_stop
);
addButton
(
"Aux Inter Test"
,
panelClt5aux
,
color_stop
);
addButton
(
"Aux Inter Pairs"
,
panelClt5aux
,
color_process
);
addButton
(
"Aux Inter LMA"
,
panelClt5aux
,
color_stop
);
...
...
@@ -5132,6 +5133,13 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
testInterScene
(
false
);
return
;
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Aux Build Series"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EYESIS_CORRECTIONS
.
setDebug
(
DEBUG_LEVEL
);
CLT_PARAMETERS
.
batch_run
=
true
;
buildSeries
(
true
);
return
;
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Aux Inter Test"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EYESIS_CORRECTIONS
.
setDebug
(
DEBUG_LEVEL
);
...
...
@@ -6746,6 +6754,102 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return
true
;
}
public
boolean
buildSeries
(
boolean
use_aux
)
{
long
startTime
=
System
.
nanoTime
();
// load needed sensor and kernels files
if
(!
prepareRigImages
())
return
false
;
String
configPath
=
getSaveCongigPath
();
if
(
configPath
.
equals
(
"ABORT"
))
return
false
;
setAllProperties
(
PROPERTIES
);
// batchRig may save properties with the model. Extrinsics will be updated,
// others should be set here
if
(
DEBUG_LEVEL
>
-
2
)
{
System
.
out
.
println
(
"++++++++++++++ Building series from scratch ++++++++++++++"
);
}
if
(
CLT_PARAMETERS
.
useGPU
())
{
// only init GPU instances if it is used
if
(
GPU_TILE_PROCESSOR
==
null
)
{
try
{
GPU_TILE_PROCESSOR
=
new
GPUTileProcessor
(
CORRECTION_PARAMETERS
.
tile_processor_gpu
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Failed to initialize GPU class"
);
// TODO Auto-generated catch block
e
.
printStackTrace
();
return
false
;
}
// final int debugLevel);
}
if
(
use_aux
)
{
if
(
CLT_PARAMETERS
.
useGPU
(
true
)
&&
(
QUAD_CLT_AUX
!=
null
)
&&
(
GPU_QUAD_AUX
==
null
))
{
// if GPU AUX is
// needed
try
{
GPU_QUAD_AUX
=
new
GpuQuad
(
//
GPU_TILE_PROCESSOR
,
QUAD_CLT_AUX
,
CLT_PARAMETERS
.
gpu_debug_level
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Failed to initialize GpuQuad class"
);
// TODO Auto-generated catch block
e
.
printStackTrace
();
return
false
;
}
// final int debugLevel);
QUAD_CLT_AUX
.
setGPU
(
GPU_QUAD_AUX
);
}
}
else
{
if
(
CLT_PARAMETERS
.
useGPU
(
false
)
&&
(
QUAD_CLT
!=
null
)
&&
(
GPU_QUAD
==
null
))
{
// if GPU main is needed
try
{
GPU_QUAD
=
new
GpuQuad
(
GPU_TILE_PROCESSOR
,
QUAD_CLT
,
CLT_PARAMETERS
.
gpu_debug_level
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Failed to initialize GpuQuad class"
);
// TODO Auto-generated catch block
e
.
printStackTrace
();
return
false
;
}
// final int debugLevel);
QUAD_CLT
.
setGPU
(
GPU_QUAD
);
}
}
}
QuadCLT
quadCLT
=
use_aux
?
QUAD_CLT_AUX
:
QUAD_CLT
;
ColorProcParameters
colorProcParameters
=
use_aux
?
COLOR_PROC_PARAMETERS_AUX
:
COLOR_PROC_PARAMETERS
;
CLT_PARAMETERS
.
setColorProcParameters
(
COLOR_PROC_PARAMETERS
,
false
);
CLT_PARAMETERS
.
setColorProcParameters
(
COLOR_PROC_PARAMETERS_AUX
,
true
);
CLT_PARAMETERS
.
setRGBParameters
(
RGB_PARAMETERS
);
try
{
TWO_QUAD_CLT
.
buildSeriesTQ
(
quadCLT
,
// QUAD_CLT, // QuadCLT quadCLT_main,
-
1
,
// int ref_index,
0
,
// int ref_step,
// QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS
,
// EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters
,
// COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
// colorProcParameters,
CHANNEL_GAINS_PARAMETERS
,
// CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS
,
// EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS
,
// EyesisCorrectionParameters.EquirectangularParameters
// equirectangularParameters,
PROPERTIES
,
// Properties properties,
true
,
// false, // boolean reset_from_extrinsics,
THREADS_MAX
,
// final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
// final boolean updateStatus,
DEBUG_LEVEL
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
// final int debugLevel);
if
(
configPath
!=
null
)
{
saveTimestampedProperties
(
// save config again
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
System
.
out
.
println
(
"batchRig(): Processing finished at "
+
IJ
.
d2s
(
0.000000001
*
(
System
.
nanoTime
()
-
startTime
),
3
)
+
" sec, --- Free memory="
+
Runtime
.
getRuntime
().
freeMemory
()
+
" (of "
+
Runtime
.
getRuntime
().
totalMemory
()
+
")"
);
return
true
;
}
public
boolean
testInterLMA
(
boolean
use_aux
)
{
long
startTime
=
System
.
nanoTime
();
// load needed sensor and kernels files
...
...
@@ -7791,12 +7895,14 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
System
.
out
.
println
(
"++++++++++++++ Copying JP4 source files ++++++++++++++"
);
}
try
{
T
WO_QUAD_
CLT
.
copyJP4src
(
// actually there is no sense to process multiple image sets. Combine with other
T
woQuad
CLT
.
copyJP4src
(
// actually there is no sense to process multiple image sets. Combine with other
// processing?
null
,
// String set_name
QUAD_CLT
,
// QuadCLT quadCLT_main,
QUAD_CLT_AUX
,
// QuadCLT quadCLT_aux,
CLT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
true
,
// boolean skip_existing,
true
,
// boolean search_KML,
DEBUG_LEVEL
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
...
...
src/main/java/com/elphel/imagej/jp4/JP46_Reader_camera.java
View file @
23452c5b
...
...
@@ -328,6 +328,7 @@ public class JP46_Reader_camera implements PlugIn, ActionListener {
imp
=
openJpegOrGif
(
directory
,
fileName
);
if
(
imp
==
null
)
{
IJ
.
showMessage
(
"JP46 Reader Error"
,
"Could not open "
+
directory
+
""
+
fileName
+
" as JPEG/JP46"
);
System
.
out
.
println
(
"JP46 Reader Error: Could not open "
+
directory
+
""
+
fileName
+
" as JPEG/JP46"
);
}
else
{
if
((
imp_src
==
null
)&&
showImage
)
imp
.
show
();
/* Shows before re-ordering*/
ElphelMakerNote
=
readElphelMakerNote
(
directory
,
fileName
,
16
,
xtraExif
);
/* after or 8.2.2 */
...
...
src/main/java/com/elphel/imagej/tileprocessor/Correlation2d.java
View file @
23452c5b
...
...
@@ -2438,11 +2438,13 @@ public class Correlation2d {
for
(
int
ix
=
0
;
ix
<
data_width
;
ix
++)
{
double
x
=
ix
-
x0
;
double
d
=
data
[
iy
*
data_width
+
ix
];
if
(
d
>
0
)
{
// ignore negative
s0
+=
d
;
sx
+=
d
*
x
;
sy
+=
d
*
y
;
}
}
}
x0
+=
sx
/
s0
;
y0
+=
sy
/
s0
;
}
else
{
...
...
@@ -2457,6 +2459,7 @@ public class Correlation2d {
if
(
r2
<
radius2
)
{
double
r
=
Math
.
sqrt
(
r2
);
double
d
=
data
[
iy
*
data_width
+
ix
];
if
(
d
>
0
)
{
// ignore negative
d
*=
Math
.
cos
(
0.5
*
Math
.
PI
*
r
/
radius
);
s0
+=
d
;
sx
+=
d
*
x
;
...
...
@@ -2464,6 +2467,7 @@ public class Correlation2d {
}
}
}
}
x0
+=
sx
/
s0
;
y0
+=
sy
/
s0
;
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/ErsCorrection.java
View file @
23452c5b
...
...
@@ -1987,6 +1987,23 @@ public class ErsCorrection extends GeometryCorrection {
}
}
public
static
double
[][]
combineXYZATR
(
double
[][]
reference_xyzatr
,
double
[][]
scene_xyzatr
){
return
combineXYZATR
(
reference_xyzatr
[
0
],
reference_xyzatr
[
1
],
scene_xyzatr
[
0
],
scene_xyzatr
[
1
]);
}
public
static
double
[][]
invertXYZATR
(
double
[][]
source_xyzatr
){
return
invertXYZATR
(
source_xyzatr
[
0
],
source_xyzatr
[
1
]);
}
public
static
double
[][]
combineXYZATR
(
double
[]
reference_xyz
,
double
[]
reference_atr
,
...
...
src/main/java/com/elphel/imagej/tileprocessor/GeometryCorrection.java
View file @
23452c5b
...
...
@@ -320,6 +320,9 @@ public class GeometryCorrection {
System
.
arraycopy
(
right
,
0
,
egc
.
right
,
0
,
min_nc
);
System
.
arraycopy
(
height
,
0
,
egc
.
height
,
0
,
min_nc
);
System
.
arraycopy
(
roll
,
0
,
egc
.
roll
,
0
,
min_nc
);
if
(
woi_tops
==
null
)
{
woi_tops
=
new
int
[
min_nc
];
}
System
.
arraycopy
(
woi_tops
,
0
,
egc
.
woi_tops
,
0
,
min_nc
);
for
(
int
n
=
0
;
n
<
min_nc
;
n
++)
{
egc
.
pXY0
[
n
]
=
pXY0
[
n
].
clone
();
...
...
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
View file @
23452c5b
...
...
@@ -2467,6 +2467,10 @@ public class ImageDtt extends ImageDttCPU {
final
int
n_recenter
,
// when cosine window, re-center window this many times
final
double
min_str
,
// = 0.25;
final
double
min_str_sum
,
// = 0.8; // 5;
final
int
min_neibs
,
// 2; // minimal number of strong neighbors (> min_str)
final
double
weight_zero_neibs
,
// 0.2; // Reduce weight for no-neib (1.0 for all 8)
final
double
half_disparity
,
// 5.0; // Reduce weight twice for this disparity
final
double
half_avg_diff
,
// 0.2; // when L2 of x,y difference from average of neibs - reduce twice
final
int
debug_tileX
,
final
int
debug_tileY
,
final
int
threadsMax
,
// maximal number of threads to launch
...
...
@@ -2477,6 +2481,7 @@ public class ImageDtt extends ImageDttCPU {
System
.
out
.
println
(
"clt_process_tl_interscene(): this.gpuQuad is null, bailing out"
);
return
null
;
}
// final int min_neibs = clt_parameters.imp.min_neibs;
final
boolean
extra_sum
=
true
;
// use sum of pixel-domain correlations (TD have artifacts for low contrast
// - maybe -related to float vs. double - not tested yet
// final int width = gpuQuad.getImageWidth();
...
...
@@ -2657,15 +2662,19 @@ public class ImageDtt extends ImageDttCPU {
centroid_radius
,
// double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
n_recenter
,
// int refine, // re-center window around new maximum. 0 -no refines (single-pass)
false
);
// boolean debug)
if
((
mv
!=
null
)
&&
(
mv
[
2
]
<
min_str
))
{
if
(
mv
!=
null
)
{
if
(
mv
[
2
]
<
min_str
)
{
mv
=
null
;
}
else
{
mv
[
2
]
-=
min_str
;
}
}
if
(
mv
!=
null
)
{
if
(
pXpYD
==
null
)
{
coord_motion
[
0
][
nTile
]
=
mv
;
}
else
{
if
(
pXpYD
[
nTile
]
!=
null
)
{
// seems always
coord_motion
[
0
][
nTile
]
=
pXpYD
[
nTile
];
coord_motion
[
0
][
nTile
]
=
pXpYD
[
nTile
]
.
clone
()
;
coord_motion
[
1
][
nTile
]
=
mv
;
}
}
...
...
@@ -2675,6 +2684,85 @@ public class ImageDtt extends ImageDttCPU {
};
}
startAndJoin
(
threads
);
ai
.
set
(
0
);
final
int
tiles
=
tilesX
*
tilesY
;
final
double
[][]
mv
=
coord_motion
[
coord_motion
.
length
-
1
];
final
double
[][]
pxd
=
(
coord_motion
.
length
>
1
)
?
coord_motion
[
0
]
:
null
;
final
double
scale_num_neib
=
((
weight_zero_neibs
>=
0
)
&&
(
weight_zero_neibs
<
1.0
))
?
(
weight_zero_neibs
*
8
/(
1.0
-
weight_zero_neibs
)):
0.0
;
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
double
l2
;
TileNeibs
tn
=
new
TileNeibs
(
tilesX
,
tilesY
);
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
tiles
;
nTile
=
ai
.
getAndIncrement
())
{
if
((
mv
[
nTile
]
!=
null
)
&&
(
pXpYD
[
nTile
]
!=
null
))
{
int
num_neibs
=
0
;
double
sx
=
0.0
,
sy
=
0.0
;
for
(
int
dir
=
0
;
dir
<
8
;
dir
++)
{
int
nTile1
=
tn
.
getNeibIndex
(
nTile
,
dir
);
if
((
nTile1
>=
0
)
&&
(
mv
[
nTile1
]
!=
null
)
&&
(
pXpYD
[
nTile1
]
!=
null
)
&&
!
Double
.
isNaN
(
mv
[
nTile1
][
2
])
&&
!
Double
.
isNaN
(
mv
[
nTile1
][
0
])
&&
!
Double
.
isNaN
(
mv
[
nTile1
][
1
])){
num_neibs
++;
sx
+=
mv
[
nTile1
][
0
];
sy
+=
mv
[
nTile1
][
1
];
}
}
if
(
num_neibs
<
min_neibs
)
{
// filter by minimal neighbors
mv
[
nTile
][
2
]
=
0
;
/*
mv[nTile] = null;
if (pxd != null) {
pxd[nTile] = null;
}
*/
continue
;
}
if
((
weight_zero_neibs
>=
0
)
&&
(
weight_zero_neibs
<
1.0
))
{
// scale weight by number of neighbors
mv
[
nTile
][
2
]
*=
(
num_neibs
+
scale_num_neib
)/(
8.0
+
scale_num_neib
);
}
if
(
half_disparity
>
0.0
)
{
// scale by disparity
mv
[
nTile
][
2
]
*=
half_disparity
/(
half_disparity
+
pxd
[
nTile
][
2
]);
}
if
((
half_avg_diff
>
0.0
)
&&(
num_neibs
>
0
))
{
double
dx
=
mv
[
nTile
][
0
]
-
sx
/
num_neibs
;
double
dy
=
mv
[
nTile
][
1
]
-
sy
/
num_neibs
;
l2
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
mv
[
nTile
][
2
]
*=
half_avg_diff
/(
half_avg_diff
+
l2
);
}
}
}
}
};
}
startAndJoin
(
threads
);
ai
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
double
l2
;
TileNeibs
tn
=
new
TileNeibs
(
tilesX
,
tilesY
);
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
tiles
;
nTile
=
ai
.
getAndIncrement
())
{
if
((
mv
[
nTile
]
!=
null
)
&&
(
pXpYD
[
nTile
]
!=
null
))
{
if
(
mv
[
nTile
][
2
]
<=
0
)
{
mv
[
nTile
]
=
null
;
if
(
pxd
!=
null
)
{
pxd
[
nTile
]
=
null
;
}
}
}
}
}
};
}
startAndJoin
(
threads
);
return
coord_motion
;
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
View file @
23452c5b
...
...
@@ -389,7 +389,7 @@ public class IntersceneLma {
Matrix
wjtjlambda
=
new
Matrix
(
getWJtJlambda
(
lambda
,
// *10, // temporary
this
.
last_jt
));
// double [][] jt)
if
(
debug_level
>
1
)
{
if
(
debug_level
>
2
)
{
try
{
System
.
out
.
println
(
"getFxDerivs(): getChecksum(this.y_vector)="
+
getChecksum
(
this
.
y_vector
));
System
.
out
.
println
(
"getFxDerivs(): getChecksum(this.weights)="
+
getChecksum
(
this
.
weights
));
...
...
@@ -427,7 +427,7 @@ public class IntersceneLma {
System
.
out
.
println
(
"Jt * (y-fx)"
);
jty
.
print
(
18
,
6
);
}
if
(
debug_level
>
1
)
{
if
(
debug_level
>
2
)
{
try
{
System
.
out
.
println
(
"getFxDerivs(): getChecksum(jtjl_inv)="
+
getChecksum
(
jtjl_inv
));
System
.
out
.
println
(
"getFxDerivs(): getChecksum(jty)= "
+
getChecksum
(
jty
));
...
...
@@ -451,7 +451,7 @@ public class IntersceneLma {
for
(
int
i
=
0
;
i
<
parameters_vector
.
length
;
i
++)
{
new_vector
[
i
]
+=
scale
*
delta
[
i
];
}
if
(
debug_level
>
1
)
{
if
(
debug_level
>
2
)
{
try
{
System
.
out
.
println
(
"getFxDerivs(): getChecksum(mdelta)= "
+
getChecksum
(
mdelta
));
System
.
out
.
println
(
"getFxDerivs(): getChecksum(delta)= "
+
getChecksum
(
delta
));
...
...
@@ -793,7 +793,7 @@ public class IntersceneLma {
fx
[
i
+
2
*
macrotile_centers
.
length
]
=
vector
[
i
];
// - parameters_initial[i]; // scale will be combined with weights
jt
[
i
][
i
+
2
*
macrotile_centers
.
length
]
=
1.0
;
// scale will be combined with weights
}
if
(
debug_level
>
1
)
{
if
(
debug_level
>
2
)
{
try
{
System
.
out
.
println
(
"getFxDerivs(): getChecksum(fx)="
+
getChecksum
(
fx
));
if
(
jt
!=
null
)
{
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java
View file @
23452c5b
...
...
@@ -34,11 +34,26 @@ public class IntersceneMatchParameters {
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
boolean
use_partial
=
true
;
// find motion vectors for individual pairs, false - for sum only
public
boolean
run_poly
=
false
;
// not yet imp
[
lemented
public
boolean
run_poly
=
false
;
// not yet implemented
public
double
centroid_radius
=
4.0
;
//
public
int
n_recenter
=
2
;
// when cosine window, re-center window this many times
// filtering motion vectors
public
double
min_str
=
0.25
;
// minimal correlation strength for all but TD-accumulated layer
public
double
min_str_sum
=
0.8
;
// minimal correlation strength for TD-accumulated layer
public
int
min_neibs
=
2
;
// minimal number of strong neighbors (> min_str)
public
double
weight_zero_neibs
=
0.2
;
// Reduce weight for no-neib (1.0 for all 8)
public
double
half_disparity
=
5.0
;
// Reduce weight twice for this disparity
public
double
half_avg_diff
=
0.2
;
// when L2 of x,y difference from average of neibs - reduce twice
// Detect initial match
public
int
pix_step
=
4
;
// Azimuth/tilt search step in pixels
public
int
search_rad
=
10
;
// Search radius in steps
public
double
maybe_sum
=
8.0
;
// minimal sum of strengths (will search for the best)
public
double
shure_sum
=
30.0
;
// definitely good sum of strengths (no farther search)
public
double
maybe_avg
=
0.005
;
// maybe average strength
public
double
shure_avg
=
0.015
;
// sure average strength
//LMA parameters
public
boolean
[]
adjust_atr
=
new
boolean
[]
{
true
,
true
,
true
};
public
boolean
[]
adjust_xyz
=
new
boolean
[]
{
true
,
true
,
true
};
...
...
@@ -60,7 +75,8 @@ public class IntersceneMatchParameters {
public
boolean
renderRef
()
{
return
(
debug_level
>
1
)
&&
render_ref
;}
public
boolean
renderScene
()
{
return
(
debug_level
>
1
)
&&
render_scene
;}
public
boolean
show2dCorrelations
()
{
return
(
debug_level
>
1
)
&&
show_2d_correlations
;}
public
boolean
showMotionVectors
()
{
return
(
debug_level
>
0
)
&&
show_motion_vectors
;}
public
boolean
showMotionVectors
()
{
return
(
debug_level
>
1
)
&&
show_motion_vectors
;}
public
boolean
showCorrMotion
()
{
return
(
debug_level
>
0
)
&&
show_motion_vectors
;}
public
IntersceneMatchParameters
()
{
...
...
@@ -81,10 +97,34 @@ public class IntersceneMatchParameters {
"Calculate centroids after multiplication by a half-cosine window. All correlation data farther than this value from the center is ignored"
);
gd
.
addNumericField
(
"Refine centroids"
,
this
.
n_recenter
,
0
,
5
,
""
,
"Repeat centroids after moving the window center to the new centroid location this many times (0 - calculate once)"
);
gd
.
addMessage
(
"Filtering motion vectors"
);
gd
.
addNumericField
(
"Minimal correlation strength (non-sum)"
,
this
.
min_str
,
5
,
7
,
""
,
"Minimal correlation strength for individual correlation and for pixel-domain averaged one. Weeker tiles results are removed."
);
gd
.
addNumericField
(
"Minimal correlation strength (sum only)"
,
this
.
min_str_sum
,
5
,
7
,
""
,
"Minimal correlation strength for transform-domain averaging. Weeker tiles results are removed."
);
gd
.
addNumericField
(
"Minimal number of neighbors (of 8)"
,
this
.
min_neibs
,
0
,
3
,
""
,
"Remove motion vectors with less than this number of defined (passing min_str) neighbors."
);
gd
.
addNumericField
(
"No-neighbors weight (<1.0)"
,
this
.
weight_zero_neibs
,
5
,
7
,
""
,
"Punish for reduced neighbors - weigh for no-neighbors), weight of 8 neighbors = 1.0."
);
gd
.
addNumericField
(
"Disparity to reduce weight twice from infinity"
,
this
.
half_disparity
,
5
,
7
,
""
,
"Weight at this disparity is 0.5, at infinity - 1.0."
);
gd
.
addNumericField
(
"Difference from neighbors average "
,
this
.
half_avg_diff
,
5
,
7
,
""
,
"Reduce twice for high difference from neighbors average."
);
gd
.
addMessage
(
"Initial search for the intre-scene match"
);
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"
);
gd
.
addNumericField
(
"Search spiral radius"
,
this
.
search_rad
,
0
,
3
,
"steps"
,
"Maximal search radius in steps"
);
gd
.
addNumericField
(
"\"Maybe\" sum of strengths"
,
this
.
maybe_sum
,
5
,
7
,
""
,
"Minimal acceptable sum of defined tiles strengths (will look for the best among matching)"
);
gd
.
addNumericField
(
"\"Sure\" sum of strengths"
,
this
.
shure_sum
,
5
,
7
,
""
,
"Definitely sufficient sum of defined tiles strengths (will non continue looking for better)."
);
gd
.
addNumericField
(
"\"Maybe\" average of strengths"
,
this
.
maybe_avg
,
5
,
7
,
""
,
"Minimal acceptable average of defined tiles strengths (will look for the best among matching)"
);
gd
.
addNumericField
(
"\"Sure\" average of strengths"
,
this
.
shure_avg
,
5
,
7
,
""
,
"Definitely sufficient average of defined tiles strengths (will non continue looking for better)."
);
gd
.
addMessage
(
"LMA parameters"
);
gd
.
addCheckbox
(
"Azimuth"
,
this
.
adjust_atr
[
0
],
...
...
@@ -141,6 +181,16 @@ public class IntersceneMatchParameters {
this
.
n_recenter
=
(
int
)
gd
.
getNextNumber
();
this
.
min_str
=
gd
.
getNextNumber
();
this
.
min_str_sum
=
gd
.
getNextNumber
();
this
.
min_neibs
=
(
int
)
gd
.
getNextNumber
();
this
.
weight_zero_neibs
=
gd
.
getNextNumber
();
this
.
half_disparity
=
gd
.
getNextNumber
();
this
.
half_avg_diff
=
gd
.
getNextNumber
();
this
.
pix_step
=
(
int
)
gd
.
getNextNumber
();
this
.
search_rad
=
(
int
)
gd
.
getNextNumber
();
this
.
maybe_sum
=
gd
.
getNextNumber
();
this
.
shure_sum
=
gd
.
getNextNumber
();
this
.
maybe_avg
=
gd
.
getNextNumber
();
this
.
shure_avg
=
gd
.
getNextNumber
();
this
.
adjust_atr
[
0
]
=
gd
.
getNextBoolean
();
this
.
adjust_atr
[
1
]
=
gd
.
getNextBoolean
();
this
.
adjust_atr
[
2
]
=
gd
.
getNextBoolean
();
...
...
@@ -159,6 +209,8 @@ public class IntersceneMatchParameters {
this
.
show_2d_correlations
=
gd
.
getNextBoolean
();
this
.
show_motion_vectors
=
gd
.
getNextBoolean
();
this
.
debug_level
=
(
int
)
gd
.
getNextNumber
();
if
(
this
.
weight_zero_neibs
>
1.0
)
this
.
weight_zero_neibs
=
1.0
;
}
public
void
setProperties
(
String
prefix
,
Properties
properties
){
...
...
@@ -170,6 +222,16 @@ public class IntersceneMatchParameters {
properties
.
setProperty
(
prefix
+
"n_recenter"
,
this
.
n_recenter
+
""
);
// int
properties
.
setProperty
(
prefix
+
"min_str"
,
this
.
min_str
+
""
);
// double
properties
.
setProperty
(
prefix
+
"min_str_sum"
,
this
.
min_str_sum
+
""
);
// double
properties
.
setProperty
(
prefix
+
"min_neibs"
,
this
.
min_neibs
+
""
);
// int
properties
.
setProperty
(
prefix
+
"weight_zero_neibs"
,
this
.
weight_zero_neibs
+
""
);
// double
properties
.
setProperty
(
prefix
+
"half_disparity"
,
this
.
half_disparity
+
""
);
// double
properties
.
setProperty
(
prefix
+
"half_avg_diff"
,
this
.
half_avg_diff
+
""
);
// double
properties
.
setProperty
(
prefix
+
"pix_step"
,
this
.
pix_step
+
""
);
// int
properties
.
setProperty
(
prefix
+
"search_rad"
,
this
.
search_rad
+
""
);
// int
properties
.
setProperty
(
prefix
+
"maybe_sum"
,
this
.
maybe_sum
+
""
);
// double
properties
.
setProperty
(
prefix
+
"shure_sum"
,
this
.
shure_sum
+
""
);
// double
properties
.
setProperty
(
prefix
+
"maybe_avg"
,
this
.
maybe_avg
+
""
);
// double
properties
.
setProperty
(
prefix
+
"shure_avg"
,
this
.
shure_avg
+
""
);
// double
properties
.
setProperty
(
prefix
+
"adjust_atr_0"
,
this
.
adjust_atr
[
0
]+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"adjust_atr_1"
,
this
.
adjust_atr
[
1
]+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"adjust_atr_2"
,
this
.
adjust_atr
[
2
]+
""
);
// boolean
...
...
@@ -199,6 +261,16 @@ public class IntersceneMatchParameters {
if
(
properties
.
getProperty
(
prefix
+
"margin"
)!=
null
)
this
.
margin
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"margin"
));
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_neibs"
)!=
null
)
this
.
min_neibs
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"min_neibs"
));
if
(
properties
.
getProperty
(
prefix
+
"weight_zero_neibs"
)!=
null
)
this
.
weight_zero_neibs
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"weight_zero_neibs"
));
if
(
properties
.
getProperty
(
prefix
+
"half_disparity"
)!=
null
)
this
.
half_disparity
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"half_disparity"
));
if
(
properties
.
getProperty
(
prefix
+
"half_avg_diff"
)!=
null
)
this
.
half_avg_diff
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"half_avg_diff"
));
if
(
properties
.
getProperty
(
prefix
+
"pix_step"
)!=
null
)
this
.
pix_step
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"pix_step"
));
if
(
properties
.
getProperty
(
prefix
+
"search_rad"
)!=
null
)
this
.
search_rad
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"search_rad"
));
if
(
properties
.
getProperty
(
prefix
+
"maybe_sum"
)!=
null
)
this
.
maybe_sum
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"maybe_sum"
));
if
(
properties
.
getProperty
(
prefix
+
"shure_sum"
)!=
null
)
this
.
shure_sum
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"shure_sum"
));
if
(
properties
.
getProperty
(
prefix
+
"maybe_avg"
)!=
null
)
this
.
maybe_avg
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"maybe_avg"
));
if
(
properties
.
getProperty
(
prefix
+
"shure_avg"
)!=
null
)
this
.
shure_avg
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"shure_avg"
));
if
(
properties
.
getProperty
(
prefix
+
"adjust_atr_0"
)!=
null
)
this
.
adjust_atr
[
0
]=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"adjust_atr_0"
));
if
(
properties
.
getProperty
(
prefix
+
"adjust_atr_1"
)!=
null
)
this
.
adjust_atr
[
1
]=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"adjust_atr_1"
));
if
(
properties
.
getProperty
(
prefix
+
"adjust_atr_2"
)!=
null
)
this
.
adjust_atr
[
2
]=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"adjust_atr_2"
));
...
...
@@ -230,6 +302,16 @@ public class IntersceneMatchParameters {
imp
.
n_recenter
=
this
.
n_recenter
;
imp
.
min_str
=
this
.
min_str
;
imp
.
min_str_sum
=
this
.
min_str_sum
;
imp
.
min_neibs
=
this
.
min_neibs
;
imp
.
weight_zero_neibs
=
this
.
weight_zero_neibs
;
imp
.
half_disparity
=
this
.
half_disparity
;
imp
.
half_avg_diff
=
this
.
half_avg_diff
;
imp
.
pix_step
=
this
.
pix_step
;
imp
.
search_rad
=
this
.
search_rad
;
imp
.
maybe_sum
=
this
.
maybe_sum
;
imp
.
shure_sum
=
this
.
shure_sum
;
imp
.
maybe_avg
=
this
.
maybe_avg
;
imp
.
shure_avg
=
this
.
shure_avg
;
imp
.
adjust_atr
[
0
]
=
this
.
adjust_atr
[
0
];
imp
.
adjust_atr
[
1
]
=
this
.
adjust_atr
[
1
];
imp
.
adjust_atr
[
2
]
=
this
.
adjust_atr
[
2
];
...
...
@@ -250,5 +332,4 @@ public class IntersceneMatchParameters {
imp
.
debug_level
=
this
.
debug_level
;
return
imp
;
}
}
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
23452c5b
...
...
@@ -37,6 +37,7 @@ import java.util.Arrays;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.DoubleAccumulator
;
...
...
@@ -48,8 +49,10 @@ import java.util.concurrent.ThreadLocalRandom;
import
com.elphel.imagej.cameras.CLTParameters
;
import
com.elphel.imagej.cameras.ColorProcParameters
;
import
com.elphel.imagej.cameras.EyesisCorrectionParameters
;
import
com.elphel.imagej.common.DoubleGaussianBlur
;
import
com.elphel.imagej.common.ShowDoubleFloatArrays
;
import
com.elphel.imagej.correction.CorrectionColorProc
;
import
com.elphel.imagej.gpu.GpuQuad
;
import
com.elphel.imagej.gpu.TpTask
;
import
com.elphel.imagej.jp4.JP46_Reader_camera
;
...
...
@@ -85,6 +88,7 @@ public class OpticalFlow {
public
int
numSens
;
// not configured yet
public
double
scale_no_lma_disparity
=
1.0
;
// multiply strength were disparity_lma = NaN;
public
long
startTime
;
// start of batch processing
public
OpticalFlow
(
int
numSens
,
...
...
@@ -2310,7 +2314,7 @@ public class OpticalFlow {
scene_ers_dt
[
indx
][
0
],
// double [] ers_xyz_dt,
scene_ers_dt
[
indx
][
1
]);
// double [] ers_atr_dt)(ers_scene_original_xyz_dt);
ers_scene
.
setupERS
();
dsrbg
[
i
]
=
transformCameraVew
(
// shifts previous image correctly (right)
dsrbg
[
i
]
=
transformCameraVew
(
// shifts previous image correctly (right)
null pointer
title
,
// final String title,
scene_xyzatr
[
indx
][
0
],
// double [] camera_xyz, // camera center in world coordinates
scene_xyzatr
[
indx
][
1
],
//double [] camera_atr, // camera orientation relative to world frame
...
...
@@ -2336,9 +2340,11 @@ public class OpticalFlow {
for
(
int
nslice
=
0
;
nslice
<
nslices
;
nslice
++)
{
for
(
int
nscene
=
0
;
nscene
<
nscenes
;
nscene
++)
{
rtitles
[
nscenes
*
nslice
+
nscene
]
=
dsrbg_titles
[
nslice
]+
"-"
+
time_stamps
[
nscene
];
if
(
dsrbg
[
nscene
]
!=
null
)
{
dbg_rslt
[
nscenes
*
nslice
+
nscene
]
=
dsrbg
[
nscene
][
nslice
];
}
}
}
(
new
ShowDoubleFloatArrays
()).
showArrays
(
dbg_rslt
,
tilesX
,
...
...
@@ -3104,7 +3110,10 @@ public class OpticalFlow {
final
double
sigma
=
0.5
*
iscale
;
final
double
scale
=
1.0
*
iscale
/
transform_size
;
final
double
[][]
dsrbg_camera
=
scene_QuadClt
.
getDSRBG
();
final
double
[][]
ds
=
new
double
[
dsrbg_camera
.
length
][
stiles
];
if
(
dsrbg_camera
==
null
)
{
return
null
;
}
final
double
[][]
ds
=
new
double
[
dsrbg_camera
.
length
][
stiles
];
// null pointer
for
(
int
i
=
0
;
i
<
ds
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
ds
[
i
].
length
;
j
++)
{
ds
[
i
][
j
]
=
Double
.
NaN
;
...
...
@@ -3410,6 +3419,8 @@ public class OpticalFlow {
)
{
double
scale_two_omegas
=
2.00
;
// ers angular velocities contain double omegas
// Maintain pose differences and velocities, they are saved after pass2
double
[][][]
scenes_xyzatr
=
new
double
[
scenes
.
length
][][];
// previous scene relative to the next one
double
[][][]
ers_xyzatr
=
new
double
[
scenes
.
length
][][];
// previous scene relative to the next one
...
...
@@ -3422,6 +3433,8 @@ public class OpticalFlow {
double
max_rms_sure
=
clt_parameters
.
ofp
.
max_rms_sure
;
// 2.1;
int
pix_step
=
clt_parameters
.
ofp
.
pix_step
;
// 20;
int
search_rad
=
clt_parameters
.
ofp
.
search_rad
;
// 2; // 0;
boolean
next_predict
=
true
;
// Do not use macrotiles for 3-rd and next scenes - assume linear motion
boolean
use_second_pass
=
false
;
// Probably not needed - instead just set velocities from neighbors
// pass I - adjust pairs using angular and linear velocities from intrascene ERS.
for
(
int
i
=
1
;
i
<
scenes
.
length
;
i
++)
{
...
...
@@ -3435,19 +3448,18 @@ public class OpticalFlow {
scene_QuadClt
,
debug_level
);
}
reference_QuadClt
.
getErsCorrection
().
setupERSfromExtrinsics
();
scene_QuadClt
.
getErsCorrection
().
setupERSfromExtrinsics
();
double
[]
rms2
=
new
double
[
2
];
if
((
i
<=
1
)
||
!
next_predict
)
{
// for scanning around
double
angle_per_step
=
reference_QuadClt
.
getGeometryCorrection
().
getCorrVector
().
getTiltAzPerPixel
()
*
pix_step
;
double
[]
rmses
=
new
double
[(
2
*
search_rad
+
1
)*(
2
*
search_rad
+
1
)];
Arrays
.
fill
(
rmses
,
max_rms_maybe
+
1.0
);
// undefined - set larges
r than worst
Arrays
.
fill
(
rmses
,
max_rms_maybe
+
1.0
);
// undefined - set large
r than worst
double
[][]
atrs
=
new
double
[
rmses
.
length
][];
int
rad
=
0
,
dir
=
0
,
n
=
0
;
int
ntry
=
0
;
int
num_good
=
0
;
double
[]
rms2
=
new
double
[
2
];
try_around:
for
(
rad
=
0
;
rad
<=
search_rad
;
rad
++)
{
for
(
dir
=
0
;
dir
<
((
rad
==
0
)?
1
:
4
);
dir
++)
{
...
...
@@ -3517,93 +3529,47 @@ public class OpticalFlow {
null
,
// double [][] dbg_img,
max_rms_maybe
,
// double max_rms,
clt_parameters
.
ofp
.
debug_level_optical
);
// 1); // -1); // int debug_level);
}
if
(
debug_level
>
-
1
)
{
System
.
out
.
println
(
"Pass 1
scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
System
.
out
.
println
(
"Pass 1 MACRO
scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+(
" Done.\n"
));
}
if
(
num_good
==
0
)
{
System
.
out
.
println
(
"****** Error ! Could not find any good match in a pair of consecutive scenes ! *****"
);
}
int
margin
=
clt_parameters
.
imp
.
margin
;
int
sensor_mask_inter
=
clt_parameters
.
imp
.
sensor_mask_inter
;
//-1;
float
[][][]
facc_2d_img
=
new
float
[
1
][][];
IntersceneLma
intersceneLma
=
new
IntersceneLma
(
this
,
// OpticalFlow opticalFlow
clt_parameters
.
ilp
.
ilma_thread_invariant
);
// int nlma = 0;
int
lmaResult
=
-
1
;
boolean
last_run
=
false
;
double
[]
camera_xyz0
=
scenes_xyzatr
[
i
][
0
];
double
[]
camera_atr0
=
scenes_xyzatr
[
i
][
1
];
double
[][][]
coord_motion
=
null
;
for
(
int
nlma
=
0
;
nlma
<
clt_parameters
.
imp
.
max_cycles
;
nlma
++)
{
coord_motion
=
interCorrPair
(
// new double [tilesY][tilesX][][];
}
}
else
{
double
dt_prev
=
scenes
[
i
-
1
].
getTimeStamp
()
-
scenes
[
i
-
2
].
getTimeStamp
();
double
dt_this
=
scenes
[
i
-
0
].
getTimeStamp
()
-
scenes
[
i
-
1
].
getTimeStamp
();
double
tscale
=
dt_this
/
dt_prev
;
scenes_xyzatr
[
i
]
=
new
double
[
2
][
3
];
for
(
int
t
=
0
;
t
<
scenes_xyzatr
[
i
].
length
;
t
++)
{
for
(
int
j
=
0
;
j
<
scenes_xyzatr
[
i
][
t
].
length
;
j
++)
{
scenes_xyzatr
[
i
][
t
][
j
]
=
tscale
*
scenes_xyzatr
[
i
-
1
][
t
][
j
];
}
}
}
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
camera_xyz0
,
// xyz
camera_atr0
,
// pose[1], // atr
null
,
// final boolean [] selection, // may be null, if not null do not process unselected tiles
margin
,
// final int margin,
sensor_mask_inter
,
// final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
facc_2d_img
,
// final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
intersceneLma
.
prepareLMA
(
camera_xyz0
,
// final double [] scene_xyz0, // camera center in world coordinates (or null to use instance)
camera_atr0
,
// final double [] scene_atr0, // camera orientation relative to world frame (or null to use instance)
// reference atr, xyz are considered 0.0
scene_QuadClt
,
// final QuadCLT scene_QuadClt,
reference_QuadClt
,
// final QuadCLT reference_QuadClt,
scenes_xyzatr
[
i
][
0
],
// xyz
scenes_xyzatr
[
i
][
1
],
// atr
clt_parameters
.
ilp
.
ilma_lma_select
,
// final boolean[] param_select,
clt_parameters
.
ilp
.
ilma_regularization_weights
,
// final double [] param_regweights,
coord_motion
[
1
],
// final double [][] vector_XYS, // optical flow X,Y, confidence obtained from the correlate2DIterate()
coord_motion
[
0
],
// final double [][] centers, // macrotile centers (in pixels and average disparities
(
nlma
==
0
),
// boolean first_run,
clt_parameters
.
imp
.
debug_level
);
// final int debug_level)
lmaResult
=
intersceneLma
.
runLma
(
clt_parameters
.
ilp
.
ilma_lambda
,
// double lambda, // 0.1
clt_parameters
.
ilp
.
ilma_lambda_scale_good
,
// double lambda_scale_good,// 0.5
clt_parameters
.
ilp
.
ilma_lambda_scale_bad
,
// double lambda_scale_bad, // 8.0
clt_parameters
.
ilp
.
ilma_lambda_max
,
// double lambda_max, // 100
clt_parameters
.
ilp
.
ilma_rms_diff
,
// double rms_diff, // 0.001
clt_parameters
.
imp
.
max_LMA
,
// int num_iter, // 20
last_run
,
// boolean last_run,
clt_parameters
.
imp
.
debug_level
);
// int debug_level)
camera_xyz0
=
intersceneLma
.
getSceneXYZ
(
false
);
// true for initial values
camera_atr0
=
intersceneLma
.
getSceneATR
(
false
);
// true for initial values
/*
if (clt_parameters.imp.debug_level > -1) {
System.out.println("adjustPairsLMA(): "+IntersceneLma.printNameV3("ATR",camera_atr0)+
" "+IntersceneLma.printNameV3("XYZ",camera_xyz0));
}
*/
double
[]
diffs_atr
=
intersceneLma
.
getV3Diff
(
ErsCorrection
.
DP_DSAZ
);
double
[]
diffs_xyz
=
intersceneLma
.
getV3Diff
(
ErsCorrection
.
DP_DSX
);
boolean
last
=
(
nlma
==
(
clt_parameters
.
imp
.
max_cycles
-
1
))
||
((
diffs_atr
[
0
]
<
clt_parameters
.
imp
.
exit_change_atr
)
&&
(
diffs_xyz
[
0
]
<
clt_parameters
.
imp
.
exit_change_xyz
));
if
(
last
)
{
if
(
clt_parameters
.
imp
.
debug_level
>
-
2
)
{
String
[]
lines1
=
intersceneLma
.
printOldNew
(
false
);
// boolean allvectors)
System
.
out
.
println
(
"Adjusted interscene, iteration="
+
nlma
+
", last RMS = "
+
intersceneLma
.
getLastRms
()[
0
]+
" (pure RMS = "
+
intersceneLma
.
getLastRms
()[
1
]+
")"
+
", results:"
);
for
(
String
line
:
lines1
)
{
System
.
out
.
println
(
line
);
}
if
(
intersceneLma
.
getLastRms
()[
0
]
>
clt_parameters
.
imp
.
max_rms
)
{
throw
new
IllegalArgumentException
(
"Interscene adjustment failed, RMS="
+
intersceneLma
.
getLastRms
()[
0
]+
" > "
+
clt_parameters
.
imp
.
max_rms
);
}
}
break
;
}
// System.out.println();
rms2
,
// double [] rms, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
if
(
debug_level
>
-
1
)
{
System
.
out
.
println
(
"Pass 1 scene "
+
i
+
" (of "
+
scenes
.
length
+
") "
+
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+(
" Done.\n"
));
}
}
// TODO: add optional interCorrPair to display results
}
// for (int i = 1; i < scenes.length; i++) {
// TODO: Add setting velocities w/o second pass
// updating ERS from delta pose
for
(
int
i
=
0
;
i
<
scenes
.
length
;
i
++)
{
int
i_prev
=
i
-
((
i
>
0
)
?
1
:
0
);
int
i_next
=
i
+
((
i
<
(
scenes
.
length
-
1
))
?
1
:
0
);
...
...
@@ -3676,7 +3642,20 @@ public class OpticalFlow {
}
}
//{camera_xyz0, camera_atr0}
if
(!
use_second_pass
)
{
for
(
int
i
=
1
;
i
<
scenes
.
length
;
i
++)
{
QuadCLT
reference_QuadClt
=
scenes
[
i
];
QuadCLT
scene_QuadClt
=
scenes
[
i
-
1
];
ErsCorrection
ers_reference
=
reference_QuadClt
.
getErsCorrection
();
// ErsCorrection ers_scene = scene_QuadClt.getErsCorrection();
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
scenes_xyzatr
[
i
][
0
],
scenes_xyzatr
[
i
][
1
],
ers_xyzatr
[
i
][
0
],
ers_xyzatr
[
i
][
1
]
);
}
}
else
{
// pass II - set scene velocities from offsets to 1 before and one after, freeze ERS parameters, and
// adjust other ones.
boolean
[]
param_select2
=
clt_parameters
.
ilp
.
ilma_lma_select
.
clone
();
// final boolean[] param_select,
...
...
@@ -3685,8 +3664,8 @@ public class OpticalFlow {
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
param_select2
[
ErsCorrection
.
DP_DVX
+
j
]
=
false
;
param_select2
[
ErsCorrection
.
DP_DVAZ
+
j
]
=
false
;
// param_select2[ErsCorrection.DP_DSVX + j] = false; // disabling, may check with high rot speed
// param_select2[ErsCorrection.DP_DSVAZ + j] = true; // so far ers correction noise is too high to compare
// param_select2[ErsCorrection.DP_DSVX + j] = false; // disabling, may check with high rot speed
// param_select2[ErsCorrection.DP_DSVAZ + j] = true; // so far ers correction noise is too high to compare
param_regweights2
[
ErsCorrection
.
DP_DSVX
+
j
]
=
0.0
;
param_regweights2
[
ErsCorrection
.
DP_DSVAZ
+
j
]
=
0.0
;
}
...
...
@@ -3754,7 +3733,7 @@ public class OpticalFlow {
//TODO: Add update ers with lpf here?
// boolean show_results = true;
// boolean show_results = true;
if
(
show_results
)
{
int
dbg_w
=
scenes_xyzatr1
.
length
;
int
dbg_h
=
6
;
...
...
@@ -3773,7 +3752,7 @@ public class OpticalFlow {
dbg_h
,
"scenes_xyzatr1"
);
// dsrbg_titles);
}
}
...
...
@@ -3787,6 +3766,343 @@ public class OpticalFlow {
}
}
/**
* Build series of poses from just a single (reference) scene.
* @param quadCLT_main
* @param ref_index
* @param ref_step
* @param clt_parameters
* @param debayerParameters
* @param colorProcParameters
* @param channelGainParameters
* @param rgbParameters
* @param equirectangularParameters
* @param properties
* @param reset_from_extrinsics
* @param threadsMax
* @param updateStatus
* @param debugLevel
* @return true if OK, false on failure
* @throws Exception
*/
public
boolean
buildSeries
(
QuadCLT
quadCLT_main
,
// tiles should be set
int
ref_index
,
// -1 - last
int
ref_step
,
CLTParameters
clt_parameters
,
EyesisCorrectionParameters
.
DebayerParameters
debayerParameters
,
ColorProcParameters
colorProcParameters
,
CorrectionColorProc
.
ColorGainsParameters
channelGainParameters
,
EyesisCorrectionParameters
.
RGBParameters
rgbParameters
,
EyesisCorrectionParameters
.
EquirectangularParameters
equirectangularParameters
,
Properties
properties
,
boolean
reset_from_extrinsics
,
final
int
threadsMax
,
// maximal number of threads to launch
final
boolean
updateStatus
,
final
int
debugLevel
)
throws
Exception
{
boolean
build_ref_dsi
=
false
;
// true;
boolean
build_orientations
=
false
;
boolean
build_interscene
=
true
;
final
int
debugLevelInner
=
clt_parameters
.
batch_run
?
-
2
:
debugLevel
;
// copied from TQ
if
((
quadCLT_main
!=
null
)
&&
(
quadCLT_main
.
getGPU
()
!=
null
))
{
quadCLT_main
.
getGPU
().
resetGeometryCorrection
();
quadCLT_main
.
gpuResetCorrVector
();
// .getGPU().resetGeometryCorrectionVector();
}
// final boolean batch_mode = clt_parameters.batch_run;
this
.
startTime
=
System
.
nanoTime
();
String
[]
sourceFiles0
=
quadCLT_main
.
correctionsParameters
.
getSourcePaths
();
QuadCLT
.
SetChannels
[]
set_channels_main
=
quadCLT_main
.
setChannels
(
debugLevel
);
if
((
set_channels_main
==
null
)
||
(
set_channels_main
.
length
==
0
))
{
System
.
out
.
println
(
"buildSeriesTQ(): No files to process (of "
+
sourceFiles0
.
length
+
")"
);
return
false
;
}
QuadCLT
.
SetChannels
[]
set_channels
=
quadCLT_main
.
setChannels
(
debugLevel
);
QuadCLT
[]
quadCLTs
=
new
QuadCLT
[
set_channels
.
length
];
if
(
ref_index
<
0
)
{
ref_index
+=
quadCLTs
.
length
;
}
double
[][][]
scenes_xyzatr
=
new
double
[
quadCLTs
.
length
][][];
// previous scene relative to the next one
scenes_xyzatr
[
ref_index
]
=
new
double
[
2
][
3
];
// all zeros
if
(
build_ref_dsi
)
{
TwoQuadCLT
.
copyJP4src
(
// actually there is no sense to process multiple image sets. Combine with other
// processing?
set_channels
[
ref_index
].
set_name
,
// String set_name
quadCLT_main
,
// QuadCLT quadCLT_main,
null
,
// QuadCLT quadCLT_aux,
clt_parameters
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
true
,
// boolean skip_existing,
false
,
// boolean search_KML,
debugLevel
);
quadCLTs
[
ref_index
]
=
(
QuadCLT
)
quadCLT_main
.
spawnNoModelQuadCLT
(
// will conditionImageSet
set_channels
[
ref_index
].
set_name
,
clt_parameters
,
colorProcParameters
,
//
threadsMax
,
debugLevel
-
2
);
quadCLTs
[
ref_index
].
saveQuadClt
();
// to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
quadCLTs
[
ref_index
].
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
clt_parameters
,
debayerParameters
,
colorProcParameters
,
rgbParameters
,
threadsMax
,
// maximal number of threads to launch
updateStatus
,
debugLevelInner
);
double
[][]
aux_last_scan
=
TileProcessor
.
getDSLMA
(
quadCLTs
[
ref_index
].
tp
.
clt_3d_passes
.
get
(
quadCLTs
[
ref_index
].
tp
.
clt_3d_passes
.
size
()
-
1
),
false
);
// boolean force_final);
double
[][]
dsi
=
new
double
[
TwoQuadCLT
.
DSI_SLICES
.
length
][];
dsi
[
TwoQuadCLT
.
DSI_DISPARITY_AUX
]
=
aux_last_scan
[
0
];
dsi
[
TwoQuadCLT
.
DSI_STRENGTH_AUX
]
=
aux_last_scan
[
1
];
dsi
[
TwoQuadCLT
.
DSI_DISPARITY_AUX_LMA
]
=
aux_last_scan
[
2
];
if
(
quadCLT_main
.
correctionsParameters
.
clt_batch_dsi_cm_strength
)
{
CLTPass3d
scan
=
new
CLTPass3d
(
quadCLTs
[
ref_index
].
tp
);
scan
.
setTileOpDisparity
(
aux_last_scan
[
0
]);
// measure w/o LMA, use just strength
quadCLTs
[
ref_index
].
CLTMeas
(
// perform single pass according to prepared tiles operations and disparity
clt_parameters
,
// EyesisCorrectionParameters.CLTParameters clt_parameters,
scan
,
// final CLTPass3d scan,
false
,
// final boolean save_textures,
false
,
// final boolean need_diffs, // calculate diffs even if textures are not needed
0
,
// final int clust_radius,
true
,
// final boolean save_corr,
false
,
// final boolean run_lma, // = true;
threadsMax
,
// final int threadsMax, // maximal number of threads to launch
updateStatus
,
// final boolean updateStatus,
debugLevel
);
// final int debugLevel);
dsi
[
TwoQuadCLT
.
DSI_STRENGTH_AUX
]
=
scan
.
getStrength
();
if
(
debugLevel
>
1
)
{
quadCLTs
[
ref_index
].
tp
.
showScan
(
scan
,
// CLTPass3d scan,
"test-strength"
);
}
}
else
{
dsi
[
TwoQuadCLT
.
DSI_STRENGTH_AUX
]
=
aux_last_scan
[
1
];
}
quadCLTs
[
ref_index
].
saveDSIAll
(
"-DSI_MAIN"
,
// String suffix, // "-DSI_MAIN"
dsi
);
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, // Properties properties, // if null - will only save extrinsics)
debugLevel
);
// Copy source files to the model directory - they are needed for poses and interscene
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
TwoQuadCLT
.
copyJP4src
(
// actually there is no sense to process multiple image sets. Combine with other
// processing?
set_channels
[
scene_index
].
set_name
,
// String set_name
quadCLT_main
,
// QuadCLT quadCLT_main,
null
,
// QuadCLT quadCLT_aux,
clt_parameters
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
true
,
// boolean skip_existing,
false
,
// boolean search_KML,
debugLevel
);
}
// split cycles to remove output clutter
}
// if (build_ref_dsi) {
quadCLTs
[
ref_index
]
=
(
QuadCLT
)
quadCLT_main
.
spawnQuadCLT
(
set_channels
[
ref_index
].
set_name
,
clt_parameters
,
colorProcParameters
,
//
threadsMax
,
debugLevel
);
quadCLTs
[
ref_index
].
setDSRBG
(
clt_parameters
,
// CLTParameters clt_parameters,
threadsMax
,
// int threadsMax, // maximal number of threads to launch
updateStatus
,
// boolean updateStatus,
debugLevel
);
// int debugLevel)
QuadCLT
reference_QuadClt
=
quadCLTs
[
ref_index
];
ErsCorrection
ers_reference
=
reference_QuadClt
.
getErsCorrection
();
if
(
build_orientations
)
{
double
[]
lma_rms
=
new
double
[
2
];
double
[]
use_atr
=
null
;
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
quadCLTs
[
scene_index
]
=
(
QuadCLT
)
quadCLT_main
.
spawnNoModelQuadCLT
(
set_channels
[
scene_index
].
set_name
,
clt_parameters
,
colorProcParameters
,
//
threadsMax
,
debugLevel
-
2
);
}
// split cycles to remove output clutter
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
QuadCLT
scene_QuadClt
=
quadCLTs
[
scene_index
];
// get initial xyzatr:
if
(
scene_index
==
ref_index
-
1
)
{
// search around for the best fit
use_atr
=
spiralSearchATR
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadClt,
scene_QuadClt
,
// QuadCLT scene_QuadClt,
debugLevel
);
if
(
use_atr
==
null
)
{
return
false
;
}
scenes_xyzatr
[
scene_index
]
=
new
double
[][]
{
new
double
[
3
],
use_atr
};
}
else
{
// assume linear motion
double
[][]
last_diff
=
ErsCorrection
.
combineXYZATR
(
scenes_xyzatr
[
scene_index
+
1
],
ErsCorrection
.
invertXYZATR
(
scenes_xyzatr
[
scene_index
+
2
]));
scenes_xyzatr
[
scene_index
]
=
ErsCorrection
.
combineXYZATR
(
scenes_xyzatr
[
scene_index
+
1
],
last_diff
);
}
// Refine with LMA
scenes_xyzatr
[
scene_index
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
scenes_xyzatr
[
scene_index
][
0
],
// xyz
scenes_xyzatr
[
scene_index
][
1
],
// atr
clt_parameters
.
ilp
.
ilma_lma_select
,
// final boolean[] param_select,
clt_parameters
.
ilp
.
ilma_regularization_weights
,
// final double [] param_regweights,
lma_rms
,
// double [] rms, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
// TODO: Maybe after testing high-ers scenes - restore velocities from before/after scenes
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
scenes_xyzatr
[
scene_index
][
0
],
scenes_xyzatr
[
scene_index
][
1
],
ZERO3
,
// ers_scene.getErsXYZ_dt(),
ZERO3
// ers_scene.getErsATR_dt()
);
if
(
debugLevel
>
-
3
)
{
System
.
out
.
println
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
reference_QuadClt
.
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done."
);
}
/*
if (delete_scene_asap) {
scenes[i+1] = null;
}
*/
}
reference_QuadClt
.
saveInterProperties
(
// save properties for interscene processing (extrinsics, ers, ...)
null
,
// String path, // full name with extension or w/o path to use x3d directory
debugLevel
+
1
);
}
// if (build_orientations) {
if
(
build_interscene
)
{
if
(!
build_orientations
)
{
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
0
;
scene_index
--)
{
quadCLTs
[
scene_index
]
=
(
QuadCLT
)
quadCLT_main
.
spawnNoModelQuadCLT
(
// restores image data
set_channels
[
scene_index
].
set_name
,
clt_parameters
,
colorProcParameters
,
//
threadsMax
,
debugLevel
-
2
);
}
}
intersceneExport
(
clt_parameters
,
// CLTParameters clt_parameters,
ers_reference
,
// ErsCorrection ers_reference,
quadCLTs
,
// QuadCLT [] scenes,
colorProcParameters
,
// ColorProcParameters colorProcParameters,
debugLevel
);
// int debug_level
}
System
.
out
.
println
(
"buildSeries(): DONE"
);
//
return
true
;
}
public
double
[]
spiralSearchATR
(
CLTParameters
clt_parameters
,
QuadCLT
reference_QuadClt
,
QuadCLT
scene_QuadClt
,
int
debugLevel
)
{
int
[][]
offset_start_corner
=
{{-
1
,-
1
},{
1
,-
1
},{
1
,
1
},{-
1
,
1
}};
//{x,y}
int
[][]
offset_move
=
{{
1
,
0
},{
0
,
1
},{-
1
,
0
},{
0
,-
1
}};
int
margin
=
clt_parameters
.
imp
.
margin
;
int
sensor_mask_inter
=
clt_parameters
.
imp
.
sensor_mask_inter
;
//-1;
float
[][][]
facc_2d_img
=
new
float
[
1
][][];
int
pix_step
=
clt_parameters
.
imp
.
pix_step
;
// 4;
int
search_rad
=
clt_parameters
.
imp
.
search_rad
;
// 10;
double
maybe_sum
=
clt_parameters
.
imp
.
maybe_sum
;
// 8.0;
double
shure_sum
=
clt_parameters
.
imp
.
shure_sum
;
// 30.0;
double
maybe_avg
=
clt_parameters
.
imp
.
maybe_avg
;
// 0.005;
double
shure_avg
=
clt_parameters
.
imp
.
shure_avg
;
// 0.015;
double
[][]
pose
=
new
double
[
2
][
3
];
double
angle_per_step
=
reference_QuadClt
.
getGeometryCorrection
().
getCorrVector
().
getTiltAzPerPixel
()
*
pix_step
;
double
[][]
atrs
=
new
double
[(
2
*
search_rad
+
1
)*(
2
*
search_rad
+
1
)][];
double
[]
confidences_sum
=
new
double
[
atrs
.
length
];
double
[]
confidences_avg
=
new
double
[
atrs
.
length
];
int
rad
=
0
,
dir
=
0
,
n
=
0
;
int
ntry
=
0
;
int
num_good
=
0
;
double
[]
use_atr
=
null
;
try_around:
for
(
rad
=
0
;
rad
<=
search_rad
;
rad
++)
{
for
(
dir
=
0
;
dir
<
((
rad
==
0
)?
1
:
4
);
dir
++)
{
int
n_range
=
(
rad
>
0
)
?
(
2
*
rad
)
:
1
;
for
(
n
=
0
;
n
<
n_range
;
n
++)
{
int
ix
=
rad
*
offset_start_corner
[
dir
][
0
]
+
n
*
offset_move
[
dir
][
0
];
int
iy
=
rad
*
offset_start_corner
[
dir
][
1
]
+
n
*
offset_move
[
dir
][
1
];;
double
[]
atr
=
{
pose
[
1
][
0
]+
ix
*
angle_per_step
,
pose
[
1
][
1
]+
iy
*
angle_per_step
,
pose
[
1
][
2
]};
if
(
debugLevel
>
-
2
)
{
System
.
out
.
println
(
"buildSeries(): trying adjustPairsLMA() with initial offset azimuth: "
+
atr
[
0
]+
", tilt ="
+
atr
[
1
]);
}
double
[][][]
coord_motion
=
interCorrPair
(
// new double [tilesY][tilesX][][];
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
pose
[
0
],
// camera_xyz0, // xyz
atr
,
// camera_atr0, // pose[1], // atr
null
,
// final boolean [] selection, // may be null, if not null do not process unselected tiles
margin
,
// final int margin,
sensor_mask_inter
,
// final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
facc_2d_img
,
// final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
int
num_defined
=
0
;
double
sum_strength
=
0.0
;
for
(
int
i
=
0
;
i
<
coord_motion
[
1
].
length
;
i
++)
if
(
coord_motion
[
1
][
i
]
!=
null
){
sum_strength
+=
coord_motion
[
1
][
i
][
2
];
num_defined
++;
}
double
avg_strength
=
(
num_defined
>
0
)?(
sum_strength
/
num_defined
)
:
0
;
atrs
[
ntry
]
=
atr
;
confidences_sum
[
ntry
]
=
sum_strength
;
confidences_avg
[
ntry
]
=
avg_strength
;
if
(
debugLevel
>
-
2
)
{
System
.
out
.
println
(
"ntry = "
+
ntry
+
", num_defined = "
+
num_defined
+
", sum_strength = "
+
sum_strength
+
", avg_strength = "
+
avg_strength
);
}
if
((
sum_strength
>
maybe_sum
)
||
(
avg_strength
>
maybe_avg
))
{
if
((
sum_strength
>
shure_sum
)
||
(
avg_strength
>
shure_avg
))
{
use_atr
=
atr
;
break
try_around
;
}
num_good
++;
}
ntry
++;
}
}
}
if
((
use_atr
==
null
)
&&
(
num_good
==
0
))
{
System
.
out
.
println
(
"Failed to find a match between the reference scene ("
+
reference_QuadClt
.
getImageName
()
+
") and a previous one ("
+
scene_QuadClt
.
getImageName
()+
")"
);
return
null
;
}
if
(
use_atr
==
null
)
{
int
best_ntry
=
0
;
for
(
int
i
=
1
;
i
<
atrs
.
length
;
i
++)
{
if
(
confidences_sum
[
i
]
>
confidences_sum
[
best_ntry
])
{
best_ntry
=
i
;
}
}
use_atr
=
atrs
[
best_ntry
];
}
return
use_atr
;
}
public
void
adjustSeries
(
CLTParameters
clt_parameters
,
double
k_prev
,
...
...
@@ -3797,6 +4113,7 @@ public class OpticalFlow {
{
boolean
show_results
=
clt_parameters
.
ilp
.
ilma_debug_adjust_series
;
boolean
pattern_mode
=
clt_parameters
.
ofp
.
pattern_mode
;
boolean
high_res_motion_vectors
=
true
;
// use new 05/20/2022 mode
if
(
pattern_mode
)
{
if
(
clt_parameters
.
ofp
.
center_index
<
0
)
{
double
[][][]
atrs
=
new
double
[
scenes
.
length
][][];
...
...
@@ -3923,9 +4240,13 @@ public class OpticalFlow {
dbg_iterdata
[
ii
]
=
new
double
[
macroTilesY
*
scenes
.
length
*
macroTilesX
*
clt_parameters
.
ilp
.
ilma_num_corr
];
}
}
if
(
debug_level
>
-
1000
)
{
dbg_iterdata
=
null
;
// does not work now (at 3964)
}
double
[]
dbg_rms_pre
=
new
double
[
scenes
.
length
];
Arrays
.
fill
(
dbg_rms_pre
,
Double
.
NaN
);
// process scenes before reference
int
dbg_ref_index
=
10
;
// wait for ref_index <= dbg_ref_index and print (manually update dbg_ref_index
if
(
ref_index
>
1
)
{
for
(
int
i
=
ref_index
-
2
;
i
>=
0
;
i
--)
{
QuadCLT
scene_QuadClt
=
scenes
[
i
];
...
...
@@ -3941,7 +4262,7 @@ public class OpticalFlow {
double
[]
new_from_last_atr
=
ers_scene_last_known
.
getSceneATR
(
scene_ts
);
// combine two rotations and two translations
System
.
out
.
println
(
"
Processing scene "
+
i
+
": "
+
scene_QuadClt
.
getImageName
()
);
System
.
out
.
println
(
"
***** Processing scene "
+
i
+
": "
+
scene_QuadClt
.
getImageName
()+
" *****"
);
double
[][]
combo_XYZATR
=
ErsCorrection
.
combineXYZATR
(
last_known_xyz
,
// double [] reference_xyz,
last_known_atr
,
// double [] reference_atr, // null?
...
...
@@ -3955,6 +4276,22 @@ public class OpticalFlow {
// ers should be correct for both
double
[]
lma_rms
=
new
double
[
2
];
double
[][]
dbg_img
=
(
dbg_iterdata
!=
null
)
?
(
new
double
[
3
][])
:
null
;
if
(
i
<=
dbg_ref_index
)
{
System
.
out
.
println
(
"i = "
+
i
+
" <= dbg_ref_index"
);
}
if
(
high_res_motion_vectors
)
{
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
combo_XYZATR
[
0
],
// xyz
combo_XYZATR
[
1
],
// atr
param_select2
,
// final boolean[] param_select,
param_regweights2
,
// final double [] param_regweights,
lma_rms
,
// double [] rms, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
}
else
{
scenes_xyzatr
[
i
]
=
adjustPairsLMA
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
...
...
@@ -3967,11 +4304,12 @@ public class OpticalFlow {
dbg_img
,
// double [][] dbg_img,
0.0
,
// double max_rms,
debug_level
);
// int debug_level)
}
if
(
dbg_iterdata
!=
null
)
{
int
dbg_width
=
clt_parameters
.
ilp
.
ilma_num_corr
*
macroTilesX
;
for
(
int
kk
=
0
;
kk
<
dbg_iterdata
.
length
;
kk
++)
{
for
(
int
ii
=
0
;
ii
<
macroTilesY
;
ii
++)
{
System
.
arraycopy
(
dbg_img
[
kk
],
System
.
arraycopy
(
dbg_img
[
kk
],
// null pointer
ii
*
dbg_width
,
dbg_iterdata
[
kk
],
(
i
*
macroTilesY
+
ii
)
*
dbg_width
,
...
...
@@ -4043,6 +4381,19 @@ public class OpticalFlow {
// ers should be correct for both
double
[]
lma_rms
=
new
double
[
2
];
if
(
high_res_motion_vectors
)
{
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
combo_XYZATR
[
0
],
// xyz
combo_XYZATR
[
1
],
// atr
param_select2
,
// final boolean[] param_select,
param_regweights2
,
// final double [] param_regweights,
lma_rms
,
// double [] rms, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
}
else
{
scenes_xyzatr
[
i
]
=
adjustPairsLMA
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
...
...
@@ -4055,6 +4406,7 @@ public class OpticalFlow {
null
,
// double [][] dbg_img,
0.0
,
// double max_rms,
debug_level
);
// int debug_level)
}
dbg_rms_pre
[
i
]
=
lma_rms
[
0
];
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
scenes_xyzatr
[
i
][
0
],
...
...
@@ -4104,7 +4456,7 @@ public class OpticalFlow {
System
.
out
.
println
(
"adjustSeries(): No processing velosities (\"Second pass\" in pattern_mode"
);
}
if
((
clt_parameters
.
ofp
.
lpf_series
>
1.0
)
&&
!
pattern_mode
)
{
// no velocities in pattern mode
boolean
ers_invert
=
true
;
// false;
boolean
ers_invert
=
false
;
//
true; // false;
// get current ers
double
[][][]
ers_xyzatr
=
getVelocitiesFromScenes
(
scenes
,
// QuadCLT [] scenes, // ordered by increasing timestamps
...
...
@@ -4158,7 +4510,9 @@ public class OpticalFlow {
scenes_xyzatr_dt_preadjust
[
i
]
=
new
double
[][]
{
ers_scene
.
getErsXYZ_dt
().
clone
(),
ers_scene
.
getErsATR_dt
().
clone
()};
scenes_xyzatr_preadjust
[
i
]
=
new
double
[][]
{
scene_xyz
.
clone
(),
scene_atr
.
clone
()};
double
[]
lma_rms
=
new
double
[
2
];
scenes_xyzatr
[
i
]
=
adjustPairsLMA
(
if
(
high_res_motion_vectors
)
{
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scenes
[
i
],
// QuadCLT scene_QuadCLT,
...
...
@@ -4167,9 +4521,22 @@ public class OpticalFlow {
param_select3
,
// 3, // 2, // final boolean[] param_select,
param_regweights2
,
// final double [] param_regweights,
lma_rms
,
// double [] rms, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
}
else
{
scenes_xyzatr
[
i
]
=
adjustPairsLMA
(
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scenes
[
i
],
// QuadCLT scene_QuadCLT,
scene_xyz
,
// combo_XYZATR[0], // xyz
scene_atr
,
// combo_XYZATR[1], // atr
param_select3
,
// final boolean[] param_select,
param_regweights2
,
// final double [] param_regweights,
lma_rms
,
// double [] rms, // null or double [2]
null
,
// double [][] dbg_img,
0.0
,
// double max_rms,
debug_level
);
// int debug_level)
}
dbg_rms
[
i
]
=
lma_rms
[
0
];
ers_reference
.
addScene
(
scene_ts
,
...
...
@@ -5142,6 +5509,8 @@ public class OpticalFlow {
COMBO_DSN_INDX_STRENGTH
,
COMBO_DSN_INDX_VALID
};
// initial: "disp", "strength","num_valid"
double
[][]
combo_dsn
=
null
;
// USE reference scene if no individual DSI are available double [][] dsrbg = scene.getDSRBG(); Probably null for non-reference
double
[][]
combo_dsn0
=
prepareInitialComboDS
(
// 3
clt_parameters
,
// final CLTParameters clt_parameters,
scenes
,
// final QuadCLT [] scenes,
...
...
@@ -5539,7 +5908,7 @@ public class OpticalFlow {
all_scenes_xyzatr
[
i
]
=
new
double
[][]
{
ers_reference
.
getSceneXYZ
(
ts
),
ers_reference
.
getSceneATR
(
ts
)};
all_scenes_ers_dt
[
i
]
=
new
double
[][]
{
ers_reference
.
getSceneErsXYZ_dt
(
ts
),
ers_reference
.
getSceneErsATR_dt
(
ts
)};
}
compareRefSceneTiles
(
compareRefSceneTiles
(
// null pointer
""
,
// String suffix,
true
,
// false, // boolean blur_reference,
all_scenes_xyzatr
,
// double [][][] scene_xyzatr, // does not include reference
...
...
@@ -6243,9 +6612,11 @@ public class OpticalFlow {
for
(
int
i
=
0
;
i
<
num_scenes
;
i
++)
{
dbg_titles
[
i
+
0
]
=
"d-"
+
scenes
[
i
].
getImageName
();
dbg_titles
[
i
+
num_scenes
]
=
"s-"
+
scenes
[
i
].
getImageName
();
if
(
initial_ds
[
i
]
!=
null
)
{
dbg_img
[
i
+
0
]
=
initial_ds
[
i
][
0
];
dbg_img
[
i
+
num_scenes
]
=
initial_ds
[
i
][
1
];
}
}
(
new
ShowDoubleFloatArrays
()).
showArrays
(
dbg_img
,
ref_scene
.
getTileProcessor
().
getTilesX
(),
...
...
@@ -6263,7 +6634,7 @@ public class OpticalFlow {
double
[][][]
initial_toref_ds
=
new
double
[
num_scenes
][][];
initial_toref_ds
[
indx_ref
]
=
initial_ds
[
indx_ref
];
// reference camera ERS should be already set
for
(
int
i
=
0
;
i
<
num_scenes
;
i
++)
if
(
i
!=
indx_ref
)
{
for
(
int
i
=
0
;
i
<
num_scenes
;
i
++)
if
(
(
i
!=
indx_ref
)
&&
(
initial_ds
[
i
]
!=
null
)
)
{
String
ts
=
scenes
[
i
].
getImageName
();
double
[]
scene_xyz
=
ers_reference
.
getSceneXYZ
(
ts
);
double
[]
scene_atr
=
ers_reference
.
getSceneATR
(
ts
);
...
...
@@ -6292,9 +6663,11 @@ public class OpticalFlow {
for
(
int
i
=
0
;
i
<
num_scenes
;
i
++)
{
dbg_titles
[
i
+
0
]
=
"d-"
+
scenes
[
i
].
getImageName
();
dbg_titles
[
i
+
num_scenes
]
=
"s-"
+
scenes
[
i
].
getImageName
();
if
(
initial_toref_ds
[
i
]
!=
null
)
{
dbg_img
[
i
+
0
]
=
initial_toref_ds
[
i
][
0
];
dbg_img
[
i
+
num_scenes
]
=
initial_toref_ds
[
i
][
1
];
}
}
(
new
ShowDoubleFloatArrays
()).
showArrays
(
dbg_img
,
ref_scene
.
getTileProcessor
().
getTilesX
(),
...
...
@@ -6319,7 +6692,7 @@ public class OpticalFlow {
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
tiles
;
nTile
=
ai
.
getAndIncrement
())
{
int
ndef
=
0
;
double
sw
=
0.0
,
swd
=
0.0
;
for
(
int
i
=
0
;
i
<
initial_toref_ds
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
initial_toref_ds
.
length
;
i
++)
if
(
initial_toref_ds
[
i
]
!=
null
)
{
double
d
=
initial_toref_ds
[
i
][
0
][
nTile
];
double
w
=
initial_toref_ds
[
i
][
1
][
nTile
]+
zero_strength
;
if
(!
Double
.
isNaN
(
d
))
{
...
...
@@ -7379,6 +7752,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
clt_parameters
,
// CLTParameters clt_parameters,
scenes
[
nscene
],
// QuadCLT scene,
-
1
);
// int debug_level);
if
(
scene_ds
!=
null
)
{
double
[]
disparity_cam
=
scene_ds
[
0
];
// null; // for now
scene_pXpYD
=
filterBG
(
scenes
[
indx_ref
].
getTileProcessor
(),
// final TileProcessor tp,
...
...
@@ -7390,6 +7764,9 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
clt_parameters
.
tileX
,
// final int dbg_tileX,
clt_parameters
.
tileY
,
// final int dbg_tileY,
0
);
// 1); //debug_level); // final int debug_level);
}
else
{
scene_pXpYD
=
scene_pXpYD_prefilter
;
}
}
scenes
[
nscene
].
saveQuadClt
();
// to re-load new set of Bayer images to the GPU (do nothing for CPU)
final
double
gpu_sigma_corr
=
clt_parameters
.
getGpuCorrSigma
(
scenes
[
nscene
].
isMonochrome
());
...
...
@@ -8681,6 +9058,9 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
// final int margin = 4; /// was 8 for EO 8; // pixels
final
int
margin
=
8
;
// pixels
double
[][]
dsrbg
=
scene
.
getDSRBG
();
if
(
dsrbg
==
null
)
{
return
null
;
}
// mostly filter infinity, clouds, sky
double
[]
disp_outliers
=
QuadCLT
.
removeDisparityOutliers
(
new
double
[][]
{
dsrbg
[
QuadCLT
.
DSRBG_DISPARITY
],
dsrbg
[
QuadCLT
.
DSRBG_STRENGTH
]},
// double [][] ds0,
...
...
@@ -8869,7 +9249,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
boolean
show_render_ref
=
clt_parameters
.
imp
.
renderRef
();
// false; //true;
boolean
show_render_scene
=
clt_parameters
.
imp
.
renderScene
();
// false; // true;
boolean
toRGB
=
clt_parameters
.
imp
.
toRGB
;
// true;
boolean
show_coord_motion
=
clt_parameters
.
imp
.
showCorrMotion
();
// mae its own
if
(
scene_is_ref_test
)
{
scene_xyz
=
ZERO3
.
clone
();
scene_atr
=
ZERO3
.
clone
();
...
...
@@ -9022,6 +9402,10 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
clt_parameters
.
imp
.
n_recenter
,
// final int n_recenter, // when cosine window, re-center window this many times
clt_parameters
.
imp
.
min_str
,
// final double min_str, // = 0.25;
clt_parameters
.
imp
.
min_str_sum
,
// final double min_str_sum, // = 0.8; // 5;
clt_parameters
.
imp
.
min_neibs
,
// final int min_neibs, // 2; // minimal number of strong neighbors (> min_str)
clt_parameters
.
imp
.
weight_zero_neibs
,
// final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8)
clt_parameters
.
imp
.
half_disparity
,
// final double half_disparity, // 5.0; // Reduce weight twice for this disparity
clt_parameters
.
imp
.
half_avg_diff
,
// final double half_avg_diff, // 0.2; // when L2 of x,y difference from average of neibs - reduce twice
clt_parameters
.
tileX
,
// final int debug_tileX,
clt_parameters
.
tileY
,
// final int debug_tileY,
threadsMax
,
// final int threadsMax, // maximal number of threads to launch
...
...
@@ -9112,6 +9496,44 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
true
,
scene
.
getImageName
()+
"-"
+
ref_scene
.
getImageName
()+
"-motion_vectors"
,
titles
);
}
if
(
show_coord_motion
)
{
//coord_motion
String
[]
mvTitles
=
{
"dx"
,
"dy"
,
"conf"
,
"pX"
,
"pY"
,
"Disp"
};
double
[][]
dbg_img
=
new
double
[
mvTitles
.
length
][
tilesX
*
tilesY
];
for
(
int
l
=
0
;
l
<
dbg_img
.
length
;
l
++)
{
Arrays
.
fill
(
dbg_img
[
l
],
Double
.
NaN
);
}
for
(
int
nTile
=
0
;
nTile
<
coord_motion
[
0
].
length
;
nTile
++)
{
if
(
coord_motion
[
0
][
nTile
]
!=
null
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
dbg_img
[
3
+
i
][
nTile
]
=
coord_motion
[
0
][
nTile
][
i
];
}
}
if
(
coord_motion
[
1
][
nTile
]
!=
null
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
dbg_img
[
0
+
i
][
nTile
]
=
coord_motion
[
1
][
nTile
][
i
];
}
}
}
(
new
ShowDoubleFloatArrays
()).
showArrays
(
// out of boundary 15
dbg_img
,
tilesX
,
tilesY
,
true
,
scene
.
getImageName
()+
"-"
+
ref_scene
.
getImageName
()+
"-coord_motion"
,
mvTitles
);
}
if
(
debug_level
>
0
){
int
num_defined
=
0
;
double
sum_strength
=
0.0
;
for
(
int
i
=
0
;
i
<
coord_motion
[
1
].
length
;
i
++)
if
(
coord_motion
[
1
][
i
]
!=
null
){
sum_strength
+=
coord_motion
[
1
][
i
][
2
];
num_defined
++;
}
System
.
out
.
println
(
"interCorrPair(): num_defined = "
+
num_defined
+
", sum_strength = "
+
sum_strength
+
", avg_strength = "
+(
sum_strength
/
num_defined
));
}
return
coord_motion
;
}
...
...
@@ -9379,6 +9801,110 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
}
return
new
double
[][]
{
camera_xyz0
,
camera_atr0
};
}
public
double
[][]
adjustPairsLMAInterscene
(
CLTParameters
clt_parameters
,
QuadCLT
reference_QuadClt
,
QuadCLT
scene_QuadClt
,
double
[]
camera_xyz
,
double
[]
camera_atr
,
boolean
[]
param_select
,
double
[]
param_regweights
,
double
[]
rms_out
,
// null or double [2]
double
max_rms
,
int
debug_level
)
{
int
margin
=
clt_parameters
.
imp
.
margin
;
int
sensor_mask_inter
=
clt_parameters
.
imp
.
sensor_mask_inter
;
//-1;
float
[][][]
facc_2d_img
=
new
float
[
1
][][];
IntersceneLma
intersceneLma
=
new
IntersceneLma
(
this
,
// OpticalFlow opticalFlow
clt_parameters
.
ilp
.
ilma_thread_invariant
);
int
lmaResult
=
-
1
;
boolean
last_run
=
false
;
double
[]
camera_xyz0
=
camera_xyz
.
clone
();
double
[]
camera_atr0
=
camera_atr
.
clone
();
double
[][][]
coord_motion
=
null
;
int
nlma
=
0
;
for
(;
nlma
<
clt_parameters
.
imp
.
max_cycles
;
nlma
++)
{
coord_motion
=
interCorrPair
(
// new double [tilesY][tilesX][][];
clt_parameters
,
// CLTParameters clt_parameters,
reference_QuadClt
,
// QuadCLT reference_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
camera_xyz0
,
// xyz
camera_atr0
,
// pose[1], // atr
null
,
// final boolean [] selection, // may be null, if not null do not process unselected tiles
margin
,
// final int margin,
sensor_mask_inter
,
// final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
facc_2d_img
,
// final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
debug_level
);
// 1); // -1); // int debug_level);
intersceneLma
.
prepareLMA
(
camera_xyz0
,
// final double [] scene_xyz0, // camera center in world coordinates (or null to use instance)
camera_atr0
,
// final double [] scene_atr0, // camera orientation relative to world frame (or null to use instance)
// reference atr, xyz are considered 0.0
scene_QuadClt
,
// final QuadCLT scene_QuadClt,
reference_QuadClt
,
// final QuadCLT reference_QuadClt,
param_select
,
// final boolean[] param_select,
param_regweights
,
// final double [] param_regweights,
coord_motion
[
1
],
// final double [][] vector_XYS, // optical flow X,Y, confidence obtained from the correlate2DIterate()
coord_motion
[
0
],
// final double [][] centers, // macrotile centers (in pixels and average disparities
(
nlma
==
0
),
// boolean first_run,
clt_parameters
.
imp
.
debug_level
);
// final int debug_level)
lmaResult
=
intersceneLma
.
runLma
(
clt_parameters
.
ilp
.
ilma_lambda
,
// double lambda, // 0.1
clt_parameters
.
ilp
.
ilma_lambda_scale_good
,
// double lambda_scale_good,// 0.5
clt_parameters
.
ilp
.
ilma_lambda_scale_bad
,
// double lambda_scale_bad, // 8.0
clt_parameters
.
ilp
.
ilma_lambda_max
,
// double lambda_max, // 100
clt_parameters
.
ilp
.
ilma_rms_diff
,
// double rms_diff, // 0.001
clt_parameters
.
imp
.
max_LMA
,
// int num_iter, // 20
last_run
,
// boolean last_run,
debug_level
);
// int debug_level)
if
(
lmaResult
<
0
)
{
System
.
out
.
println
(
"Interscene adjustment failed, lmaResult="
+
lmaResult
+
" < 0"
);
return
null
;
}
camera_xyz0
=
intersceneLma
.
getSceneXYZ
(
false
);
// true for initial values
camera_atr0
=
intersceneLma
.
getSceneATR
(
false
);
// true for initial values
double
[]
diffs_atr
=
intersceneLma
.
getV3Diff
(
ErsCorrection
.
DP_DSAZ
);
double
[]
diffs_xyz
=
intersceneLma
.
getV3Diff
(
ErsCorrection
.
DP_DSX
);
if
((
diffs_atr
[
0
]
<
clt_parameters
.
imp
.
exit_change_atr
)
&&
(
diffs_xyz
[
0
]
<
clt_parameters
.
imp
.
exit_change_xyz
))
{
break
;
}
}
if
(
clt_parameters
.
imp
.
debug_level
>
-
2
)
{
String
[]
lines1
=
intersceneLma
.
printOldNew
(
false
);
// boolean allvectors)
System
.
out
.
println
(
"Adjusted interscene, iteration="
+
nlma
+
", last RMS = "
+
intersceneLma
.
getLastRms
()[
0
]+
" (pure RMS = "
+
intersceneLma
.
getLastRms
()[
1
]+
")"
+
", results:"
);
for
(
String
line
:
lines1
)
{
System
.
out
.
println
(
line
);
}
// if (intersceneLma.getLastRms()[0] > clt_parameters.imp.max_rms) {
// System.out.println("Interscene adjustment failed, RMS="+
// intersceneLma.getLastRms()[0]+" > "+ clt_parameters.imp.max_rms);
// return null;
// }
}
if
((
rms_out
!=
null
)
&&
(
intersceneLma
.
getLastRms
()
!=
null
))
{
rms_out
[
0
]
=
intersceneLma
.
getLastRms
()[
0
];
rms_out
[
1
]
=
intersceneLma
.
getLastRms
()[
1
];
//if (lmaResult < 0) { last_rms[0]
}
if
(
max_rms
>
0.0
)
{
if
(
lmaResult
<
0
)
{
// = 0) {
return
null
;
}
if
(!(
intersceneLma
.
getLastRms
()[
0
]
<=
max_rms
))
{
System
.
out
.
println
(
"RMS failed: "
+
intersceneLma
.
getLastRms
()[
0
]+
" >= "
+
max_rms
);
return
null
;
}
}
return
new
double
[][]
{
camera_xyz0
,
camera_atr0
};
}
/*
public static String getChecksum(Serializable object) throws IOException, NoSuchAlgorithmException {
ByteArrayOutputStream baos = null;
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
View file @
23452c5b
...
...
@@ -5615,6 +5615,26 @@ if (debugLevel < -100) {
return
quadCLT
;
}
public
QuadCLT
spawnNoModelQuadCLT
(
String
set_name
,
CLTParameters
clt_parameters
,
ColorProcParameters
colorProcParameters
,
//
int
threadsMax
,
int
debugLevel
)
{
QuadCLT
quadCLT
=
new
QuadCLT
(
this
,
set_name
);
//null
quadCLT
.
restoreNoModel
(
clt_parameters
,
colorProcParameters
,
null
,
// double [] noise_sigma_level,
-
1
,
// noise_variant, // <0 - no-variants, compatible with old code
null
,
// final QuadCLTCPU ref_scene, // may be null if scale_fpn <= 0
threadsMax
,
debugLevel
);
return
quadCLT
;
}
}
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
23452c5b
...
...
@@ -67,6 +67,7 @@ import com.elphel.imagej.correction.EyesisCorrections;
import
com.elphel.imagej.gpu.GpuQuad
;
import
com.elphel.imagej.gpu.TpTask
;
import
com.elphel.imagej.jp4.JP46_Reader_camera
;
import
com.elphel.imagej.readers.ImagejJp4Tiff
;
import
com.elphel.imagej.tileprocessor.CorrVector
;
import
com.elphel.imagej.tileprocessor.QuadCLTCPU.SetChannels
;
import
com.elphel.imagej.x3d.export.WavefrontExport
;
...
...
@@ -83,6 +84,7 @@ import ij.io.FileSaver;
import
ij.process.ColorProcessor
;
import
ij.process.FloatProcessor
;
import
ij.process.ImageProcessor
;
import
loci.formats.FormatException
;
public
class
QuadCLTCPU
{
...
...
@@ -709,6 +711,80 @@ public class QuadCLTCPU {
return
this
;
// can only be QuadCLT instance
}
public
QuadCLTCPU
restoreNoModel
(
CLTParameters
clt_parameters
,
ColorProcParameters
colorProcParameters
,
NoiseParameters
noise_sigma_level
,
int
noise_variant
,
// <0 - no-variants, compatible with old code
QuadCLTCPU
ref_scene
,
// may be null if scale_fpn <= 0
int
threadsMax
,
int
debugLevel
)
{
final
int
debugLevelInner
=
clt_parameters
.
batch_run
?
-
2
:
debugLevel
;
String
jp4_copy_path
=
correctionsParameters
.
selectX3dDirectory
(
this
.
image_name
,
// quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
correctionsParameters
.
jp4SubDir
,
true
,
// smart,
true
);
//newAllowed, // save
String
[]
sourceFiles
=
correctionsParameters
.
selectSourceFileInSet
(
jp4_copy_path
,
debugLevel
);
SetChannels
[]
set_channels
=
setChannels
(
null
,
// single set name
sourceFiles
,
debugLevel
);
// sets set name to jp4, overwrite
set_channels
[
0
].
set_name
=
this
.
image_name
;
// set_name;
double
[]
referenceExposures
=
null
;
if
(!
isLwir
())
{
// colorProcParameters.lwir_islwir) {
referenceExposures
=
eyesisCorrections
.
calcReferenceExposures
(
sourceFiles
,
debugLevel
);
}
int
[]
channelFiles
=
set_channels
[
0
].
fileNumber
();
boolean
[][]
saturation_imp
=
(
clt_parameters
.
sat_level
>
0.0
)?
new
boolean
[
channelFiles
.
length
][]
:
null
;
double
[]
scaleExposures
=
new
double
[
channelFiles
.
length
];
// ImagePlus [] imp_srcs =
conditionImageSet
(
clt_parameters
,
// EyesisCorrectionParameters.CLTParameters clt_parameters,
colorProcParameters
,
// ColorProcParameters colorProcParameters, //
sourceFiles
,
// String [] sourceFiles,
this
.
image_name
,
// String set_name,
referenceExposures
,
// double [] referenceExposures,
channelFiles
,
// int [] channelFiles,
scaleExposures
,
// output // double [] scaleExposures
saturation_imp
,
// output // boolean [][] saturation_imp,
threadsMax
,
// int threadsMax,
debugLevelInner
);
// int debugLevel);
if
(
noise_sigma_level
!=
null
)
{
generateAddNoise
(
"-NOISE"
,
ref_scene
,
// final QuadCLTCPU ref_scene, // may be null if scale_fpn <= 0
noise_sigma_level
,
noise_variant
,
//final int noise_variant, // <0 - no-variants, compatible with old code
threadsMax
,
1
);
// debugLevel); // final int debug_level)
}
/*
// try to restore DSI generated from interscene if available, if not use single-scene -DSI_MAIN
if (restoreDSI(
"-DSI_INTER",
true // silent
) < 0) {
restoreDSI(
"-DSI_MAIN", // "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
false); // silent
}
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
}
// generate and save noise file (each Bayer component amplitude same as the corresponding image average,
// apply gaussian blur with sigma (before Bayer scaling)
// If file with the same sigma already exists in the model directory - just use it, multiply by noise_sigma_level[0] and add to the non-zero Bayer
...
...
@@ -8053,8 +8129,8 @@ public class QuadCLTCPU {
// need to replace for low-res?
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -8352,8 +8428,8 @@ public class QuadCLTCPU {
}
public
boolean
preExpandCLTQuad3d
(
// USED in lwir
ImagePlus
[]
imp_quad
,
// should have properties "name"(base for saving results), "channel","path"
boolean
[][]
saturation_imp
,
// (near) saturated pixels or null
//
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path"
//
boolean [][] saturation_imp, // (near) saturated pixels or null
CLTParameters
clt_parameters
,
EyesisCorrectionParameters
.
DebayerParameters
debayerParameters
,
ColorProcParameters
colorProcParameters
,
...
...
@@ -8368,7 +8444,8 @@ public class QuadCLTCPU {
final
boolean
show_init_refine
=
clt_parameters
.
show_init_refine
;
// change to true?
//max_expand
String
name
=
(
String
)
imp_quad
[
0
].
getProperty
(
"name"
);
// String name = (String) imp_quad[0].getProperty("name");
String
name
=
getImageName
();
// should create data for the macro! (diff, rgb) make sure .texture_tiles is measured correctly
CLTPass3d
bgnd_data
=
CLTBackgroundMeas
(
// measure background - both CPU and GPU (remove textures from GPU)
clt_parameters
,
...
...
@@ -11490,7 +11567,7 @@ public class QuadCLTCPU {
}
// Save KML and ratings files if they do not exist (so not to overwrite edited ones), make them world-writable
writeKml
(
debugLevel
);
writeKml
(
null
,
debugLevel
);
writeRatingFile
(
debugLevel
);
...
...
@@ -13828,8 +13905,8 @@ public class QuadCLTCPU {
if
(
correctionsParameters
.
clt_batch_extrinsic
)
{
if
(
tp
!=
null
)
tp
.
resetCLTPasses
();
boolean
ok
=
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -13852,8 +13929,8 @@ public class QuadCLTCPU {
if
(
correctionsParameters
.
clt_batch_poly
)
{
if
(
tp
!=
null
)
tp
.
resetCLTPasses
();
boolean
ok
=
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -13893,8 +13970,8 @@ public class QuadCLTCPU {
if
(
correctionsParameters
.
clt_batch_explore
)
{
if
(
tp
!=
null
)
tp
.
resetCLTPasses
();
boolean
ok
=
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -13976,6 +14053,7 @@ public class QuadCLTCPU {
public
boolean
setGpsLla
(
// USED in lwir
String
source_file
)
{
/*
ImagePlus imp=(new JP46_Reader_camera(false)).open(
"", // path,
source_file,
...
...
@@ -13983,6 +14061,17 @@ public class QuadCLTCPU {
true, // un-apply camera color gains
null, // new window
false); // do not show
*/
ImagePlus
imp
=
null
;
try
{
imp
=
(
new
ImagejJp4Tiff
()).
readTiffJp4
(
source_file
,
true
);
}
catch
(
IOException
|
FormatException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
// scale);
if
(
imp
.
getProperty
(
"LATITUDE"
)
!=
null
){
gps_lla
=
new
double
[
3
];
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
...
...
@@ -13998,8 +14087,12 @@ public class QuadCLTCPU {
public
boolean
writeKml
(
// USED in lwir
String
image_name
,
int
debugLevel
)
{
if
(
image_name
==
null
)
{
image_name
=
this
.
image_name
;
}
String
[]
sourceFiles_main
=
correctionsParameters
.
getSourcePaths
();
SetChannels
[]
set_channels
=
setChannels
(
image_name
,
debugLevel
);
// only for specified image timestamp
...
...
@@ -14010,6 +14103,7 @@ public class QuadCLTCPU {
}
}
for
(
String
fname:
path_list
)
{
System
.
out
.
println
(
"writeKml(): "
+
fname
);
if
(
setGpsLla
(
fname
))
{
break
;
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
View file @
23452c5b
...
...
@@ -3074,11 +3074,13 @@ if (debugLevel > -100) return true; // temporarily !
public
void
copyJP4src
(
public
static
void
copyJP4src
(
String
set_name
,
QuadCLT
quadCLT_main
,
// tiles should be set
QuadCLT
quadCLT_aux
,
CLTParameters
clt_parameters
,
boolean
skip_existing
,
boolean
search_KML
,
final
int
debugLevel
)
// throws Exception
{
// quadCLT_main.writeKml(debugLevel);
...
...
@@ -3087,27 +3089,23 @@ if (debugLevel > -100) return true; // temporarily !
String
[]
sourceFiles_main
=
quadCLT_main
.
correctionsParameters
.
getSourcePaths
();
//
// String [] sourceFiles_aux=quadCLT_main.correctionsParameters.getSourcePaths();
if
(
set_name
==
null
)
{
set_name
=
quadCLT_main
.
image_name
;
}
if
(
set_name
==
null
)
{
if
(
(
set_name
==
null
)
&&
(
quadCLT_aux
!=
null
)
)
{
set_name
=
quadCLT_aux
.
image_name
;
}
if
(
set_name
==
null
)
{
QuadCLT
.
SetChannels
[]
set_channels
=
quadCLT_main
.
setChannels
(
debugLevel
);
if
(
set_channels
==
null
)
{
if
(
(
set_channels
==
null
)
&&
(
quadCLT_aux
!=
null
)
)
{
set_channels
=
quadCLT_aux
.
setChannels
(
debugLevel
);
}
set_name
=
set_channels
[
0
].
set_name
;
set_name
=
set_channels
[
0
0
].
set_name
;
}
QuadCLT
.
SetChannels
[]
set_channels_main
=
quadCLT_main
.
setChannels
(
set_name
,
debugLevel
);
// only for specified image timestamp
QuadCLT
.
SetChannels
[]
set_channels_aux
=
quadCLT_aux
.
setChannels
(
set_name
,
debugLevel
)
;
QuadCLT
.
SetChannels
[]
set_channels_aux
=
(
quadCLT_aux
!=
null
)
?
quadCLT_aux
.
setChannels
(
set_name
,
debugLevel
)
:
null
;
ArrayList
<
String
>
path_list
=
new
ArrayList
<
String
>();
if
(
set_channels_main
!=
null
)
for
(
int
i
=
0
;
i
<
set_channels_main
.
length
;
i
++)
{
...
...
@@ -3120,9 +3118,9 @@ if (debugLevel > -100) return true; // temporarily !
path_list
.
add
(
sourceFiles_main
[
fn
]);
}
}
if
(
set_channels_main
!=
null
)
{
quadCLT_main
.
writeKml
(
debugLevel
);
// also generated with x3d model
}
//
if (set_channels_main !=null) {
//
quadCLT_main.writeKml(debugLevel ); // also generated with x3d model
//
}
String
jp4_copy_path
=
quadCLT_main
.
correctionsParameters
.
selectX3dDirectory
(
set_name
,
// quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
...
...
@@ -3133,6 +3131,11 @@ if (debugLevel > -100) return true; // temporarily !
if
(!
dir
.
exists
()){
dir
.
mkdirs
();
System
.
out
.
println
(
"Created "
+
dir
);
}
else
if
(
skip_existing
)
{
if
(
dir
.
list
().
length
>
0
)
{
System
.
out
.
println
(
"Skipping existing directory "
+
dir
);
return
;
}
}
for
(
String
fname:
path_list
)
{
if
(
fname
.
contains
(
set_name
))
{
// only files containing set name // TODO:improve
...
...
@@ -3149,6 +3152,11 @@ if (debugLevel > -100) return true; // temporarily !
}
}
}
if
(
search_KML
&&
(
set_channels_main
!=
null
))
{
// TODO: make it look in both MAIN and AUX. Look in only the same scene?
quadCLT_main
.
writeKml
(
set_name
,
debugLevel
);
// also generated with x3d model
}
System
.
out
.
println
(
"jp4_copy_path = "
+
jp4_copy_path
);
// System.out.println("Do something useful here");
}
...
...
@@ -7657,8 +7665,8 @@ if (debugLevel > -100) return true; // temporarily !
}
quadCLT_main
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_main
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -7696,8 +7704,8 @@ if (debugLevel > -100) return true; // temporarily !
" (w/o rig), pass "
+(
num_adjust_aux
+
1
)+
" of "
+
quadCLT_main
.
correctionsParameters
.
rig_batch_adjust_aux
);
}
quadCLT_aux
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_aux
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters_aux
,
...
...
@@ -7774,8 +7782,8 @@ if (debugLevel > -100) return true; // temporarily !
{
if
(
updateStatus
)
IJ
.
showStatus
(
"Building basic DSI for the main camera image set "
+
quadCLT_main
.
image_name
+
" (post rig adjustment)"
);
quadCLT_main
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_main
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -7934,8 +7942,8 @@ if (debugLevel > -100) return true; // temporarily !
if
(
quadCLT_main
.
correctionsParameters
.
clt_batch_dsi_aux
)
{
if
(
updateStatus
)
IJ
.
showStatus
(
"Building basic DSI for the aux camera image set "
+
quadCLT_main
.
image_name
+
" (for DSI export)"
);
quadCLT_aux
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_aux
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters_aux
,
...
...
@@ -7965,8 +7973,8 @@ if (debugLevel > -100) return true; // temporarily !
if
(
quadCLT_main
.
correctionsParameters
.
clt_batch_explore
)
{
if
(
updateStatus
)
IJ
.
showStatus
(
"Building basic DSI for the main camera image set "
+
quadCLT_main
.
image_name
+
" (after all adjustments)"
);
quadCLT_main
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_main
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -8076,6 +8084,8 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main
,
// QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux
,
// QuadCLT quadCLT_aux,
clt_parameters
,
// EyesisCorrectionParameters.CLTParameters clt_parameters,
true
,
// boolean skip_existing,
true
,
// boolean search_KML,
debugLevel
);
// final int debugLevel)
}
...
...
@@ -8530,6 +8540,63 @@ if (debugLevel > -100) return true; // temporarily !
}
/**
* Build series of poses from just a single (reference) scene.
* @param quadCLT_main
* @param ref_index
* @param ref_step
* @param clt_parameters
* @param debayerParameters
* @param colorProcParameters
* @param channelGainParameters
* @param rgbParameters
* @param equirectangularParameters
* @param properties
* @param reset_from_extrinsics
* @param threadsMax
* @param updateStatus
* @param debugLevel
* @throws Exception
*/
public
void
buildSeriesTQ
(
QuadCLT
quadCLT_main
,
// tiles should be set
int
ref_index
,
// -1 - last
int
ref_step
,
CLTParameters
clt_parameters
,
EyesisCorrectionParameters
.
DebayerParameters
debayerParameters
,
ColorProcParameters
colorProcParameters
,
CorrectionColorProc
.
ColorGainsParameters
channelGainParameters
,
EyesisCorrectionParameters
.
RGBParameters
rgbParameters
,
EyesisCorrectionParameters
.
EquirectangularParameters
equirectangularParameters
,
Properties
properties
,
boolean
reset_from_extrinsics
,
final
int
threadsMax
,
// maximal number of threads to launch
final
boolean
updateStatus
,
final
int
debugLevel
)
throws
Exception
{
OpticalFlow
opticalFlow
=
new
OpticalFlow
(
quadCLT_main
.
getNumSensors
(),
clt_parameters
.
ofp
.
scale_no_lma_disparity
,
// double scale_no_lma_disparity,
threadsMax
,
// int threadsMax, // maximal number of threads to launch
updateStatus
);
// boolean updateStatus);
opticalFlow
.
buildSeries
(
quadCLT_main
,
// QuadCLT quadCLT_main, // tiles should be set
ref_index
,
// int ref_index, // -1 - last
ref_step
,
// int ref_step,
clt_parameters
,
// CLTParameters clt_parameters,
debayerParameters
,
// EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters
,
// ColorProcParameters colorProcParameters,
channelGainParameters
,
// CorrectionColorProc.ColorGainsParameters channelGainParameters,
rgbParameters
,
// EyesisCorrectionParameters.RGBParameters rgbParameters,
equirectangularParameters
,
// EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
properties
,
// Properties properties,
reset_from_extrinsics
,
// boolean reset_from_extrinsics,
threadsMax
,
// final int threadsMax, // maximal number of threads to launch
updateStatus
,
// final boolean updateStatus,
debugLevel
+
2
);
// final int debugLevel)
}
public
void
intersceneAccumulate
(
...
...
@@ -11700,8 +11767,8 @@ if (debugLevel > -100) return true; // temporarily !
}
//Generates background image in model tree - should be done later, after adjustment (It is overwritten later, so OK)
quadCLT_main
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_main
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -11752,8 +11819,8 @@ if (debugLevel > -100) return true; // temporarily !
if
(
quadCLT_main
.
correctionsParameters
.
clt_batch_dsi1
){
System
.
out
.
println
(
"Trying experimental features DSI/ERS"
);
quadCLT_main
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_main
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -11785,6 +11852,8 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main
,
// QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux
,
// QuadCLT quadCLT_aux,
clt_parameters
,
// EyesisCorrectionParameters.CLTParameters clt_parameters,
true
,
// boolean skip_existing,
true
,
// boolean search_KML,
debugLevel
);
// final int debugLevel)
}
}
...
...
@@ -11831,8 +11900,8 @@ if (debugLevel > -100) return true; // temporarily !
if
(
quadCLT_main
.
correctionsParameters
.
clt_batch_explore
)
{
if
(
updateStatus
)
IJ
.
showStatus
(
"Building basic DSI for the main camera image set "
+
quadCLT_main
.
image_name
+
" (after all adjustments)"
);
quadCLT_main
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_main
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters
,
...
...
@@ -11911,6 +11980,8 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main
,
// QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux
,
// QuadCLT quadCLT_aux,
clt_parameters
,
// EyesisCorrectionParameters.CLTParameters clt_parameters,
true
,
// boolean skip_existing,
true
,
// boolean search_KML,
debugLevel
);
// final int debugLevel)
}
...
...
@@ -12035,8 +12106,8 @@ if (debugLevel > -100) return true; // temporarily !
// dbg_path = "/home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif";
if
(
dbg_path
==
null
)
{
quadCLT_aux
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_aux
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters_aux
,
...
...
@@ -12127,8 +12198,8 @@ if (debugLevel > -100) return true; // temporarily !
if
(
quadCLT_main
.
correctionsParameters
.
clt_batch_dsi_aux
)
{
if
(
updateStatus
)
IJ
.
showStatus
(
"Building basic DSI for the aux camera image set "
+
quadCLT_main
.
image_name
+
" (for DSI export)"
);
quadCLT_aux
.
preExpandCLTQuad3d
(
// returns ImagePlus, but it already should be saved/shown
imp_srcs_aux
,
// [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux
,
// boolean [][] saturation_imp, // (near) saturated pixels or null
//
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
//
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters
,
debayerParameters
,
colorProcParameters_aux
,
...
...
@@ -12206,6 +12277,8 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main
,
// QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux
,
// QuadCLT quadCLT_aux,
clt_parameters
,
// EyesisCorrectionParameters.CLTParameters clt_parameters,
true
,
// boolean skip_existing,
true
,
// boolean search_KML,
debugLevel
);
// final int debugLevel)
}
if
(
dsi_aux_from_main
!=
null
)
{
...
...
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