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
e57130aa
Commit
e57130aa
authored
Oct 10, 2021
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improving multi-tile averaging
parent
17f7b343
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1200 additions
and
298 deletions
+1200
-298
GpuQuad.java
src/main/java/com/elphel/imagej/gpu/GpuQuad.java
+119
-4
TpTask.java
src/main/java/com/elphel/imagej/gpu/TpTask.java
+17
-8
CLTPass3d.java
src/main/java/com/elphel/imagej/tileprocessor/CLTPass3d.java
+6
-1
Correlation2d.java
...n/java/com/elphel/imagej/tileprocessor/Correlation2d.java
+2
-2
ImageDttCPU.java
...ain/java/com/elphel/imagej/tileprocessor/ImageDttCPU.java
+766
-177
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+1
-0
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+281
-103
TwoQuadCLT.java
...main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
+8
-3
No files found.
src/main/java/com/elphel/imagej/gpu/GpuQuad.java
View file @
e57130aa
...
...
@@ -938,7 +938,117 @@ public class GpuQuad{ // quad camera description
return
task_list
.
toArray
(
new
TpTask
[
task_list
.
size
()]);
}
/**
* Set a single task
* @param num_cams number of sensors in a system
* @param task_code task code (need to be re-defined, currently is mostly zero/non-zero
* @param tileX integer tile X coordinate
* @param tileY integer tile X coordinate
* @param target_disparity target disparity (should include disparity_corr if used)
* @param corr_rots Array of rotational matrices, may be null, but it is more efficient to calculate it once
* @param transform_size CLT transform size (==8)
* @param geometryCorrection instance of GeometryCorrection class fro the scene
* @return TpTask instance, compatible with both CPU and GPU processing
*/
public
static
TpTask
setTask
(
int
num_cams
,
int
transform_size
,
int
task_code
,
int
tileX
,
int
tileY
,
double
target_disparity
,
// include disparity_corr
// use geometryCorrection.getCorrVector().getRotMatrices(); once per whole image set
Matrix
[]
corr_rots
,
// if null, will be calculated
GeometryCorrection
geometryCorrection
)
{
if
(
corr_rots
==
null
)
{
corr_rots
=
geometryCorrection
.
getCorrVector
().
getRotMatrices
();
// get array of per-sensor rotation matrices
}
TpTask
tp_task
=
new
TpTask
(
num_cams
,
tileX
,
tileY
);
tp_task
.
task
=
task_code
;
// double disparity = pXpYD[nTile][2] + disparity_corr;
tp_task
.
target_disparity
=
(
float
)
target_disparity
;
// will it be used?
double
centerX
=
tileX
*
transform_size
+
transform_size
/
2
;
double
centerY
=
tileY
*
transform_size
+
transform_size
/
2
;
double
[][]
disp_dist
=
new
double
[
num_cams
][];
// used to correct 3D correlations (not yet used here)
double
[][]
centersXY_main
=
geometryCorrection
.
getPortsCoordinatesAndDerivatives
(
geometryCorrection
,
// GeometryCorrection gc_main,
false
,
// boolean use_rig_offsets,
corr_rots
,
// Matrix [] rots,
null
,
// Matrix [][] deriv_rots,
null
,
// double [][] pXYderiv,
disp_dist
,
// used to correct 3D correlations
centerX
,
centerY
,
tp_task
.
target_disparity
);
// + disparity_corr);
tp_task
.
setDispDist
(
disp_dist
);
tp_task
.
xy
=
new
float
[
centersXY_main
.
length
][
2
];
for
(
int
i
=
0
;
i
<
centersXY_main
.
length
;
i
++)
{
tp_task
.
xy
[
i
][
0
]
=
(
float
)
centersXY_main
[
i
][
0
];
tp_task
.
xy
[
i
][
1
]
=
(
float
)
centersXY_main
[
i
][
1
];
}
return
tp_task
;
}
public
static
TpTask
[]
setTasks
(
final
int
num_cams
,
final
int
transform_size
,
final
double
[][]
disparity_array
,
// [tilesY][tilesX] - individual per-tile expected disparity
final
double
disparity_corr
,
final
int
[][]
tile_op
,
// [tilesY][tilesX] - what to do - 0 - nothing for this tile
final
GeometryCorrection
geometryCorrection
,
final
int
threadsMax
)
// maximal number of threads to launch
{
final
int
tilesY
=
disparity_array
.
length
;
int
tx
=
-
1
;
for
(
int
i
=
0
;
i
<
disparity_array
.
length
;
i
++)
if
(
disparity_array
[
i
]
!=
null
)
{
tx
=
disparity_array
[
i
].
length
;
break
;
}
if
(
tx
<
0
)
{
return
new
TpTask
[
0
];
}
final
int
tilesX
=
tx
;
final
Matrix
[]
corr_rots
=
geometryCorrection
.
getCorrVector
().
getRotMatrices
();
// get array of per-sensor rotation matrices
final
TpTask
[]
tp_tasks_xy
=
new
TpTask
[
tilesY
*
tilesX
];
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
anum_tiles
=
new
AtomicInteger
(
0
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
threadsMax
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
for
(
int
iTile
=
ai
.
getAndIncrement
();
iTile
<
tp_tasks_xy
.
length
;
iTile
=
ai
.
getAndIncrement
())
{
int
tileY
=
iTile
/
tilesX
;
int
tileX
=
iTile
%
tilesX
;
if
((
tile_op
[
tileY
][
tileX
]
!=
0
)
&&
!
Double
.
isNaN
(
disparity_array
[
tileY
][
tileX
]))
{
tp_tasks_xy
[
iTile
]
=
setTask
(
num_cams
,
// int num_cams,
transform_size
,
// int transform_size,
tile_op
[
tileY
][
tileX
],
// int task_code,
tileX
,
// int tileX,
tileY
,
// int tileY,
disparity_array
[
tileY
][
tileX
]
+
disparity_corr
,
// double target_disparity, // include disparity_corr
corr_rots
,
// Matrix [] corr_rots, // if null, will be calculated
geometryCorrection
);
// GeometryCorrection geometryCorrection)
anum_tiles
.
getAndIncrement
();
}
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
final
TpTask
[]
tp_tasks
=
new
TpTask
[
anum_tiles
.
get
()];
int
indx
=
0
;
for
(
int
i
=
0
;
i
<
tp_tasks_xy
.
length
;
i
++)
if
(
tp_tasks_xy
[
i
]
!=
null
)
{
tp_tasks
[
indx
++]
=
tp_tasks_xy
[
i
];
}
return
tp_tasks
;
}
/**
* Prepare contents pointers for calculation of the correlation pairs
...
...
@@ -2330,11 +2440,11 @@ public class GpuQuad{ // quad camera description
// for (int indx = ai.getAndIncrement(); indx < tp_tasks.length; indx = ai.getAndIncrement()) {
// int nTile = tile_indices[indx];
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
tiles
;
nTile
=
ai
.
getAndIncrement
())
if
(
pXpYD
[
nTile
]
!=
null
)
{
TpTask
tp_task
=
new
TpTask
();
int
tileY
=
nTile
/
tilesX
;
int
tileX
=
nTile
%
tilesX
;
tp_task
.
ty
=
tileY
;
tp_task
.
tx
=
tileX
;
TpTask
tp_task
=
new
TpTask
(
num_cams
,
tileX
,
tileY
);
// tp_task.ty = tileY;
// tp_task.tx = tileX;
tp_task
.
task
=
task_code
;
double
disparity
=
pXpYD
[
nTile
][
2
]
+
disparity_corr
;
tp_task
.
target_disparity
=
(
float
)
disparity
;
// will it be used?
...
...
@@ -2379,6 +2489,11 @@ public class GpuQuad{ // quad camera description
}
public
void
setLpfRbg
(
...
...
src/main/java/com/elphel/imagej/gpu/TpTask.java
View file @
e57130aa
package
com
.
elphel
.
imagej
.
gpu
;
public
class
TpTask
{
public
int
task
;
// [0](+1) - generate 4 images, [4..9]+16..+512 - correlation pairs, 2 - generate texture tiles
public
float
target_disparity
;
public
int
num_sensors
=
4
;
public
int
ty
;
public
int
tx
;
public
float
[][]
xy
=
null
;
public
float
[][]
xy_aux
=
null
;
public
int
task
;
// [0](+1) - generate 4 images, [4..9]+16..+512 - correlation pairs, 2 - generate texture tiles
public
float
target_disparity
;
public
int
num_sensors
=
4
;
public
int
ty
;
public
int
tx
;
public
float
[][]
xy
=
null
;
public
float
[][]
xy_aux
=
null
;
public
float
[][]
disp_dist
=
null
;
public
TpTask
()
{}
// public float weight;
public
TpTask
(
int
num_sensors
,
int
tileX
,
int
tileY
)
{
this
.
num_sensors
=
num_sensors
;
this
.
ty
=
tileY
;
this
.
tx
=
tileX
;
}
public
TpTask
(
int
num_sensors
,
int
tx
,
int
ty
,
float
target_disparity
,
int
task
)
{
this
.
tx
=
tx
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/CLTPass3d.java
View file @
e57130aa
...
...
@@ -416,6 +416,9 @@ public class CLTPass3d{
double
[]
disparity
,
double
[]
strength
)
{
if
((
disparity
==
null
)
||
(
strength
==
null
))
{
return
;
}
// depends on direction, but that is OK - just converge faster when smoothing
int
tilesX
=
tileProcessor
.
getTilesX
();
int
tilesY
=
tileProcessor
.
getTilesY
();
...
...
@@ -1000,7 +1003,9 @@ public class CLTPass3d{
{
final
double
[][]
diffs
=
getDiffs
();
if
(
diffs
==
null
)
return
null
;
for
(
int
i
=
0
;
i
<
diffs
.
length
;
i
++)
{
if
(
diffs
[
i
]
==
null
)
return
null
;
}
final
int
tilesX
=
tileProcessor
.
getTilesX
();
final
int
tilesY
=
tileProcessor
.
getTilesY
();
final
int
num_tiles
=
tilesX
*
tilesY
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/Correlation2d.java
View file @
e57130aa
...
...
@@ -3681,7 +3681,7 @@ public class Correlation2d {
boolean
adjust_ly
,
// adjust Lazy Eye
double
[][]
corr_wnd
,
// correlation window to save on re-calculation of the window
double
[]
corr_wnd_inv_limited
,
// correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
double
[][]
corrs
,
double
[][]
corrs
,
// may have more elements than pair_mask (corrs may have combo as last elements)
double
[][]
disp_dist
,
// per camera disparity matrix as a 1d (linescan order)
double
[][]
rXY
,
// non-distorted X,Y offset per nominal pixel of disparity
boolean
[]
pair_mask
,
// which pairs to process
...
...
@@ -3732,7 +3732,7 @@ public class Correlation2d {
// for (int npair = 0; npair < corrs.length; npair++) if ((corrs[npair] != null) && (((pair_mask >> npair) & 1) !=0)){
double
[][]
filtWeight
=
new
double
[
corrs
.
length
][];
for
(
int
npair
=
0
;
npair
<
corrs
.
length
;
npair
++)
if
((
corrs
[
npair
]
!=
null
)
&&
(
pair_mask
[
npair
])){
for
(
int
npair
=
0
;
npair
<
pair_mask
.
length
;
npair
++)
if
((
corrs
[
npair
]
!=
null
)
&&
(
pair_mask
[
npair
])){
// double[] corr = corrs[npair].clone();
double
[]
corr_blur
=
corrs
[
npair
].
clone
();
...
...
src/main/java/com/elphel/imagej/tileprocessor/ImageDttCPU.java
View file @
e57130aa
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
e57130aa
...
...
@@ -5465,6 +5465,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
final
float
[][][][]
fcorr_td_acc
=
new
float
[
tilesY
][
tilesX
][][];
final
int
[][][]
num_acc
=
new
int
[
tilesY
][
tilesX
][
num_pairs
];
double
fat_zero_single
=
clt_parameters
.
getGpuFatZero
(
ref_scene
.
isMonochrome
());
// for single scene
// TODO: make per-tile variable
double
scaled_fat_zero
=
fat_zero_single
/
(
scenes
.
length
);
boolean
show_accumulated_correlations
=
debug_level
>
-
5
;
boolean
show_reference_correlations
=
debug_level
>
-
5
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
e57130aa
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
View file @
e57130aa
...
...
@@ -8311,7 +8311,12 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax
,
// int threadsMax, // maximal number of threads to launch
updateStatus
,
// boolean updateStatus,
debugLevel
);
// int debugLevel)
/// quadCLTs[i].showDSIMain();
if
(
debugLevel
>
-
10
)
{
quadCLTs
[
i
].
showDSIMain
();
quadCLTs
[
i
].
testAltCorr
(
clt_parameters
,
// CLTParameters clt_parameters,
this
.
dsi
);
// double [][] dsi);
}
}
...
...
@@ -8341,10 +8346,10 @@ if (debugLevel > -100) return true; // temporarily !
System
.
out
.
println
(
"End of test"
);
}
public
void
interPairsLMA
(
QuadCLT
quadCLT_main
,
// tiles should be set
CLTParameters
clt_parameters
,
...
...
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