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
5075dfa3
Commit
5075dfa3
authored
Jul 11, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compositeScan() with multi-plane (FG/BG) results
parent
28f7044c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
656 additions
and
13 deletions
+656
-13
Eyesis_Correction.java
.../java/com/elphel/imagej/correction/Eyesis_Correction.java
+1
-1
CLTPass3d.java
src/main/java/com/elphel/imagej/tileprocessor/CLTPass3d.java
+1
-1
QuadCLT.java
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
+63
-9
TileProcessor.java
...n/java/com/elphel/imagej/tileprocessor/TileProcessor.java
+591
-2
No files found.
src/main/java/com/elphel/imagej/correction/Eyesis_Correction.java
View file @
5075dfa3
...
...
@@ -5335,7 +5335,7 @@ private Panel panel1,
if
(
ds_list
.
get
(
nt
).
isEmpty
())
continue
;
Collections
.
sort
(
ds_list
.
get
(
nt
),
new
Comparator
<
DS
>()
{
@Override
public
int
compare
(
DS
lhs
,
DS
rhs
)
{
public
int
compare
(
DS
lhs
,
DS
rhs
)
{
// ascending
return
rhs
.
disparity
>
lhs
.
disparity
?
-
1
:
(
rhs
.
disparity
<
lhs
.
disparity
)
?
1
:
0
;
}
});
...
...
src/main/java/com/elphel/imagej/tileprocessor/CLTPass3d.java
View file @
5075dfa3
...
...
@@ -446,7 +446,7 @@ public class CLTPass3d{
}
/**
*
Get Get c
ombine per-tile disparity values from correlation combined with pre-programmed initial disparity shift.
*
C
ombine per-tile disparity values from correlation combined with pre-programmed initial disparity shift.
* @return line-scan array of per-tile disparity by reference (not a copy), so it can be modified
*/
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
View file @
5075dfa3
...
...
@@ -5973,8 +5973,41 @@ public class QuadCLT {
threadsMax
,
// maximal number of threads to launch
updateStatus
,
debugLevel
);
// Add here composite scans and show FG and BG images
// adjust extrinsics here
ArrayList
<
CLTPass3d
>
combo_pass_list
=
tp
.
compositeScan
(
2
,
// just FG and BG
tp
.
clt_3d_passes
,
// final ArrayList <CLTPass3d> passes,
0
,
// bg_pass, // final int firstPass,
tp
.
clt_3d_passes
.
size
(),
// final int lastPassPlus1,
tp
.
getTrustedCorrelation
(),
// final double trustedCorrelation,
tp
.
getMaxOverexposure
(),
// final double max_overexposure,
0.0
,
// clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
clt_parameters
.
grow_disp_max
,
// final double disp_near,
clt_parameters
.
combine_min_strength
,
// final double minStrength,
clt_parameters
.
combine_min_hor
,
// final double minStrengthHor,
clt_parameters
.
combine_min_vert
,
// final double minStrengthVert,
false
,
// final boolean no_weak,
false
,
// final boolean use_last, //
// TODO: when useCombo - pay attention to borders (disregard)
false
,
// final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true
,
// final boolean copyDebug)
debugLevel
);
tp
.
ShowScansSFB
(
combo_pass_list
,
// ArrayList<CLTPass3d> scans, // list of composite scans
this
.
image_name
+
"-SFB"
);
// String title);
/*
if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_compositeScan-"+tp.clt_3d_passes.size());
*/
}
if
(
adjust_extrinsics
)
{
if
(
use_rig
)
{
...
...
@@ -6010,6 +6043,30 @@ public class QuadCLT {
debugLevel
);
}
ArrayList
<
CLTPass3d
>
combo_pass_list
=
tp
.
compositeScan
(
2
,
// just FG and BG
tp
.
clt_3d_passes
,
// final ArrayList <CLTPass3d> passes,
0
,
// bg_pass, // final int firstPass,
tp
.
clt_3d_passes
.
size
(),
// final int lastPassPlus1,
tp
.
getTrustedCorrelation
(),
// final double trustedCorrelation,
tp
.
getMaxOverexposure
(),
// final double max_overexposure,
0.0
,
// clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
clt_parameters
.
grow_disp_max
,
// final double disp_near,
clt_parameters
.
combine_min_strength
,
// final double minStrength,
clt_parameters
.
combine_min_hor
,
// final double minStrengthHor,
clt_parameters
.
combine_min_vert
,
// final double minStrengthVert,
false
,
// final boolean no_weak,
false
,
// final boolean use_last, //
// TODO: when useCombo - pay attention to borders (disregard)
false
,
// final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true
,
// final boolean copyDebug)
debugLevel
);
tp
.
ShowScansSFB
(
combo_pass_list
,
// ArrayList<CLTPass3d> scans, // list of composite scans
this
.
image_name
+
"-SFB"
);
// String title);
Runtime
.
getRuntime
().
gc
();
// if (debugLevel >-1) System.out.println("Processing set "+(nSet+1)+" (of "+setNames.size()+") finished at "+
...
...
@@ -6457,14 +6514,11 @@ public class QuadCLT {
if
(
show_init_refine
)
tp
.
showScan
(
tp
.
clt_3d_passes
.
get
(
refine_pass
),
// CLTPass3d scan,
"after_measure-"
+
tp
.
clt_3d_passes
.
size
());
// if (nnn < (num_macro_refine-1)) {
// if (clt_parameters.combine_refine){
CLTPass3d
combo_pass
=
tp
.
compositeScan
(
tp
.
clt_3d_passes
,
// final ArrayList <CLTPass3d> passes,
bg_pass
,
// final int firstPass,
tp
.
clt_3d_passes
.
size
(),
// final int lastPassPlus1,
// tp.clt_3d_passes.get(bg_pass).getSelected(), // selected , // final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
// clt_parameters.ex_min_over,// final double ex_min_over, // when expanding over previously detected (by error) background, disregard far tiles
tp
.
getTrustedCorrelation
(),
// final double trustedCorrelation,
tp
.
getMaxOverexposure
(),
// final double max_overexposure,
0.0
,
// clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
...
...
src/main/java/com/elphel/imagej/tileprocessor/TileProcessor.java
View file @
5075dfa3
...
...
@@ -65,6 +65,11 @@ public class TileProcessor {
"y0"
,
"y1"
,
"y2"
,
"y3"
,
"d0"
,
"d1"
,
"d2"
,
"d3"
};
public
static
String
[]
SCAN_TITLES_DS
=
{
"disparity"
,
"strength"
};
public
ArrayList
<
CLTPass3d
>
clt_3d_passes
=
null
;
public
double
[][]
rig_disparity_strength
=
null
;
// Disparity and strength created by a two-camera rig, with disparity scale and distortions of the main camera
...
...
@@ -910,7 +915,6 @@ public class TileProcessor {
return
fund_per
;
}
/**
* Calculates calc_disparity, calc_disparity_hor, calc_disparity_vert, strength, strength_hor, strength_vert,
* max_tried_disparity from the subset of a list of measurement passes (skipping non-measured)
...
...
@@ -918,6 +922,7 @@ public class TileProcessor {
* tile_op is set to 0/non-0 to show which tiles contain valid data
* disparity (target disparity) array is set to null as it can not be made valid (different values for disparity,
* disparity_hor and disparity_vert.
* Single-plane version, compatible with the older code
* @param passes list of scan passes to take data from
* @param firstPass index of the first pass to use
* @param lastPassPlus1 index plus 1 of the last pass to use
...
...
@@ -932,7 +937,7 @@ public class TileProcessor {
* @param use_last use last scan data if nothing strong enough (false - use the strongest)
* @param usePoly use polynomial method to find max for full correlation, false - use center of mass
* @param copyDebug copy data that is only needed for debug purposes
* @return
new composite scan pass (not added to the list
* @return
new composite scan pass (not added to the list)
*/
public
CLTPass3d
compositeScan
(
final
ArrayList
<
CLTPass3d
>
passes
,
...
...
@@ -951,6 +956,466 @@ public class TileProcessor {
final
boolean
usePoly
,
// use polynomial method to find max), valid if useCombo == false
final
boolean
copyDebug
,
final
int
debugLevel
)
{
return
compositeScan
(
1
,
// final int num_planes,
passes
,
firstPass
,
lastPassPlus1
,
trustedCorrelation
,
max_overexposure
,
disp_far
,
// limit results to the disparity range
disp_near
,
minStrength
,
minStrengthHor
,
minStrengthVert
,
no_weak
,
use_last
,
//
// TODO: when useCombo - pay attention to borders (disregard)
usePoly
,
// use polynomial method to find max), valid if useCombo == false
copyDebug
,
debugLevel
).
get
(
0
);
}
class
DSD
{
int
indx
;
double
disparity
;
double
strength
;
double
adiff
;
DSD
(
int
indx
){
// only index
this
.
indx
=
indx
;
}
DSD
(
int
indx
,
double
disparity
,
double
strength
,
double
adiff
){
this
.
indx
=
indx
;
this
.
disparity
=
disparity
;
this
.
strength
=
strength
;
this
.
adiff
=
adiff
;
}
}
private
ArrayList
<
DSD
>
filterDsdList
(
ArrayList
<
DSD
>
src_list
,
double
disp_tolerance
,
int
max_len
,
boolean
descending
){
// false: disparity from far to near, true - near to far
if
(
disp_tolerance
<
0.0
)
{
disp_tolerance
=
0.0
;
}
ArrayList
<
DSD
>
filtered_list
=
new
ArrayList
<
DSD
>();
ArrayList
<
DSD
>
list_in
=
src_list
;
while
(!
list_in
.
isEmpty
())
{
int
best_indx
=
0
;
for
(
int
i
=
1
;
i
<
list_in
.
size
();
i
++)
{
if
(
list_in
.
get
(
i
).
adiff
<
list_in
.
get
(
best_indx
).
adiff
)
{
best_indx
=
i
;
}
}
DSD
best_dsd
=
list_in
.
get
(
best_indx
);
filtered_list
.
add
(
best_dsd
);
ArrayList
<
DSD
>
list_remain
=
new
ArrayList
<
DSD
>();
for
(
DSD
dsd:
list_in
)
{
if
(
Math
.
abs
(
best_dsd
.
disparity
-
dsd
.
disparity
)
>
disp_tolerance
)
{
list_remain
.
add
(
dsd
);
}
}
list_in
=
list_remain
;
}
// Trim if too long
if
(
filtered_list
.
size
()
>
max_len
)
{
// sort by strength
Collections
.
sort
(
filtered_list
,
new
Comparator
<
DSD
>()
{
// descending (switched rhs, lhs)
@Override
public
int
compare
(
DSD
rhs
,
DSD
lhs
)
{
return
rhs
.
strength
>
lhs
.
strength
?
-
1
:
(
rhs
.
strength
<
lhs
.
strength
)
?
1
:
0
;
}
});
while
(
filtered_list
.
size
()
>
max_len
)
{
filtered_list
.
remove
(
filtered_list
.
size
()
-
1
);
}
}
// sort by disparity
if
(
descending
)
{
Collections
.
sort
(
filtered_list
,
new
Comparator
<
DSD
>()
{
// descending (switched rhs, lhs)
@Override
public
int
compare
(
DSD
rhs
,
DSD
lhs
)
{
return
rhs
.
disparity
>
lhs
.
disparity
?
-
1
:
(
rhs
.
disparity
<
lhs
.
disparity
)
?
1
:
0
;
}
});
}
else
{
Collections
.
sort
(
filtered_list
,
new
Comparator
<
DSD
>()
{
@Override
public
int
compare
(
DSD
lhs
,
DSD
rhs
)
{
// ascending
return
rhs
.
disparity
>
lhs
.
disparity
?
-
1
:
(
rhs
.
disparity
<
lhs
.
disparity
)
?
1
:
0
;
}
});
}
return
filtered_list
;
}
/**
* Calculates calc_disparity, calc_disparity_hor, calc_disparity_vert, strength, strength_hor, strength_vert,
* max_tried_disparity from the subset of a list of measurement passes (skipping non-measured)
* disparity, strength, *_hor and vert may come from the different scans.
* tile_op is set to 0/non-0 to show which tiles contain valid data
* disparity (target disparity) array is set to null as it can not be made valid (different values for disparity,
* disparity_hor and disparity_vert.
* Update 2019 - generates multiple composite scan passes to represent foreground/background or more disparity
* values for the same tile
* @param num_planes Number of foreground/background planes to generate
* @param passes list of scan passes to take data from
* @param firstPass index of the first pass to use
* @param lastPassPlus1 index plus 1 of the last pass to use
* @param trustedCorrelation maximal absolute value of measured correlation (no scaling) to trust (may use global trustedCorrelation)
* @param max_overexposure maximal fraction of (near) overexposed pixels in a tile to discard it
* @param disp_far lowest disparity value to consider (does not apply to max_tried_disparity)
* @param disp_near highest disparity value to consider (does not apply to max_tried_disparity)
* @param minStrength full correlation strength to consider data to be reliable
* @param minStrengthHor horizontal (for vertical features) correlation strength to consider data to be reliable. NaN - do not use
* @param minStrengthVert vertical (for horizontal features) correlation strength to consider data to be reliable. NaN - do not use
* @param no_weak Do not use weak at all
* @param use_last use last scan data if nothing strong enough (false - use the strongest)
* @param usePoly use polynomial method to find max for full correlation, false - use center of mass
* @param copyDebug copy data that is only needed for debug purposes
* @return list of the new composite scan passes (not added to the list
*/
public
ArrayList
<
CLTPass3d
>
compositeScan
(
final
int
num_planes
,
final
ArrayList
<
CLTPass3d
>
passes
,
final
int
firstPass
,
final
int
lastPassPlus1
,
final
double
trustedCorrelation
,
final
double
max_overexposure
,
final
double
disp_far
,
// limit results to the disparity range
final
double
disp_near
,
final
double
minStrength
,
final
double
minStrengthHor
,
final
double
minStrengthVert
,
final
boolean
no_weak
,
final
boolean
use_last
,
//
// TODO: when useCombo - pay attention to borders (disregard)
final
boolean
usePoly
,
// use polynomial method to find max), valid if useCombo == false
final
boolean
copyDebug
,
final
int
debugLevel
)
{
// CLTPass3d combo_pass =new CLTPass3d(this);
final
boolean
descending
=
false
;
// disparity order in the result list
final
double
disparity_tolerance
=
0.5
;
// minimal disparity to separate FG/BG
final
int
tlen
=
tilesX
*
tilesY
;
final
int
disparity_index
=
usePoly
?
ImageDtt
.
DISPARITY_INDEX_POLY
:
ImageDtt
.
DISPARITY_INDEX_CM
;
final
ArrayList
<
CLTPass3d
>
combo_pass_list
=
new
ArrayList
<
CLTPass3d
>();
final
int
dbg_tile
=
(
debugLevel
>
0
)?
35114
:
-
1
;
// x = 122, y= 108; -1; // 27669;
for
(
int
np
=
0
;
np
<
num_planes
;
np
++)
{
combo_pass_list
.
add
(
new
CLTPass3d
(
this
));
}
for
(
CLTPass3d
combo_pass
:
combo_pass_list
)
{
combo_pass
.
tile_op
=
new
int
[
tilesY
][
tilesX
];
// for just non-zero
combo_pass
.
disparity_map
=
new
double
[
ImageDtt
.
DISPARITY_TITLES
.
length
][];
for
(
int
i
=
0
;
i
<
ImageDtt
.
QUAD
;
i
++)
combo_pass
.
disparity_map
[
ImageDtt
.
IMG_DIFF0_INDEX
+
i
]
=
new
double
[
tlen
];
if
(
copyDebug
){
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_CM
]
=
new
double
[
tlen
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_STRENGTH_INDEX
]
=
new
double
[
tlen
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR
]
=
new
double
[
tlen
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR_STRENGTH
]
=
new
double
[
tlen
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT
]
=
new
double
[
tlen
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT_STRENGTH
]
=
new
double
[
tlen
];
}
// for now - will copy from the best full correlation measurement
combo_pass
.
texture_tiles
=
new
double
[
tilesY
][
tilesX
][][];
combo_pass
.
max_tried_disparity
=
new
double
[
tilesY
][
tilesX
];
combo_pass
.
is_combo
=
true
;
combo_pass
.
calc_disparity
=
new
double
[
tlen
];
combo_pass
.
calc_disparity_hor
=
new
double
[
tlen
];
combo_pass
.
calc_disparity_vert
=
new
double
[
tlen
];
combo_pass
.
strength
=
new
double
[
tlen
];
combo_pass
.
strength_hor
=
new
double
[
tlen
];
combo_pass
.
strength_vert
=
new
double
[
tlen
];
for
(
int
ty
=
0
;
ty
<
tilesY
;
ty
++)
for
(
int
tx
=
0
;
tx
<
tilesX
;
tx
++)
combo_pass
.
texture_tiles
[
ty
][
tx
]
=
null
;
}
// * Calculates calc_disparity, calc_disparity_hor, calc_disparity_vert, strength, strength_hor, strength_vert,
// temporary:
CLTPass3d
combo_pass0
=
combo_pass_list
.
get
(
0
);
for
(
int
ty
=
0
;
ty
<
tilesY
;
ty
++)
{
for
(
int
tx
=
0
;
tx
<
tilesX
;
tx
++){
int
nt
=
ty
*
tilesX
+
tx
;
int
best_index
=
-
1
;
int
best_index_hor
=
-
1
;
int
best_index_vert
=
-
1
;
int
best_weak_index
=
-
1
;
int
best_weak_index_hor
=
-
1
;
int
best_weak_index_vert
=
-
1
;
// for "strong" result (above minStrength) the best fit is with smallest residual disparity
// for weak ones - the strongest.
// TODO: handle ortho (if requested so)
// after refine - use last, after extend - use strongest of all
double
adiff_best
=
Double
.
NaN
;
double
adiff_best_hor
=
Double
.
NaN
;
double
adiff_best_vert
=
Double
.
NaN
;
double
strongest_weak
=
0.0
;
double
strongest_weak_hor
=
0.0
;
double
strongest_weak_vert
=
0.0
;
combo_pass0
.
max_tried_disparity
[
ty
][
tx
]
=
Double
.
NaN
;
if
(
nt
==
dbg_tile
)
{
System
.
out
.
println
(
"compositeScan(): nt = "
+
nt
);
}
ArrayList
<
DSD
>
quad_list
=
new
ArrayList
<
DSD
>();
ArrayList
<
DSD
>
hor_list
=
new
ArrayList
<
DSD
>();
ArrayList
<
DSD
>
vert_list
=
new
ArrayList
<
DSD
>();
for
(
int
ipass
=
firstPass
;
ipass
<
lastPassPlus1
;
ipass
++
){
CLTPass3d
pass
=
passes
.
get
(
ipass
);
if
(
nt
==
dbg_tile
)
{
System
.
out
.
println
(
"compositeScan(): ipass = "
+
ipass
+
" nt = "
+
nt
+
" pass.tile_op["
+
ty
+
"]["
+
tx
+
"]="
+
pass
.
tile_op
[
ty
][
tx
]+
" pass.isCombo()="
+(
pass
.
isCombo
())+
" pass.isProcessed()="
+(
pass
.
isProcessed
()));
}
if
(
pass
.
isMeasured
()
&&
(
pass
.
tile_op
[
ty
][
tx
]
!=
0
))
{
// current tile has valid data
if
(
(
Double
.
isNaN
(
combo_pass0
.
max_tried_disparity
[
ty
][
tx
])
||
(
pass
.
disparity
[
ty
][
tx
]
>
combo_pass0
.
max_tried_disparity
[
ty
][
tx
]))){
combo_pass0
.
max_tried_disparity
[
ty
][
tx
]
=
pass
.
disparity
[
ty
][
tx
];
}
boolean
last
=
(
ipass
==
(
lastPassPlus1
-
1
))
&&
use_last
;
double
mdisp
=
pass
.
disparity_map
[
disparity_index
][
nt
];
double
mdisp_hor
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR
][
nt
];
double
mdisp_vert
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT
][
nt
];
double
strength
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_STRENGTH_INDEX
][
nt
];
double
strength_hor
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR_STRENGTH
][
nt
];
double
strength_vert
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT_STRENGTH
][
nt
];
boolean
overexposed
=
(
max_overexposure
>
0.0
)
&&
(
pass
.
disparity_map
[
ImageDtt
.
OVEREXPOSED
]
!=
null
)
&&
(
pass
.
disparity_map
[
ImageDtt
.
OVEREXPOSED
][
nt
]
>
max_overexposure
);
if
(!
overexposed
)
{
double
adiff
=
Math
.
abs
(
mdisp
);
double
adiff_hor
=
Math
.
abs
(
mdisp_hor
);
double
adiff_vert
=
Math
.
abs
(
mdisp_vert
);
if
(
adiff
<=
trustedCorrelation
){
double
disp
=
mdisp
/
corr_magic_scale
+
pass
.
disparity
[
ty
][
tx
];
// do not consider tiles over background if they are far and initially identified as background
// if ((bg_tiles == null) || !bg_tiles[nt] || (disp >= ex_min_over)) {
if
((
disp
>=
disp_far
)
&&
(
disp
<=
disp_near
)
&&
!
Double
.
isNaN
(
adiff
)){
if
(
strength
>=
minStrength
)
{
if
(!(
adiff
>=
adiff_best
)){
// adiff_best == Double.NaN works too
adiff_best
=
adiff
;
best_index
=
ipass
;
}
quad_list
.
add
(
new
DSD
(
ipass
,
disp
,
strength
,
adiff
));
}
else
{
if
((
last
&&
(
strength
>
0.0
))
||
(!
no_weak
&&
(
strength
>
strongest_weak
))){
strongest_weak
=
strength
;
best_weak_index
=
ipass
;
}
}
}
// }
}
if
(!
Double
.
isNaN
(
minStrengthHor
)
&&
(
adiff_hor
<=
trustedCorrelation
)){
double
disp_hor
=
mdisp_hor
/
corr_magic_scale
+
pass
.
disparity
[
ty
][
tx
];
if
((
disp_hor
>=
disp_far
)
&&
(
disp_hor
<=
disp_near
)
&&
!
Double
.
isNaN
(
adiff_hor
)){
if
(
strength_hor
>=
minStrengthHor
)
{
if
(!(
adiff_hor
>=
adiff_best_hor
)){
// adiff_best == Double.NaN works too
adiff_best_hor
=
adiff_hor
;
best_index_hor
=
ipass
;
}
hor_list
.
add
(
new
DSD
(
ipass
,
disp_hor
,
strength_hor
,
adiff_hor
));
}
else
{
if
((
last
&&
(
strength_hor
>
0.0
))
||
(!
no_weak
&&
(
strength_hor
>
strongest_weak_hor
))){
strongest_weak_hor
=
strength_hor
;
best_weak_index_hor
=
ipass
;
}
}
}
}
if
(!
Double
.
isNaN
(
minStrengthVert
)
&&
(
adiff_vert
<=
trustedCorrelation
)){
double
disp_vert
=
mdisp_vert
/
corr_magic_scale
+
pass
.
disparity
[
ty
][
tx
];
if
((
disp_vert
>=
disp_far
)
&&
(
disp_vert
<=
disp_near
)
&&
!
Double
.
isNaN
(
adiff_vert
)){
if
(
strength_vert
>=
minStrengthVert
)
{
if
(!(
adiff_vert
>=
adiff_best_vert
)){
// adiff_best == Double.NaN works too
adiff_best_vert
=
adiff_vert
;
best_index_vert
=
ipass
;
}
vert_list
.
add
(
new
DSD
(
ipass
,
disp_vert
,
strength_vert
,
adiff_vert
));
}
else
{
if
((
last
&&
(
strength_vert
>
0.0
))
||
(!
no_weak
&&
(
strength_vert
>
strongest_weak_vert
))){
strongest_weak_vert
=
strength_vert
;
best_weak_index_vert
=
ipass
;
}
}
}
}
}
}
}
if
(
best_index
<
0
)
best_index
=
best_weak_index
;
if
(
best_index_hor
<
0
)
best_index_hor
=
best_weak_index_hor
;
if
(
best_index_vert
<
0
)
best_index_vert
=
best_weak_index_vert
;
//clt_parameters.gr_unique_tol
/*
private ArrayList<DSD> filterDsdList(
ArrayList<DSD> src_list,
double disp_tolerance,
int max_len,
boolean descending){ // false: disparity from far to near, true - near to far
final boolean descending = false; // disparity order in the result list
final double disparity_tolerance = 0.5; // minimal disparity to separate FG/BG
*/
if
(
quad_list
.
isEmpty
())
{
if
(
best_index
>=
0
)
{
quad_list
.
add
(
new
DSD
(
best_index
));
// only index, disparity and strength
}
}
// now quad_list contains 0, 1 for weak, 1.. num_planes for enough strong ones
quad_list
=
filterDsdList
(
quad_list
,
// ArrayList<DSD> src_list,
disparity_tolerance
,
// double disp_tolerance,
num_planes
,
// int max_len,
descending
);
// boolean descending)
for
(
int
np
=
0
;
np
<
quad_list
.
size
();
np
++)
{
CLTPass3d
pass
=
passes
.
get
(
quad_list
.
get
(
np
).
indx
);
CLTPass3d
combo_pass
=
combo_pass_list
.
get
(
np
);
combo_pass
.
tile_op
[
ty
][
tx
]
=
pass
.
tile_op
[
ty
][
tx
];
if
(
pass
.
texture_tiles
!=
null
)
{
combo_pass
.
texture_tiles
[
ty
][
tx
]
=
pass
.
texture_tiles
[
ty
][
tx
];
}
combo_pass
.
calc_disparity
[
nt
]
=
pass
.
disparity_map
[
disparity_index
][
nt
]/
corr_magic_scale
+
pass
.
disparity
[
ty
][
tx
];
combo_pass
.
strength
[
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_STRENGTH_INDEX
][
nt
];
// Only copy for full disparity
for
(
int
i
=
0
;
i
<
ImageDtt
.
QUAD
;
i
++)
combo_pass
.
disparity_map
[
ImageDtt
.
IMG_DIFF0_INDEX
+
i
][
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
IMG_DIFF0_INDEX
+
i
][
nt
];
if
(
copyDebug
){
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_CM
][
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_CM
][
nt
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_STRENGTH_INDEX
][
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_STRENGTH_INDEX
][
nt
];
}
}
// fill empty planes (if any). May be all if there were no even weak tiles (old best_index<0)
for
(
int
np
=
quad_list
.
size
();
np
<
num_planes
;
np
++)
{
CLTPass3d
combo_pass
=
combo_pass_list
.
get
(
np
);
combo_pass
.
tile_op
[
ty
][
tx
]
=
0
;
combo_pass
.
texture_tiles
[
ty
][
tx
]
=
null
;
combo_pass
.
calc_disparity
[
nt
]
=
Double
.
NaN
;
combo_pass
.
strength
[
nt
]
=
0.0
;
// Only copy for full disparity
for
(
int
i
=
0
;
i
<
ImageDtt
.
QUAD
;
i
++)
combo_pass
.
disparity_map
[
ImageDtt
.
IMG_DIFF0_INDEX
+
i
][
nt
]
=
Double
.
NaN
;
if
(
copyDebug
){
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_CM
][
nt
]
=
Double
.
NaN
;
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_STRENGTH_INDEX
][
nt
]
=
Double
.
NaN
;
}
}
// TODO: For now hor/vert are added independently and are not synchronized to full-quad correlations
if
(
hor_list
.
isEmpty
())
{
if
(
best_index_hor
>=
0
)
{
hor_list
.
add
(
new
DSD
(
best_index_hor
));
// only index, disparity and strength
}
}
// now quad_list contains 0, 1 for weak, 1.. num_planes for enough strong ones
hor_list
=
filterDsdList
(
hor_list
,
// ArrayList<DSD> src_list,
disparity_tolerance
,
// double disp_tolerance,
num_planes
,
// int max_len,
descending
);
// boolean descending)
for
(
int
np
=
0
;
np
<
hor_list
.
size
();
np
++)
{
CLTPass3d
pass
=
passes
.
get
(
hor_list
.
get
(
np
).
indx
);
CLTPass3d
combo_pass
=
combo_pass_list
.
get
(
np
);
combo_pass
.
tile_op
[
ty
][
tx
]
=
pass
.
tile_op
[
ty
][
tx
];
// just non-zero
combo_pass
.
calc_disparity_hor
[
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR
][
nt
]/
corr_magic_scale
+
pass
.
disparity
[
ty
][
tx
];
combo_pass
.
strength_hor
[
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR_STRENGTH
][
nt
];
if
(
copyDebug
){
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR
][
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR
][
nt
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR_STRENGTH
][
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR_STRENGTH
][
nt
];
}
}
// fill empty planes (if any). May be all if there were no even weak tiles (old best_index<0)
for
(
int
np
=
hor_list
.
size
();
np
<
num_planes
;
np
++)
{
CLTPass3d
combo_pass
=
combo_pass_list
.
get
(
np
);
combo_pass
.
calc_disparity_hor
[
nt
]
=
Double
.
NaN
;
combo_pass
.
strength_hor
[
nt
]
=
0.0
;
// Only copy for full disparity
for
(
int
i
=
0
;
i
<
ImageDtt
.
QUAD
;
i
++)
combo_pass
.
disparity_map
[
ImageDtt
.
IMG_DIFF0_INDEX
+
i
][
nt
]
=
Double
.
NaN
;
if
(
copyDebug
){
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR
][
nt
]
=
Double
.
NaN
;
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_HOR_STRENGTH
][
nt
]
=
0.0
;
}
}
if
(
vert_list
.
isEmpty
())
{
if
(
best_index_vert
>=
0
)
{
hor_list
.
add
(
new
DSD
(
best_index_vert
));
// only index, disparity and strength
}
}
vert_list
=
filterDsdList
(
vert_list
,
// ArrayList<DSD> src_list,
disparity_tolerance
,
// double disp_tolerance,
num_planes
,
// int max_len,
descending
);
// boolean descending)
for
(
int
np
=
0
;
np
<
vert_list
.
size
();
np
++)
{
CLTPass3d
pass
=
passes
.
get
(
vert_list
.
get
(
np
).
indx
);
CLTPass3d
combo_pass
=
combo_pass_list
.
get
(
np
);
combo_pass
.
tile_op
[
ty
][
tx
]
=
pass
.
tile_op
[
ty
][
tx
];
// just non-zero
combo_pass
.
calc_disparity_vert
[
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT
][
nt
]/
corr_magic_scale
+
pass
.
disparity
[
ty
][
tx
];
combo_pass
.
strength_vert
[
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT_STRENGTH
][
nt
];
if
(
copyDebug
){
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT
][
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT
][
nt
];
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT_STRENGTH
][
nt
]
=
pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT_STRENGTH
][
nt
];
}
}
// fill empty planes (if any). May be all if there were no even weak tiles (old best_index<0)
for
(
int
np
=
vert_list
.
size
();
np
<
num_planes
;
np
++)
{
CLTPass3d
combo_pass
=
combo_pass_list
.
get
(
np
);
combo_pass
.
calc_disparity_vert
[
nt
]
=
Double
.
NaN
;
combo_pass
.
strength_vert
[
nt
]
=
0.0
;
// Only copy for full disparity
for
(
int
i
=
0
;
i
<
ImageDtt
.
QUAD
;
i
++)
combo_pass
.
disparity_map
[
ImageDtt
.
IMG_DIFF0_INDEX
+
i
][
nt
]
=
Double
.
NaN
;
if
(
copyDebug
){
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT
][
nt
]
=
Double
.
NaN
;
combo_pass
.
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_VERT_STRENGTH
][
nt
]
=
0.0
;
}
}
// Duplicate some values from the combo_pass0 to all other passes (if any)
for
(
int
np
=
1
;
np
<
combo_pass_list
.
size
();
np
++)
{
CLTPass3d
combo_pass
=
combo_pass_list
.
get
(
np
);
combo_pass
.
max_tried_disparity
[
ty
][
tx
]
=
combo_pass0
.
max_tried_disparity
[
ty
][
tx
];
}
}
}
for
(
CLTPass3d
combo_pass
:
combo_pass_list
)
{
// getDisparity(): calc_disparity_combo = calc_disparity.clone();
combo_pass
.
getDisparity
();
// See if it does not break anything - triggers calculation if not done yet
combo_pass
.
fixNaNDisparity
();
// mostly for debug, measured disparity should be already fixed from NaN
}
return
combo_pass_list
;
}
@Deprecated
public
CLTPass3d
compositeScanOld
(
final
ArrayList
<
CLTPass3d
>
passes
,
final
int
firstPass
,
final
int
lastPassPlus1
,
final
double
trustedCorrelation
,
final
double
max_overexposure
,
final
double
disp_far
,
// limit results to the disparity range
final
double
disp_near
,
final
double
minStrength
,
final
double
minStrengthHor
,
final
double
minStrengthVert
,
final
boolean
no_weak
,
final
boolean
use_last
,
//
// TODO: when useCombo - pay attention to borders (disregard)
final
boolean
usePoly
,
// use polynomial method to find max), valid if useCombo == false
final
boolean
copyDebug
,
final
int
debugLevel
)
{
final
int
dbg_tile
=
(
debugLevel
>
0
)?
35114
:
-
1
;
// x = 122, y= 108; -1; // 27669;
CLTPass3d
combo_pass
=
new
CLTPass3d
(
this
);
...
...
@@ -1165,6 +1630,7 @@ public class TileProcessor {
return
combo_pass
;
}
/**
* Create a minimal composite scan from provided data (dual-quad rig. So no Hor/Vert
* @param disparity target disparity from the rig
...
...
@@ -2684,6 +3150,12 @@ public class TileProcessor {
public
String
[]
getScanTitles
()
{
return
SCAN_TITLES
;
}
public
String
[]
getScanTitles
(
boolean
ds_only
)
{
return
ds_only
?
SCAN_TITLES_DS
:
SCAN_TITLES
;
}
public
void
showScan
(
CLTPass3d
scan
,
String
in_title
)
...
...
@@ -2700,6 +3172,123 @@ public class TileProcessor {
System
.
out
.
println
(
"showScan("
+
title
+
"): isMeasured()="
+
scan
.
isMeasured
()+
", isProcessed()="
+
scan
.
isProcessed
()+
", isCombo()="
+
scan
.
isCombo
());
}
public
void
ShowScansSFB
(
ArrayList
<
CLTPass3d
>
scans
,
// list of composite scans
String
title
)
{
String
[]
titles
=
getScanDHVTitles
();
double
[][]
slices
=
getScanDHV
(
scans
);
(
new
ShowDoubleFloatArrays
()).
showArrays
(
slices
,
tilesX
,
tilesY
,
true
,
title
,
titles
);
}
public
String
[]
getScanDHVTitles
(){
String
[]
titles_slices
=
{
"disparity"
,
"strength"
,
"hor-disp"
,
"hor-strength"
,
"vert-disp"
,
"vert-strength"
};
String
[]
titles_planes
=
{
"strong"
,
"fg"
,
"bg"
};
String
[]
titles
=
new
String
[
titles_slices
.
length
*
titles_planes
.
length
];
for
(
int
p
=
0
;
p
<
titles_planes
.
length
;
p
++)
{
for
(
int
i
=
0
;
i
<
titles_slices
.
length
;
i
++)
{
int
n
=
p
*
titles_slices
.
length
+
i
;
titles
[
n
]
=
titles_slices
[
i
]
+
"-"
+
titles_planes
[
p
];
}
}
return
titles
;
}
public
double
[][]
getScanDHV
(
ArrayList
<
CLTPass3d
>
scans
)
// list of composite scans
{
int
[]
planes
=
{
0
,
1
,
-
1
};
double
[][][]
ds
=
new
double
[
planes
.
length
][][];
for
(
int
p
=
0
;
p
<
planes
.
length
;
p
++)
{
ds
[
p
]
=
getScanDHV
(
scans
,
planes
[
p
]);
}
double
[][]
slices
=
new
double
[
ds
[
0
].
length
*
planes
.
length
][];
for
(
int
p
=
0
;
p
<
planes
.
length
;
p
++)
{
ds
[
p
]
=
getScanDHV
(
scans
,
planes
[
p
]);
for
(
int
i
=
0
;
i
<
ds
[
p
].
length
;
i
++)
{
int
n
=
p
*
ds
[
p
].
length
+
i
;
slices
[
n
]
=
ds
[
p
][
i
];
}
}
return
slices
;
}
public
double
[][]
getScanDHV
(
CLTPass3d
scan
){
double
[][]
dhv
=
new
double
[
6
][];
dhv
[
0
]
=
scan
.
calc_disparity
;
dhv
[
1
]
=
scan
.
strength
;
dhv
[
2
]
=
scan
.
calc_disparity_hor
;
dhv
[
3
]
=
scan
.
strength_hor
;
dhv
[
4
]
=
scan
.
calc_disparity_vert
;
dhv
[
5
]
=
scan
.
strength_vert
;
return
dhv
;
}
public
double
[][]
getScanDHV
(
ArrayList
<
CLTPass3d
>
scans
,
// list of composite scans
int
plane
){
// 0 - maximal strength, 1 - foreground, 2 under FG,..., -1 - BG, -2 - over BG
double
[][][]
ds
=
new
double
[
scans
.
size
()][
6
][];
for
(
int
i
=
0
;
i
<
ds
.
length
;
i
++)
{
CLTPass3d
scan
=
scans
.
get
(
i
);
ds
[
i
][
0
]
=
scan
.
calc_disparity
;
ds
[
i
][
1
]
=
scan
.
strength
;
ds
[
i
][
2
]
=
scan
.
calc_disparity_hor
;
ds
[
i
][
3
]
=
scan
.
strength_hor
;
ds
[
i
][
4
]
=
scan
.
calc_disparity_vert
;
ds
[
i
][
5
]
=
scan
.
strength_vert
;
}
double
[][]
dhv
=
new
double
[
6
][
ds
[
0
][
0
].
length
];
int
nm
=
3
;
// number of modes - quad, hor, vert
for
(
int
m
=
0
;
m
<
nm
;
m
++)
{
int
id
=
2
*
m
;
int
is
=
id
+
1
;
for
(
int
t
=
0
;
t
<
dhv
[
id
].
length
;
t
++)
{
dhv
[
id
][
t
]
=
Double
.
NaN
;
dhv
[
is
][
t
]
=
0.0
;
if
(
plane
==
0
)
{
//find maximal strength
for
(
int
i
=
0
;
i
<
ds
.
length
;
i
++)
{
if
(
ds
[
i
][
is
][
t
]
>
dhv
[
is
][
t
])
{
dhv
[
is
][
t
]
=
ds
[
i
][
is
][
t
];
dhv
[
id
][
t
]
=
ds
[
i
][
id
][
t
];
}
}
}
else
if
(
plane
>
0
)
{
int
n
=
0
;
for
(
int
i
=
ds
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
ds
[
i
][
is
][
t
]
>
0
)
{
dhv
[
is
][
t
]
=
ds
[
i
][
is
][
t
];
dhv
[
id
][
t
]
=
ds
[
i
][
id
][
t
];
n
++;
}
if
(
n
>=
plane
)
break
;
}
}
else
{
int
n
=
0
;
for
(
int
i
=
0
;
i
<
ds
.
length
;
i
++)
{
if
(
ds
[
i
][
is
][
t
]
>
0
)
{
dhv
[
is
][
t
]
=
ds
[
i
][
is
][
t
];
dhv
[
id
][
t
]
=
ds
[
i
][
id
][
t
];
n
++;
}
if
(
n
>=
(-
plane
))
break
;
}
}
}
}
return
dhv
;
}
public
double
[][]
getShowDS
(
CLTPass3d
scan
,
boolean
force_final
)
...
...
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