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
1ff463f4
Commit
1ff463f4
authored
Jan 15, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed processing of negative disparity
parent
91f2ace8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
183 additions
and
52 deletions
+183
-52
BiQuadParameters.java
...ava/com/elphel/imagej/tileprocessor/BiQuadParameters.java
+41
-12
ErsCorrection.java
...n/java/com/elphel/imagej/tileprocessor/ErsCorrection.java
+67
-16
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+45
-10
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+1
-1
TwoQuadCLT.java
...main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
+29
-13
No files found.
src/main/java/com/elphel/imagej/tileprocessor/BiQuadParameters.java
View file @
1ff463f4
...
...
@@ -248,8 +248,14 @@ public class BiQuadParameters {
// ML export for LWIR16 camera
// calculating GT
public
double
mll_min_disp_change
=
0.001
;
// stop re-measure when difference is below
public
int
mll_max_refines
=
10
;
public
double
mll_min_disp_change_pre
=
0.01
;
// stop re-measure when difference is below
public
int
mll_max_refines_pre
=
10
;
public
double
mll_min_disp_change_lma
=
0.001
;
// stop re-measure when difference is below
public
int
mll_max_refines_lma
=
5
;
public
boolean
mll_generate_scene_outlines
=
false
;
// Uses 2 GB - change format, add dimensions (separate color for ref)
// Exporting ML files
public
boolean
mll_add_combo
=
true
;
// add 121-st slice with combined pairs correlation
public
boolean
mll_save_accum
=
true
;
// save accumulated 0-offset correlation
...
...
@@ -681,10 +687,17 @@ public class BiQuadParameters {
gd
.
addTab
(
"ML"
,
"Parameters related to the ML files generation for the dual-quad camera rig"
);
gd
.
addMessage
(
"Calculating GT Disparity"
);
gd
.
addNumericField
(
"Min change of disparity"
,
this
.
mll_min_disp_change
,
3
,
6
,
"pix"
,
gd
.
addNumericField
(
"Min change of disparity (preliminary, 40 pairs/no LMA)"
,
this
.
mll_min_disp_change_pre
,
3
,
6
,
"pix"
,
"Refine tile until disparity change falls below"
);
gd
.
addNumericField
(
"Number of disparity refine passes (preliminary, 40 pairs/no LMA)"
,
this
.
mll_max_refines_pre
,
0
,
3
,
""
,
"Abandon disparity refinement for tiles where disparity does not converge after this number of passes"
);
gd
.
addNumericField
(
"Min change of disparity (final, 120 pairs with LMA)"
,
this
.
mll_min_disp_change_lma
,
3
,
6
,
"pix"
,
"Refine tile until disparity change falls below"
);
gd
.
addNumericField
(
"Number of disparity refine passes
"
,
this
.
mll_max_refines
,
0
,
3
,
""
,
gd
.
addNumericField
(
"Number of disparity refine passes
(final, 120 pairs with LMA)"
,
this
.
mll_max_refines_lma
,
0
,
3
,
""
,
"Abandon disparity refinement for tiles where disparity does not converge after this number of passes"
);
gd
.
addCheckbox
(
"Generate scene outlines"
,
this
.
mll_generate_scene_outlines
,
"Generate and save scene outlines for scene series (need to change format, it is 2GB with uncompressed Tiff)"
);
gd
.
addMessage
(
"ML output files export for LWIR16 camera"
);
gd
.
addCheckbox
(
"Add combo slice"
,
this
.
mll_add_combo
,
"Add combined correlations slice from all available pairs after rotation/scaling. Will not be used for training, can be removed to reduce processing time"
);
...
...
@@ -980,8 +993,12 @@ public class BiQuadParameters {
this
.
oc_min_disparity
=
gd
.
getNextNumber
();
this
.
oc_min_strength
=
gd
.
getNextNumber
();
this
.
mll_min_disp_change
=
gd
.
getNextNumber
();
this
.
mll_max_refines
=
(
int
)
gd
.
getNextNumber
();
this
.
mll_min_disp_change_pre
=
gd
.
getNextNumber
();
this
.
mll_max_refines_pre
=
(
int
)
gd
.
getNextNumber
();
this
.
mll_min_disp_change_lma
=
gd
.
getNextNumber
();
this
.
mll_max_refines_lma
=
(
int
)
gd
.
getNextNumber
();
this
.
mll_generate_scene_outlines
=
gd
.
getNextBoolean
();
this
.
mll_add_combo
=
gd
.
getNextBoolean
();
this
.
mll_save_accum
=
gd
.
getNextBoolean
();
this
.
mll_randomize_offsets
=
gd
.
getNextBoolean
();
...
...
@@ -1225,8 +1242,12 @@ public class BiQuadParameters {
properties
.
setProperty
(
prefix
+
"oc_min_disparity"
,
this
.
oc_min_disparity
+
""
);
properties
.
setProperty
(
prefix
+
"oc_min_strength"
,
this
.
oc_min_strength
+
""
);
properties
.
setProperty
(
prefix
+
"mll_min_disp_change"
,
this
.
mll_min_disp_change
+
""
);
properties
.
setProperty
(
prefix
+
"mll_max_refines"
,
this
.
mll_max_refines
+
""
);
properties
.
setProperty
(
prefix
+
"mll_min_disp_change_pre"
,
this
.
mll_min_disp_change_pre
+
""
);
properties
.
setProperty
(
prefix
+
"mll_max_refines_pre"
,
this
.
mll_max_refines_pre
+
""
);
properties
.
setProperty
(
prefix
+
"mll_min_disp_change_lma"
,
this
.
mll_min_disp_change_lma
+
""
);
properties
.
setProperty
(
prefix
+
"mll_max_refines_lma"
,
this
.
mll_max_refines_lma
+
""
);
properties
.
setProperty
(
prefix
+
"mll_generate_scene_outlines"
,
this
.
mll_generate_scene_outlines
+
""
);
properties
.
setProperty
(
prefix
+
"mll_add_combo"
,
this
.
mll_add_combo
+
""
);
properties
.
setProperty
(
prefix
+
"mll_save_accum"
,
this
.
mll_save_accum
+
""
);
properties
.
setProperty
(
prefix
+
"mll_randomize_offsets"
,
this
.
mll_randomize_offsets
+
""
);
...
...
@@ -1467,8 +1488,12 @@ public class BiQuadParameters {
if
(
properties
.
getProperty
(
prefix
+
"oc_min_disparity"
)!=
null
)
this
.
oc_min_disparity
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"oc_min_disparity"
));
if
(
properties
.
getProperty
(
prefix
+
"oc_min_strength"
)!=
null
)
this
.
oc_min_strength
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"oc_min_strength"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_min_disp_change"
)!=
null
)
this
.
mll_min_disp_change
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"mll_min_disp_change"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_max_refines"
)!=
null
)
this
.
mll_max_refines
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"mll_max_refines"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_min_disp_change_pre"
)!=
null
)
this
.
mll_min_disp_change_pre
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"mll_min_disp_change_pre"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_max_refines_pre"
)!=
null
)
this
.
mll_max_refines_pre
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"mll_max_refines_pre"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_min_disp_change_lma"
)!=
null
)
this
.
mll_min_disp_change_lma
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"mll_min_disp_change_lma"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_max_refines_lma"
)!=
null
)
this
.
mll_max_refines_lma
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"mll_max_refines_lma"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_generate_scene_outlines"
)!=
null
)
this
.
mll_generate_scene_outlines
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"mll_generate_scene_outlines"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_add_combo"
)!=
null
)
this
.
mll_add_combo
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"mll_add_combo"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_save_accum"
)!=
null
)
this
.
mll_save_accum
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"mll_save_accum"
));
if
(
properties
.
getProperty
(
prefix
+
"mll_randomize_offsets"
)!=
null
)
this
.
mll_randomize_offsets
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"mll_randomize_offsets"
));
...
...
@@ -1709,8 +1734,12 @@ public class BiQuadParameters {
bqp
.
oc_min_disparity
=
this
.
oc_min_disparity
;
bqp
.
oc_min_strength
=
this
.
oc_min_strength
;
bqp
.
mll_min_disp_change
=
this
.
mll_min_disp_change
;
bqp
.
mll_max_refines
=
this
.
mll_max_refines
;
bqp
.
mll_min_disp_change_pre
=
this
.
mll_min_disp_change_pre
;
bqp
.
mll_max_refines_pre
=
this
.
mll_max_refines_pre
;
bqp
.
mll_min_disp_change_lma
=
this
.
mll_min_disp_change_lma
;
bqp
.
mll_max_refines_lma
=
this
.
mll_max_refines_lma
;
bqp
.
mll_generate_scene_outlines
=
this
.
mll_generate_scene_outlines
;
bqp
.
mll_add_combo
=
this
.
mll_add_combo
;
bqp
.
mll_save_accum
=
this
.
mll_save_accum
;
bqp
.
mll_randomize_offsets
=
this
.
mll_randomize_offsets
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/ErsCorrection.java
View file @
1ff463f4
...
...
@@ -208,6 +208,17 @@ public class ErsCorrection extends GeometryCorrection {
private
double
[][]
ers_atr
;
// azimuth-tilt-roll per scan line
private
double
[][]
ers_atr_dt
;
// angular velocities per scan line. It is now actually 2*omega!
/*
static final double ERS_MIN_DISPARITY = 1.0E-6; // to avoid disparity == 0.0 in division
private double limitedReciprocal(double d) {
if (d > ERS_MIN_DISPARITY) return 1/0/d;
if (d < -ERS_MIN_DISPARITY) return 1/0/d;
if (d > 0) return 1.0/ERS_MIN_DISPARITY;
return -1.0/ERS_MIN_DISPARITY;
}
*/
public
void
setPose
(
double
[]
camera_xyz
,
double
[]
camera_atr
)
{
...
...
@@ -948,7 +959,8 @@ public class ErsCorrection extends GeometryCorrection {
return
null
;
}
if
(
xyzw
[
2
]
>
0
)
{
return
null
;
// can not match object behind the camera
xyzw
[
2
]
=
xyzw
[
2
];
/// return null; // can not match object behind the camera
}
ErsCorrection
ers_camera
=
this
;
if
(
cameraQuadCLT
!=
null
)
{
...
...
@@ -1028,30 +1040,43 @@ public class ErsCorrection extends GeometryCorrection {
// camera orientation during pixel acquisition :
Quaternion
qpix
=
ers_quaternion
[
line
];
Rotation
cam_orient_now_local
=
new
Rotation
(
qpix
.
getQ0
(),
qpix
.
getQ1
(),
qpix
.
getQ2
(),
qpix
.
getQ3
(),
true
);
// boolean needsNormalization)
boolean
is_infinity
=
Math
.
abs
(
disparity
)
<
THRESHOLD
;
// Maybe all negative - too?
if
(!
is_infinity
)
{
/// boolean is_infinity = Math.abs(disparity) < THRESHOLD; // Maybe all negative - too?
/// if (!is_infinity) {
if
(
Math
.
abs
(
disparity
)
>=
THRESHOLD
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
xyz
[
i
]
/=
disparity
;
}
}
else
{
if
(
disparity
>=
0
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
xyz
[
i
]
/=
THRESHOLD
;
}
}
else
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
xyz
[
i
]
/=
-
THRESHOLD
;
}
}
}
Vector3D
v3
=
new
Vector3D
(
xyz
);
// convert to frame parallel to the camera during center line
Vector3D
cam_center_now_local
=
cam_orient_now_local
.
applyInverseTo
(
v3
);
// get real world xyz relative to the camera acquiring a center line
Vector3D
cam_center_local
=
(
is_infinity
)
?
cam_center_now_local
:
cam_center_now_local
.
add
(
cam_now_local
);
// skip translation for infinity
/// Vector3D cam_center_local = (is_infinity) ? cam_center_now_local : cam_center_now_local.add(cam_now_local); // skip translation for infinity
Vector3D
cam_center_local
=
cam_center_now_local
.
add
(
cam_now_local
);
// skip translation for infinity
// undo camera rotation during acquisition of the center line.
Vector3D
cam_center_world
=
cam_orient_center
.
applyInverseTo
(
cam_center_local
);
// convert to the real world coordinates
world_xyz
=
(
is_infinity
)
?
cam_center_world
:
cam_center_world
.
add
(
new
Vector3D
(
camera_xyz
));
/// world_xyz = (is_infinity) ? cam_center_world : cam_center_world.add(new Vector3D(camera_xyz));
world_xyz
=
cam_center_world
.
add
(
new
Vector3D
(
camera_xyz
));
double
[]
wxyz
=
world_xyz
.
toArray
();
double
[]
wxyz4
=
{
wxyz
[
0
],
wxyz
[
1
],
wxyz
[
2
],
1.0
};
if
(
Double
.
isNaN
(
wxyz4
[
0
]))
{
wxyz4
[
0
]
=
Double
.
NaN
;
}
if
(
is_infinity
)
{
wxyz4
[
3
]
=
0.0
;
}
///
if (is_infinity) {
///
wxyz4[3] = 0.0;
///
}
return
wxyz4
;
}
...
...
@@ -1994,13 +2019,26 @@ public class ErsCorrection extends GeometryCorrection {
double
[]
camera_atr
,
// camera orientation relative to world frame
double
line_err
)
// threshold error in scan lines (1.0)
{
boolean
is_infinity
=
xyzw
[
3
]
==
0
;
/// boolean is_infinity = xyzw[3] == 0;
double
rxyzw3
=
0.0
;
// = 1.0/xyzw[3]
if
(
Math
.
abs
(
xyzw
[
3
])
>=
THRESHOLD
)
{
rxyzw3
=
1.0
/
xyzw
[
3
];
}
else
if
(
xyzw
[
3
]
>
0.0
)
{
rxyzw3
=
1.0
/
THRESHOLD
;
}
else
{
rxyzw3
=
-
1.0
/
THRESHOLD
;
}
Vector3D
world_xyz
=
new
Vector3D
(
xyzw
[
0
],
xyzw
[
1
],
xyzw
[
2
]);
world_xyz
.
scalarMultiply
(
rxyzw3
);
/*
if (!is_infinity) {
world_xyz.scalarMultiply(1.0/xyzw[3]);
}
*/
// convert to camera-centered, world-parallel coordinates
Vector3D
cam_center_world
=
(
is_infinity
)
?
world_xyz
:
world_xyz
.
subtract
(
new
Vector3D
(
camera_xyz
));
/// Vector3D cam_center_world = (is_infinity) ? world_xyz : world_xyz.subtract(new Vector3D(camera_xyz));
Vector3D
cam_center_world
=
world_xyz
.
subtract
(
new
Vector3D
(
camera_xyz
));
// rotate to match camera coordinates when scanning the center line
Rotation
cam_orient_center
=
new
Rotation
(
RotationOrder
.
YXZ
,
ROT_CONV
,
camera_atr
[
0
],
camera_atr
[
1
],
camera_atr
[
2
]);
Vector3D
cam_center_local
=
cam_orient_center
.
applyTo
(
cam_center_world
);
...
...
@@ -2020,19 +2058,32 @@ public class ErsCorrection extends GeometryCorrection {
Vector3D
cam_now_local1
=
new
Vector3D
(
ers_xyz
[
iline1
]);
Vector3D
cam_now_local
=
cam_now_local0
.
scalarMultiply
(
1.0
-
fline
).
add
(
fline
,
cam_now_local1
);
Vector3D
cam_center_now_local
=
(
is_infinity
)
?
cam_center_local
:
cam_center_local
.
subtract
(
cam_now_local
);
// skip translation for infinity
/// Vector3D cam_center_now_local = (is_infinity) ? cam_center_local : cam_center_local.subtract(cam_now_local); // skip translation for infinity
Vector3D
cam_center_now_local
=
cam_center_local
.
subtract
(
cam_now_local
);
// skip translation for infinity
Quaternion
qpix0
=
ers_quaternion
[
iline0
];
Quaternion
qpix1
=
ers_quaternion
[
iline1
];
Quaternion
qpix
=
(
qpix0
.
multiply
(
1.0
-
fline
)).
add
(
qpix1
.
multiply
(
fline
));
Rotation
cam_orient_now_local
=
new
Rotation
(
qpix
.
getQ0
(),
qpix
.
getQ1
(),
qpix
.
getQ2
(),
qpix
.
getQ3
(),
true
);
// boolean
Vector3D
v3
=
cam_orient_now_local
.
applyTo
(
cam_center_now_local
);
double
[]
xyz
=
v3
.
toArray
();
if
(
Math
.
abs
(
xyz
[
2
])
<
THRESHOLD
)
{
return
null
;
// object too close to the lens
/// if (Math.abs(xyz[2]) < THRESHOLD) {
/// return null; // object too close to the lens
/// }
double
recip_disp
;
// = xyz[2];
if
(
Math
.
abs
(
xyz
[
2
])
>=
THRESHOLD
)
{
recip_disp
=
1.0
/
xyz
[
2
];
// object too close to the lens (positive or negative)
}
else
if
(
xyz
[
2
]
>
0
)
{
recip_disp
=
1.0
/
THRESHOLD
;
}
else
{
recip_disp
=
-
1.0
/
THRESHOLD
;
}
double
pXc
=
-(
1000.0
*
focalLength
/
pixelSize
)
*
xyz
[
0
]
/
xyz
[
2
];
double
pYc
=
(
1000.0
*
focalLength
/
pixelSize
)
*
xyz
[
1
]
/
xyz
[
2
];
double
disparity
=
is_infinity
?
0.0
:
(-(
1000.0
*
focalLength
/
pixelSize
)
/
xyz
[
2
]
*
SCENE_UNITS_SCALE
*
disparityRadius
);
double
pXc
=
-(
1000.0
*
focalLength
/
pixelSize
)
*
xyz
[
0
]
*
recip_disp
;
// / xyz[2];
double
pYc
=
(
1000.0
*
focalLength
/
pixelSize
)
*
xyz
[
1
]
*
recip_disp
;
// / xyz[2];
// double disparity = is_infinity ? 0.0 : (-(1000.0*focalLength / pixelSize) / xyz[2] * SCENE_UNITS_SCALE * disparityRadius);
double
disparity
=
-(
1000.0
*
focalLength
/
pixelSize
)
*
recip_disp
*
SCENE_UNITS_SCALE
*
disparityRadius
;
double
rND
=
Math
.
sqrt
(
pXc
*
pXc
+
pYc
*
pYc
)*
0.001
*
this
.
pixelSize
;
// mm
double
rD2RND
=
correctDistortions
?
getRDistByR
(
rND
/
this
.
distortionRadius
):
1.0
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
1ff463f4
...
...
@@ -2494,7 +2494,7 @@ public class OpticalFlow {
double
centerX
=
tileX
*
transform_size
+
transform_size
/
2
;
// - shiftX;
double
centerY
=
tileY
*
transform_size
+
transform_size
/
2
;
// - shiftY;
if
(
disparity
<
0
)
{
disparity
=
0.0
;
disparity
=
1.0
*
disparity
;
//
0.0;
}
if
(
scene_QuadClt
==
reference_QuadClt
)
{
pXpYD
[
nTile
]
=
new
double
[]
{
centerX
,
centerY
,
disparity
};
...
...
@@ -3982,13 +3982,17 @@ public class OpticalFlow {
CLTParameters
clt_parameters
,
ErsCorrection
ers_reference
,
QuadCLT
[]
scenes
,
int
indx_ref
,
ColorProcParameters
colorProcParameters
,
QuadCLT
ref_scene
,
// ordered by increasing timestamps
int
debug_level
)
{
boolean
generate_outlines
=
true
;
// TODO: move to configs
// empiric correction for both lma and non-lma step
double
corr_nonlma
=
1.23
;
double
corr_lma
=
1.23
;
// reference scene is always added to tghe end, even is out of timestamp order
int
indx_ref
=
scenes
.
length
-
1
;
// Always added to the end even if out-of order
QuadCLT
ref_scene
=
scenes
[
indx_ref
];
// ordered by increasing timestamps
boolean
generate_outlines
=
false
;
// true; // TODO: move to configs
System
.
out
.
println
(
"intersceneExport(), scene timestamp="
+
ref_scene
.
getImageName
());
int
num_scenes
=
scenes
.
length
;
String
[]
combo_dsn_titles
=
{
"disp"
,
"strength"
,
"disp_lma"
,
"num_valid"
,
"change"
};
...
...
@@ -3998,8 +4002,8 @@ public class OpticalFlow {
int
combo_dsn_indx_valid
=
3
;
// initial only
int
combo_dsn_indx_change
=
4
;
// increment
final
double
min_disp_change
=
clt_parameters
.
rig
.
mll_min_disp_chang
e
;
// 0.001; // stop re-measure when difference is below
final
int
max_refines
=
clt_parameters
.
rig
.
mll_max_refines
;
double
min_disp_change
=
clt_parameters
.
rig
.
mll_min_disp_change_pr
e
;
// 0.001; // stop re-measure when difference is below
final
int
max_refines
=
clt_parameters
.
rig
.
mll_max_refines
_lma
+
clt_parameters
.
rig
.
mll_max_refines_pre
;
final
int
[]
iter_indices
=
{
combo_dsn_indx_disp
,
...
...
@@ -4025,6 +4029,7 @@ public class OpticalFlow {
final
int
tilesX
=
ref_scene
.
getTileProcessor
().
getTilesX
();
final
int
tilesY
=
ref_scene
.
getTileProcessor
().
getTilesY
();
final
int
tiles
=
tilesX
*
tilesY
;
// uses 2 GB - change format
if
(
generate_outlines
)
{
// debug_level > 100) { // add parameter?
int
extra
=
10
;
// pixels around largest outline
int
scale
=
4
;
...
...
@@ -4090,13 +4095,41 @@ public class OpticalFlow {
}
}
double
[]
target_disparity
=
combo_dsn_change
[
combo_dsn_indx_disp
].
clone
();
double
[]
target_disparity_orig
=
target_disparity
.
clone
();
// will just use NaN/not NaN to restore tasks before second pass with LMA
double
[][]
combo_dsn_final
=
new
double
[
combo_dsn_titles
.
length
][
combo_dsn
[
0
].
length
];
combo_dsn_final
[
0
]=
combo_dsn
[
0
].
clone
();
for
(
int
i
=
1
;
i
<
combo_dsn_final
.
length
;
i
++)
{
Arrays
.
fill
(
combo_dsn_final
[
i
],
Double
.
NaN
);
}
// Save pair selection and minimize them for scanning, then restore;
int
num_sensors
=
scenes
[
indx_ref
].
getNumSensors
();
int
save_pairs_selection
=
clt_parameters
.
img_dtt
.
getMcorr
(
num_sensors
);
clt_parameters
.
img_dtt
.
setMcorr
(
num_sensors
,
0
);
// remove all
clt_parameters
.
img_dtt
.
setMcorrNeib
(
num_sensors
,
true
);
clt_parameters
.
img_dtt
.
setMcorrSq
(
num_sensors
,
true
);
// remove even more?
clt_parameters
.
img_dtt
.
setMcorrDia
(
num_sensors
,
true
);
// remove even more?
boolean
save_run_lma
=
clt_parameters
.
correlate_lma
;
clt_parameters
.
correlate_lma
=
false
;
for
(
int
nrefine
=
0
;
nrefine
<
max_refines
;
nrefine
++)
{
int
mcorr_sel
=
Correlation2d
.
corrSelEncode
(
clt_parameters
.
img_dtt
,
scenes
[
indx_ref
].
getNumSensors
());
if
(
nrefine
==
clt_parameters
.
rig
.
mll_max_refines_pre
)
{
min_disp_change
=
clt_parameters
.
rig
.
mll_min_disp_change_lma
;
clt_parameters
.
img_dtt
.
setMcorr
(
num_sensors
,
save_pairs_selection
);
// restore
clt_parameters
.
correlate_lma
=
save_run_lma
;
// restore
for
(
int
nt
=
0
;
nt
<
target_disparity
.
length
;
nt
++)
if
(
Double
.
isNaN
(
target_disparity
[
nt
])){
if
(!
Double
.
isNaN
(
target_disparity_orig
[
nt
]))
{
target_disparity
[
nt
]
=
combo_dsn_change
[
combo_dsn_indx_disp
][
nt
];
}
}
if
(
debug_level
>
-
2
)
{
int
num_tomeas
=
0
;
for
(
int
nt
=
0
;
nt
<
target_disparity
.
length
;
nt
++)
if
(!
Double
.
isNaN
(
target_disparity
[
nt
])){
num_tomeas
++;
}
System
.
out
.
println
(
"nrefine pass = "
+
nrefine
+
", remaining "
+
num_tomeas
+
" tiles to re-measure"
);
}
}
int
mcorr_sel
=
Correlation2d
.
corrSelEncode
(
clt_parameters
.
img_dtt
,
num_sensors
);
double
[][]
disparity_map
=
correlateInterscene
(
clt_parameters
,
// final CLTParameters clt_parameters,
...
...
@@ -4111,7 +4144,7 @@ public class OpticalFlow {
false
,
// final boolean no_map, // do not generate disparity_map (time-consuming LMA)
debug_level
-
8
);
// final int debug_level)
if
(
debug_level
>
0
)
{
if
(
debug_level
>
-
3
)
{
(
new
ShowDoubleFloatArrays
()).
showArrays
(
disparity_map
,
tilesX
,
...
...
@@ -4133,9 +4166,9 @@ public class OpticalFlow {
// if ((map_disparity_lma != null) || !Double.isNaN(map_disparity[nTile])) { // remeasured
if
(!
Double
.
isNaN
(
map_disparity
[
nTile
]))
{
// remeasured
if
((
map_disparity_lma
!=
null
)
&&
!
Double
.
isNaN
(
map_disparity_lma
[
nTile
]))
{
combo_dsn_change
[
combo_dsn_indx_change
][
nTile
]
=
map_disparity_lma
[
nTile
];
combo_dsn_change
[
combo_dsn_indx_change
][
nTile
]
=
map_disparity_lma
[
nTile
]
*
corr_nonlma
;
}
else
if
(!
Double
.
isNaN
(
map_disparity
[
nTile
]))
{
combo_dsn_change
[
combo_dsn_indx_change
][
nTile
]
=
map_disparity
[
nTile
]
/
clt_parameters
.
ofp
.
magic_scale
;
combo_dsn_change
[
combo_dsn_indx_change
][
nTile
]
=
map_disparity
[
nTile
]
/
clt_parameters
.
ofp
.
magic_scale
*
corr_lma
;
}
if
(!
Double
.
isNaN
(
combo_dsn_change
[
combo_dsn_indx_change
][
nTile
]))
{
combo_dsn_change
[
combo_dsn_indx_disp
][
nTile
]
+=
combo_dsn_change
[
combo_dsn_indx_change
][
nTile
];
...
...
@@ -4193,6 +4226,8 @@ public class OpticalFlow {
}
}
// Do above twice: with 40 pairs, no-lma and then with all pairs+LMA
if
(
debug_level
>
1
)
{
(
new
ShowDoubleFloatArrays
()).
showArrays
(
combo_dsn_change
,
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
1ff463f4
...
...
@@ -693,7 +693,7 @@ public class QuadCLTCPU {
"-DSI_MAIN"
,
// "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
false
);
// silent
}
restoreInterProperties
(
// restore properties for interscene processing (extrinsics, ers, ...)
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
);
...
...
src/main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
View file @
1ff463f4
...
...
@@ -9036,9 +9036,13 @@ if (debugLevel > -100) return true; // temporarily !
return
;
}
QuadCLT
.
SetChannels
[]
set_channels
=
quadCLT_main
.
setChannels
(
debugLevel
);
// TODO: use just the last one (to need this is no time)
if
(
indx_ref
<
00
)
{
indx_ref
=
set_channels
.
length
+
indx_ref
;
// count from the last
}
QuadCLT
ref_quadCLT
=
quadCLT_main
.
spawnQuadCLT
(
set_channels
[
set_channels
.
length
-
1
].
set_name
,
QuadCLT
ref_quadCLT
=
quadCLT_main
.
spawnQuadCLT
(
// gets all relative poses (98)
// set_channels[set_channels.length-1].set_name,
set_channels
[
indx_ref
].
set_name
,
clt_parameters
,
colorProcParameters
,
//
threadsMax
,
...
...
@@ -9051,9 +9055,6 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax
,
// int threadsMax, // maximal number of threads to launch
updateStatus
,
// boolean updateStatus,
clt_parameters
.
inp
.
noise_debug_level
);
// debugLevel); // int debugLevel)
// if (debugLevel > -1000) return; // TODO: Remove
OpticalFlow
opticalFlow
=
new
OpticalFlow
(
quadCLT_main
.
getNumSensors
(),
...
...
@@ -9061,15 +9062,15 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax
,
// int threadsMax, // maximal number of threads to launch
updateStatus
);
ErsCorrection
ers_reference
=
ref_quadCLT
.
getErsCorrection
();
String
[]
sts
=
ref_only
?
(
new
String
[
0
])
:
ers_reference
.
getScenes
();
String
[]
sts
=
ref_only
?
(
new
String
[
0
])
:
ers_reference
.
getScenes
();
// others, referenced by reference
// get list of all other scenes
int
num_scenes
=
sts
.
length
+
1
;
int
num_scenes
=
sts
.
length
+
1
;
// including reference
// int indx_ref = num_scenes - 1;
if
(
indx_ref
<
0
)
{
indx_ref
=
num_scenes
-
1
;
}
//
if (indx_ref < 0) {
//
indx_ref = num_scenes - 1;
//
}
QuadCLT
[]
scenes
=
new
QuadCLT
[
num_scenes
];
scenes
[
indx_ref
]
=
ref_quadCLT
;
scenes
[
scenes
.
length
-
1
]
=
ref_quadCLT
;
// always added to the end, even if out of order
for
(
int
i
=
0
;
i
<
sts
.
length
;
i
++)
{
scenes
[
i
]
=
ref_quadCLT
.
spawnQuadCLT
(
// spawnQuadCLT(
...
...
@@ -9084,13 +9085,12 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus
,
// boolean updateStatus,
-
1
);
// debug_level); // int debugLevel)
}
// Does not need to specify reference scene - it is always the last even if out of timestamp order
opticalFlow
.
intersceneExport
(
clt_parameters
,
// CLTParameters clt_parameters,
ers_reference
,
// ErsCorrection ers_reference,
scenes
,
// QuadCLT [] scenes,
indx_ref
,
// int indx_ref,
colorProcParameters
,
// ColorProcParameters colorProcParameters,
ref_quadCLT
,
// QuadCLT ref_scene, // ordered by increasing timestamps
clt_parameters
.
inp
.
noise_debug_level
// clt_parameters.ofp.debug_level_optical - 1); // 1); // -1); // int debug_level);
);
...
...
@@ -12006,6 +12006,22 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus
,
// final boolean updateStatus,
debugLevel
);
}
if
(
quadCLT_main
.
correctionsParameters
.
clt_batch_ml_all_aux
)
{
int
ref_index
=
50
;
// temporarily, will make evently distributed
interIntraExportML
(
quadCLT_aux
,
// QuadCLT quadCLT_main,
ref_index
,
// TODO: Make with some strp from latest, matching clt_batch_pose_scene_aux
clt_parameters
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters
,
// EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux
,
// EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
channelGainParameters
,
// CorrectionColorProc.ColorGainsParameters channelGainParameters,
rgbParameters
,
// EyesisCorrectionParameters.RGBParameters rgbParameters,
equirectangularParameters
,
// EyesisCorrectionParameters.EquirectangularParameters
// equirectangularParameters,
properties
,
// Properties properties,
threadsMax
,
// final int threadsMax, // maximal number of threads to launch
updateStatus
,
// final boolean updateStatus,
debugLevel
);
}
/*
if ((quadCLT_main != null) && (quadCLT_main.getGPU() != null)) { //TODO: is it needed here? WAs not needed before - verify
quadCLT_main.getGPU().resetGeometryCorrection();
...
...
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