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
ca08b513
Commit
ca08b513
authored
Sep 12, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started textured model
parent
951a84a6
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
641 additions
and
1 deletion
+641
-1
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+77
-0
TexturedModel.java
...n/java/com/elphel/imagej/tileprocessor/TexturedModel.java
+444
-0
TileCluster.java
...ain/java/com/elphel/imagej/tileprocessor/TileCluster.java
+106
-0
TileNeibs.java
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
+14
-1
No files found.
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
ca08b513
...
...
@@ -5378,6 +5378,83 @@ public class OpticalFlow {
}
// for (int mode3d = 0; mode3d<generate_modes3d.length; mode3d++) if (generate_modes3d[mode3d]) {
}
// if (generate_mapped) {
// debugging 3D model
boolean
build_textured3d
=
true
;
double
textured_disp_adiffo
=
0.3
;
double
textured_disp_rdiffo
=
0.1
;
double
textured_disp_adiffd
=
0.4
;
double
textured_disp_rdiffd
=
0.12
;
double
textured_disp_fof
=
1.5
;
double
min_fg_bg
=
0.1
;
// NaN bg if difference from FG < this
if
(
build_textured3d
)
{
int
tilesX
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTilesX
();
int
tilesY
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTilesY
();
if
(
combo_dsn_final
==
null
)
{
combo_dsn_final
=
quadCLTs
[
ref_index
].
readDoubleArrayFromModelDirectory
(
"-INTER-INTRA-LMA"
,
// String suffix,
0
,
// int num_slices, // (0 - all)
null
);
// int [] wh);
}
boolean
[]
sky_tiles
=
new
boolean
[
combo_dsn_final
[
COMBO_DSN_INDX_BLUE_SKY
].
length
];
boolean
[]
sky_invert
=
new
boolean
[
combo_dsn_final
[
COMBO_DSN_INDX_BLUE_SKY
].
length
];
for
(
int
i
=
0
;
i
<
sky_tiles
.
length
;
i
++)
{
sky_tiles
[
i
]
=
combo_dsn_final
[
COMBO_DSN_INDX_BLUE_SKY
][
i
]
>
0.0
;
sky_invert
[
i
]
=
!
sky_tiles
[
i
];
}
// re-load , should create quadCLTs[ref_index].dsi
double
[][]
dls_fg
=
{
combo_dsn_final
[
COMBO_DSN_INDX_DISP
],
combo_dsn_final
[
COMBO_DSN_INDX_LMA
],
combo_dsn_final
[
COMBO_DSN_INDX_STRENGTH
]
};
double
[][]
ds_fg
=
conditionInitialDS
(
true
,
// boolean use_conf, // use configuration parameters, false - use following
clt_parameters
,
// CLTParameters clt_parameters,
dls_fg
,
// double [][] dls
quadCLTs
[
ref_index
],
// QuadCLT scene,
debugLevel
);
// int debug_level)
double
[][]
dls_bg
=
{
combo_dsn_final
[
COMBO_DSN_INDX_DISP_BG
].
clone
(),
combo_dsn_final
[
COMBO_DSN_INDX_LMA_BG
].
clone
(),
combo_dsn_final
[
COMBO_DSN_INDX_STRENGTH_BG
].
clone
()
};
for
(
int
i
=
0
;
i
<
sky_tiles
.
length
;
i
++)
if
(
Double
.
isNaN
(
dls_bg
[
0
][
i
])){
dls_bg
[
0
][
i
]
=
dls_fg
[
0
][
i
];
dls_bg
[
1
][
i
]
=
dls_fg
[
1
][
i
];
dls_bg
[
2
][
i
]
=
dls_fg
[
2
][
i
];
}
double
[][]
ds_bg
=
conditionInitialDS
(
true
,
// boolean use_conf, // use configuration parameters, false - use following
clt_parameters
,
// CLTParameters clt_parameters,
dls_bg
,
// double [][] dls
quadCLTs
[
ref_index
],
// QuadCLT scene,
debugLevel
);
// int debug_level)
// double[][] ds_fg_bg = {ds_fg[0], ds_bg[0]};
double
[][]
ds_fg_bg
=
{
ds_fg
[
0
],
ds_bg
[
0
].
clone
()};
for
(
int
i
=
0
;
i
<
sky_tiles
.
length
;
i
++)
{
if
(
Math
.
abs
(
ds_fg_bg
[
1
][
i
]-
ds_fg_bg
[
0
][
i
])
<
min_fg_bg
)
{
ds_fg_bg
[
1
][
i
]
=
Double
.
NaN
;
}
}
TileCluster
[]
tileCluster
=
TexturedModel
.
clusterizeFgBg
(
// wrong result type, not decided
tilesX
,
// final int tilesX,
ds_fg_bg
,
// final double [][] disparities, // may have more layers
sky_invert
,
// final boolean [] selected, // to remove sky (pre-filter by caller, like for ML?)
textured_disp_adiffo
,
// final double disp_adiffo,
textured_disp_rdiffo
,
// final double disp_rdiffo,
textured_disp_adiffd
,
// final double disp_adiffd,
textured_disp_rdiffd
,
// final double disp_rdiffd,
textured_disp_fof
,
// final double disp_fof, // enable higher difference (scale) for fried of a friend
1
);
// 2); // final int debugLevel)
System
.
out
.
println
(
"clusterizeFgBg() produces "
+
tileCluster
.
length
+
" cluster layers"
);
System
.
out
.
println
(
"clusterizeFgBg() produces "
+
tileCluster
.
length
+
" cluster layers"
);
}
if
(
export_images
)
{
if
(
combo_dsn_final
==
null
)
{
combo_dsn_final
=
quadCLTs
[
ref_index
].
readDoubleArrayFromModelDirectory
(
...
...
src/main/java/com/elphel/imagej/tileprocessor/TexturedModel.java
0 → 100644
View file @
ca08b513
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/TileCluster.java
0 → 100644
View file @
ca08b513
package
com
.
elphel
.
imagej
.
tileprocessor
;
/**
** TileCluster - clusters from disparity map to generate textured mesh
**
** Copyright (C) 2017 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** TileCluster.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
import
java.awt.Rectangle
;
import
java.util.Arrays
;
class
TileCluster
{
Rectangle
bounds
;
boolean
[]
border
;
double
[]
disparity
;
public
TileCluster
(
Rectangle
bounds
,
boolean
[]
border
,
double
[]
disparity
){
this
.
bounds
=
bounds
;
if
(
border
==
null
)
{
border
=
new
boolean
[
bounds
.
width
*
bounds
.
height
];
}
this
.
border
=
border
;
if
(
disparity
==
null
)
{
disparity
=
new
double
[
bounds
.
width
*
bounds
.
height
];
Arrays
.
fill
(
disparity
,
Double
.
NaN
);
}
this
.
disparity
=
disparity
;
}
public
Rectangle
getBounds
()
{
return
bounds
;}
public
boolean
[]
getBorder
()
{
return
border
;}
public
double
[]
getDisparity
()
{
return
disparity
;}
/*
public TileCluster combine (TileCluster tileCluster) {
TileCluster outer, inner;
if (bounds.contains(tileCluster.bounds)) {
outer = this;
inner = tileCluster;
} else if (tileCluster.bounds.contains(bounds)) {
outer = tileCluster;
inner = this;
} else {
Rectangle outer_bounds = bounds.union(tileCluster.bounds);
outer = new TileCluster(outer_bounds, null, null);
outer.combine(this); //
inner = tileCluster;
}
int dst_x = inner.bounds.x - outer.bounds.x;
for (int src_y = 0; src_y < bounds.height; src_y++) {
int dst_y = src_y + inner.bounds.y - outer.bounds.y;
System.arraycopy(
inner.border,
src_y * bounds.width,
outer.border,
dst_y * outer.bounds.width + dst_x,
bounds.width);
System.arraycopy(
inner.disparity,
src_y * bounds.width,
outer.disparity,
dst_y * outer.bounds.width + dst_x,
bounds.width);
}
return outer;
}
*/
public
void
add
(
TileCluster
tileCluster
)
{
if
(!
bounds
.
contains
(
tileCluster
.
bounds
))
{
throw
new
IllegalArgumentException
(
"TileCluster.add(): Added cluster should fit into this "
);
}
int
dst_x
=
tileCluster
.
bounds
.
x
-
bounds
.
x
;
for
(
int
src_y
=
0
;
src_y
<
tileCluster
.
bounds
.
height
;
src_y
++)
{
int
dst_y
=
src_y
+
tileCluster
.
bounds
.
y
-
bounds
.
y
;
System
.
arraycopy
(
tileCluster
.
border
,
src_y
*
tileCluster
.
bounds
.
width
,
border
,
dst_y
*
bounds
.
width
+
dst_x
,
tileCluster
.
bounds
.
width
);
System
.
arraycopy
(
tileCluster
.
disparity
,
src_y
*
tileCluster
.
bounds
.
width
,
disparity
,
dst_y
*
bounds
.
width
+
dst_x
,
tileCluster
.
bounds
.
width
);
}
return
;
}
}
\ No newline at end of file
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
View file @
ca08b513
...
...
@@ -39,10 +39,17 @@ public class TileNeibs{
final
public
static
int
DIR_LEFT
=
2
;
// Right
final
public
static
int
DIR_DOWN
=
4
;
// Down
final
public
static
int
DIR_RIGHT
=
6
;
// Left
final
public
static
int
DIRS
=
8
;
// total dirs
public
static
int
reverseDir
(
int
dir
)
{
if
((
dir
<
0
)
||
(
dir
>=
DIRS
))
{
return
dir
;
}
return
(
dir
+
DIRS
/
2
)
%
DIRS
;
}
int
sizeX
;
int
sizeY
;
public
int
dirs
=
8
;
public
int
dirs
=
DIRS
;
public
TileNeibs
(
int
size
){
this
.
sizeX
=
size
;
this
.
sizeY
=
size
;
...
...
@@ -63,6 +70,12 @@ public class TileNeibs{
return
sizeX
*
sizeY
;
}
boolean
isBorder
(
int
indx
)
{
int
[]
xy
=
{
indx
%
sizeX
,
indx
/
sizeX
};
return
(
xy
[
0
]==
0
)
||
(
xy
[
1
]==
0
)
||
(
xy
[
0
]==
(
sizeX
-
1
))
||
(
xy
[
1
]==(
sizeY
-
1
));
}
/**
* Get x,y pair from index
* @param indx element index
...
...
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