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
b267218c
Commit
b267218c
authored
Apr 15, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing planes
parent
5467504f
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
4078 additions
and
2520 deletions
+4078
-2520
CLTPass3d.java
src/main/java/CLTPass3d.java
+5
-0
DisparityProcessor.java
src/main/java/DisparityProcessor.java
+54
-38
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+44
-10
Eyesis_Correction.java
src/main/java/Eyesis_Correction.java
+80
-2
QuadCLT.java
src/main/java/QuadCLT.java
+203
-6
SuperTiles.java
src/main/java/SuperTiles.java
+3056
-2370
TilePlanes.java
src/main/java/TilePlanes.java
+10
-6
TileProcessor.java
src/main/java/TileProcessor.java
+624
-85
X3dOutput.java
src/main/java/X3dOutput.java
+2
-3
No files found.
src/main/java/CLTPass3d.java
View file @
b267218c
...
...
@@ -143,10 +143,15 @@ public class CLTPass3d{
superTiles
=
null
;
}
public
boolean
[]
getSelected
(){
return
selected
;
}
public
void
setSelected
(
boolean
[]
selected
)
{
this
.
selected
=
selected
;
}
public
void
fixNaNDisparity
()
{
fixNaNDisparity
(
...
...
src/main/java/DisparityProcessor.java
View file @
b267218c
This diff is collapsed.
Click to expand it.
src/main/java/EyesisCorrectionParameters.java
View file @
b267218c
This diff is collapsed.
Click to expand it.
src/main/java/Eyesis_Correction.java
View file @
b267218c
...
...
@@ -507,6 +507,7 @@ private Panel panel1,
addButton
(
"CLT reset 3D"
,
panelClt1
,
color_stop
);
addButton
(
"CLT 3D"
,
panelClt1
,
color_conf_process
);
addButton
(
"CLT planes"
,
panelClt1
,
color_conf_process
);
addButton
(
"CLT OUT 3D"
,
panelClt1
,
color_process
);
add
(
panelClt1
);
}
...
...
@@ -4756,6 +4757,9 @@ private Panel panel1,
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
if
(
configPath
!=
null
)
{
saveTimestampedProperties
(
// save config again
configPath
,
// full path or null
...
...
@@ -4772,14 +4776,88 @@ private Panel panel1,
System
.
out
.
println
(
"QUAD_CLT is null, nothing to show"
);
return
;
}
//"CLT planes"
QUAD_CLT
.
showCLTPlanes
(
CLT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
THREADS_MAX
,
//final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
return
;
}
else
if
(
label
.
equals
(
"CLT OUT 3D"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EYESIS_CORRECTIONS
.
setDebug
(
DEBUG_LEVEL
);
if
(
QUAD_CLT
==
null
){
System
.
out
.
println
(
"QUAD_CLT is null, nothing to show (will add previous steps)"
);
return
;
}
String
configPath
=
null
;
if
(
EYESIS_CORRECTIONS
.
correctionsParameters
.
saveSettings
)
{
configPath
=
EYESIS_CORRECTIONS
.
correctionsParameters
.
selectResultsDirectory
(
true
,
true
);
if
(
configPath
==
null
){
String
msg
=
"No results directory selected, command aborted"
;
System
.
out
.
println
(
"Warning: "
+
msg
);
IJ
.
showMessage
(
"Warning"
,
msg
);
return
;
}
configPath
+=
Prefs
.
getFileSeparator
()+
"autoconfig"
;
try
{
saveTimestampedProperties
(
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
catch
(
Exception
e
){
String
msg
=
"Failed to save configuration to "
+
configPath
+
", command aborted"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
return
;
}
}
/*
public boolean output3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
*/
boolean
OK
=
QUAD_CLT
.
output3d
(
CLT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
COLOR_PROC_PARAMETERS
,
//EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
RGB_PARAMETERS
,
//EyesisCorrectionParameters.RGBParameters rgbParameters,
THREADS_MAX
,
//final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
if
(!
OK
)
{
String
msg
=
"Image data not initialized, run 'CLT 3D' command first"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
}
/*
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
*/
return
;
//
// End of buttons code
}
...
...
src/main/java/QuadCLT.java
View file @
b267218c
...
...
@@ -52,6 +52,9 @@ public class QuadCLT {
TileProcessor
tp
=
null
;
String
image_name
=
null
;
double
[][][]
image_data
=
null
;
// magic scale should be set before using TileProcessor (calculated disparities depend on it)
public
void
setTiles
(
ImagePlus
imp
,
// set tp.tilesX, tp.tilesY
...
...
@@ -4474,6 +4477,30 @@ public class QuadCLT {
}
tp
.
showPlanes
(
clt_parameters
,
geometryCorrection
,
threadsMax
,
updateStatus
,
debugLevel
);
// CLTPass3d last_scan = tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1); // get last one
}
public
void
out3d
(
EyesisCorrectionParameters
.
CLTParameters
clt_parameters
,
final
int
threadsMax
,
// maximal number of threads to launch
final
boolean
updateStatus
,
final
int
debugLevel
)
{
if
(
tp
==
null
){
System
.
out
.
println
(
"showCLTPlanes(): tp is null"
);
return
;
}
if
(
tp
.
clt_3d_passes
==
null
){
System
.
out
.
println
(
"showCLTPlanes(): tp.clt_3d_passes is null"
);
return
;
}
tp
.
showPlanes
(
clt_parameters
,
geometryCorrection
,
threadsMax
,
updateStatus
,
debugLevel
);
...
...
@@ -4683,7 +4710,7 @@ public class QuadCLT {
clt_parameters
.
colors_equalize
,
channelFiles
,
imp_srcs
,
setNames
.
get
(
nSet
),
// just for debug mess
e
ges == setNames.get(nSet)
setNames
.
get
(
nSet
),
// just for debug mess
a
ges == setNames.get(nSet)
debugLevel
);
}
// once per quad here
...
...
@@ -4740,6 +4767,11 @@ public class QuadCLT {
setTiles
(
imp_quad
[
0
],
// set global tp.tilesX, tp.tilesY
clt_parameters
,
threadsMax
);
this
.
image_name
=
name
;
this
.
image_data
=
image_data
;
tp
.
resetCLTPasses
();
tp
.
setTrustedCorrelation
(
clt_parameters
.
grow_disp_trust
);
final
int
tilesX
=
tp
.
getTilesX
();
...
...
@@ -5083,11 +5115,15 @@ public class QuadCLT {
geometryCorrection
,
threadsMax
,
// maximal number of threads to launch
updateStatus
,
2
);
// debugLevel);
0
);
//
2); // debugLevel);
// get images for predefined regions and disparities. First - with just fixed scans 1 .. list.size()
// TEMPORARY EXIT
// Save tp.clt_3d_passes.size() to roll back without restarting the program
tp
.
saveCLTPasses
();
if
(
tp
.
clt_3d_passes
.
size
()
>
0
)
{
System
.
out
.
println
(
"-------- temporary exit after secondPassSetup() ------- "
);
return
null
;
// just to fool compiler
...
...
@@ -5206,6 +5242,167 @@ public class QuadCLT {
return
imp_bgnd
;
// relative (to x3d directory) path - (String) imp_bgnd.getProperty("name");
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// public ImagePlus output3d(
public
boolean
output3d
(
EyesisCorrectionParameters
.
CLTParameters
clt_parameters
,
EyesisCorrectionParameters
.
ColorProcParameters
colorProcParameters
,
EyesisCorrectionParameters
.
RGBParameters
rgbParameters
,
final
int
threadsMax
,
// maximal number of threads to launch
final
boolean
updateStatus
,
final
int
debugLevel
)
{
final
int
tilesX
=
tp
.
getTilesX
();
final
int
tilesY
=
tp
.
getTilesY
();
if
(
this
.
image_data
==
null
){
return
false
;
}
tp
.
trimCLTPasses
();
// make possible to run this method multiple time - remove extra passes added by it last time
int
next_pass
=
tp
.
clt_3d_passes
.
size
();
//
tp
.
showScan
(
tp
.
clt_3d_passes
.
get
(
next_pass
-
1
),
// CLTPass3d scan,
"after_pass2-"
+(
next_pass
-
1
));
//String title)
tp
.
thirdPassSetup
(
// prepare tile tasks for the second pass based on the previous one(s)
clt_parameters
,
clt_parameters
.
bgnd_range
,
// double disparity_far,
clt_parameters
.
grow_disp_max
,
// other_range, //double disparity_near, //
geometryCorrection
,
threadsMax
,
// maximal number of threads to launch
updateStatus
,
0
);
// final int debugLevel)
tp
.
showScan
(
tp
.
clt_3d_passes
.
get
(
next_pass
-
1
),
// CLTPass3d scan,
"after_pass3-"
+(
next_pass
-
1
));
//String title)
// create x3d file
X3dOutput
x3dOutput
=
new
X3dOutput
(
clt_parameters
,
correctionsParameters
,
geometryCorrection
,
tp
.
clt_3d_passes
);
x3dOutput
.
generateBackground
();
String
x3d_path
=
correctionsParameters
.
selectX3dDirectory
(
true
,
// smart,
true
);
//newAllowed, // save
for
(
int
scanIndex
=
next_pass
;
scanIndex
<
tp
.
clt_3d_passes
.
size
();
scanIndex
++){
if
(
debugLevel
>
0
){
System
.
out
.
println
(
"FPGA processing scan #"
+
scanIndex
);
}
CLTPass3d
scan
=
CLTMeasure
(
// perform single pass according to prepared tiles operations and disparity
image_data
,
// first index - number of image in a quad
clt_parameters
,
scanIndex
,
threadsMax
,
// maximal number of threads to launch
updateStatus
,
debugLevel
);
/**
if ((scanIndex == 49) || (scanIndex == 54) ) tp.showScan(
scan, // tp.clt_3d_passes.get(scanIndex), // CLTPass3d scan,
"MEASURED-"+scanIndex);
*/
}
// TEMPORARY EXIT
// if (tp.clt_3d_passes.size() > 0) return null; // just to fool compiler
// int scan_limit = 10;
for
(
int
scanIndex
=
next_pass
;
(
scanIndex
<
tp
.
clt_3d_passes
.
size
())
&&
(
scanIndex
<
clt_parameters
.
max_clusters
);
scanIndex
++){
// just temporary limiting
if
(
debugLevel
>
-
1
){
System
.
out
.
println
(
"Generating cluster images (limit is set to "
+
clt_parameters
.
max_clusters
+
") largest, scan #"
+
scanIndex
);
}
// ImagePlus cluster_image = getPassImage( // get image form a single pass
String
texturePath
=
getPassImage
(
// get image from a single pass
clt_parameters
,
colorProcParameters
,
rgbParameters
,
this
.
image_name
+
"-img"
+
scanIndex
,
scanIndex
,
threadsMax
,
// maximal number of threads to launch
updateStatus
,
debugLevel
);
CLTPass3d
scan
=
tp
.
clt_3d_passes
.
get
(
scanIndex
);
if
((
scanIndex
==
73
)
)
{
tp
.
showScan
(
tp
.
clt_3d_passes
.
get
(
scanIndex
),
// CLTPass3d scan,
"SELECTED-"
+
scanIndex
);
}
// TODO: use new updated disparity, for now just what was forced for the picture
double
[]
scan_disparity
=
new
double
[
tilesX
*
tilesY
];
int
indx
=
0
;
// boolean [] scan_selected = scan.getSelected();
for
(
int
ty
=
0
;
ty
<
tilesY
;
ty
++)
for
(
int
tx
=
0
;
tx
<
tilesX
;
tx
++){
// scan_selected[indx] = scan.tile_op[ty][tx] != 0;
scan_disparity
[
indx
++]
=
scan
.
disparity
[
ty
][
tx
];
}
if
(
clt_parameters
.
avg_cluster_disp
){
double
sw
=
0.0
,
sdw
=
0.0
;
for
(
int
i
=
0
;
i
<
scan_disparity
.
length
;
i
++){
if
(
scan
.
selected
[
i
]
&&
!
scan
.
border_tiles
[
i
]){
double
w
=
scan
.
disparity_map
[
ImageDtt
.
DISPARITY_STRENGTH_INDEX
][
i
];
sw
+=
w
;
sdw
+=
scan_disparity
[
i
]*
w
;
}
}
sdw
/=
sw
;
for
(
int
i
=
0
;
i
<
scan_disparity
.
length
;
i
++){
scan_disparity
[
i
]
=
sdw
;
}
}
if
((
scanIndex
==
73
))
{
tp
.
showScan
(
tp
.
clt_3d_passes
.
get
(
scanIndex
),
// CLTPass3d scan,
"X3D-"
+
scanIndex
);
}
boolean
showTri
=
((
scanIndex
<
next_pass
+
1
)
&&
clt_parameters
.
show_triangles
)
||(
scanIndex
==
73
);
// boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 49) || (scanIndex == 54);
generateClusterX3d
(
x3dOutput
,
texturePath
,
scan
.
bounds
,
scan
.
selected
,
scan_disparity
,
// scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
clt_parameters
.
transform_size
,
clt_parameters
.
correct_distortions
,
// requires backdrop image to be corrected also
showTri
,
// (scanIndex < next_pass + 1) && clt_parameters.show_triangles,
clt_parameters
.
bgnd_range
,
// 0.3
clt_parameters
.
grow_disp_max
,
// other_range, // 2.0 'other_range - difference from the specified (*_CM)
clt_parameters
.
maxDispTriangle
);
}
// now generate and save texture files (start with full, later use bounding rectangle?)
if
(
x3d_path
!=
null
){
x3d_path
+=
Prefs
.
getFileSeparator
()+
this
.
image_name
+
".x3d"
;
x3dOutput
.
generateX3D
(
x3d_path
);
}
return
true
;
// return imp_bgnd; // relative (to x3d directory) path - (String) imp_bgnd.getProperty("name");
}
//*****************************************************************
public
void
generateClusterX3d
(
X3dOutput
x3dOutput
,
String
texturePath
,
...
...
src/main/java/SuperTiles.java
View file @
b267218c
This diff is collapsed.
Click to expand it.
src/main/java/TilePlanes.java
View file @
b267218c
...
...
@@ -764,10 +764,10 @@ public class TilePlanes {
// double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile
// double py = tileSize*(superTileSize * sTileXY[1] + superTileSize/2) + zxy[2];
double
[]
px_py
=
getCenterPxPy
();
if
((
px_py
[
0
]
==
1760
)
&&
(
px_py
[
1
]
==
1056
)){
// 27, 15
System
.
out
.
println
(
"getWorldXYZ, px_py = {"
+
px_py
[
0
]+
","
+
px_py
[
1
]+
"}"
);
debugLevel
=
2
;
}
//
if ((px_py[0] == 1760) && (px_py[1] == 1056)){ // 27, 15
//
System.out.println("getWorldXYZ, px_py = {"+px_py[0]+","+px_py[1]+"}");
//
debugLevel = 2;
//
}
double
px
=
px_py
[
0
]
+
zxy
[
1
];
double
py
=
px_py
[
1
]
+
zxy
[
2
];
...
...
@@ -780,6 +780,10 @@ public class TilePlanes {
Matrix
xyz
=
new
Matrix
(
center_xyz
,
3
);
// column matrix
Matrix
dpxpy
=
new
Matrix
(
vectors
[
0
],
3
);
// 3 rows, 1 column
if
(
debugLevel
>
0
){
// if (sTileXY[0] == 27 ){
// System.out.println("STOP");
//
// }
System
.
out
.
println
(
"getWorldXYZ("
+
sTileXY
[
0
]+
","
+
sTileXY
[
1
]+
"), correctDistortions="
+
correctDistortions
+
", xyz= {"
+
xyz
.
get
(
0
,
0
)+
","
+
xyz
.
get
(
1
,
0
)+
","
+
xyz
.
get
(
2
,
0
)+
"}, weight = "
+
getWeight
());
// xyz.print(10, 6); // w,d
...
...
@@ -842,7 +846,7 @@ public class TilePlanes {
}
norm_xyz
.
timesEquals
(
1.0
/
norm_xyz
.
normF
());
// unity normal vector;
if
(
debugLevel
>
0
){
if
(
debugLevel
>
1
){
System
.
out
.
println
(
"+getWorldXYZ("
+
sTileXY
[
0
]+
","
+
sTileXY
[
1
]+
"): unit plane normal={"
+
norm_xyz
.
get
(
0
,
0
)+
", "
+
norm_xyz
.
get
(
1
,
0
)+
", "
+
norm_xyz
.
get
(
2
,
0
)+
"})"
);
double
dotprod
=
xyz
.
transpose
().
times
(
norm_xyz
).
get
(
0
,
0
);
...
...
@@ -1070,7 +1074,7 @@ public class TilePlanes {
int
numRemoved
=
0
;
for
(;
(
pd
.
getValue
()
>
targetEigen
)
&&
(
numRemoved
<
maxRemoved
);
numRemoved
++){
if
(
debugLevel
>
2
){
System
.
out
.
println
(
"removePlaneOutliers(): numRemoved = "
+
numRemoved
+
" eigenValue = "
+
pd
.
getValue
()+
" target = "
+
targetEigen
);
System
.
out
.
println
(
"removePlaneOutliers(
"
+
sTileXY
[
0
]+
":"
+
sTileXY
[
1
]+
"
): numRemoved = "
+
numRemoved
+
" eigenValue = "
+
pd
.
getValue
()+
" target = "
+
targetEigen
);
}
// make a plane and find the worst (largest disparity difference) tile
// z = -(x*Vx + y*Vy)/Vz
...
...
src/main/java/TileProcessor.java
View file @
b267218c
This diff is collapsed.
Click to expand it.
src/main/java/X3dOutput.java
View file @
b267218c
...
...
@@ -160,10 +160,11 @@ public class X3dOutput {
Element
el_appearance
=
x3dDoc
.
createElement
(
"Appearance"
);
el_shape
.
appendChild
(
el_appearance
);
/*
Element el_material = x3dDoc.createElement("Material");
el_appearance.appendChild(el_material);
el_material.setAttribute("diffuseColor", "0.376471 0.5 0.376471");
*/
Element
el_imageTexture
=
x3dDoc
.
createElement
(
"ImageTexture"
);
el_imageTexture
.
setAttribute
(
"url"
,
url
);
...
...
@@ -182,8 +183,6 @@ public class X3dOutput {
el_texCoordinate
.
setAttribute
(
"point"
,
stcoord
);
el_IFC
.
appendChild
(
el_texCoordinate
);
}
...
...
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