Commit 9d378818 authored by Andrey Filippov's avatar Andrey Filippov

added separate hor/vert correlation results to detect vertical/horizontal features

parent e0cc40c3
......@@ -2360,6 +2360,20 @@ public class EyesisCorrections {
true, // smart,
true); //newAllowed, // save
saveAndShow(
imp,
path,
correctionsParameters.png,
show,
jpegQuality);
}
void saveAndShow(
ImagePlus imp,
String path,
boolean png,
boolean show,
int jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
if (path!=null) {
path+=Prefs.getFileSeparator()+imp.getTitle();
boolean hasAlphaHighByte = false;
......@@ -2374,7 +2388,7 @@ public class EyesisCorrections {
}
if (hasAlphaHighByte){
if (correctionsParameters.png){
if (png){
if (this.debugLevel > 0) System.out.println("Saving RGBA result to "+path+".png");
(new EyesisTiff()).savePNG_ARGB32(
imp,
......@@ -2441,27 +2455,7 @@ public class EyesisCorrections {
imp.show();
}
}
/*
private void saveAndShow(
CompositeImage compositeImage,
EyesisCorrectionParameters.ProcessParameters processParameters,
EyesisCorrectionParameters.CorrectionParameters correctionsParameters){
saveAndShow(compositeImage, processParameters, correctionsParameters , true, true);
}
private void saveAndShow(
CompositeImage compositeImage,
EyesisCorrectionParameters.ProcessParameters processParameters,
EyesisCorrectionParameters.CorrectionParameters correctionsParameters,
boolean enableSave,
boolean enableShow){
saveAndShow(
compositeImage,
correctionsParameters,
processParameters.save && enableSave,
processParameters.show && enableShow);
}
*/
private void saveAndShow(
CompositeImage compositeImage,
EyesisCorrectionParameters.CorrectionParameters correctionsParameters,
......
This diff is collapsed.
......@@ -27,6 +27,8 @@ import ij.IJ;
*/
public class GeometryCorrection {
static double SCENE_UNITS_SCALE = 0.001;
static String SCENE_UNITS_NAME = "m";
public int debugLevel = 0;
// public double azimuth; // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
// public double radius; // mm, distance from the rotation axis
......@@ -70,8 +72,8 @@ public class GeometryCorrection {
public double [][] XYZ_he; // all cameras coordinates transformed to eliminate heading and elevation (rolls preserved)
public double [][] XYZ_her = null; // XYZ of the lenses in a corrected CCS (adjusted for to elevation, heading, common_roll)
public double [][] rXY = null; // XY pairs of the in a normal plane, relative to disparityRadius
public double cameraRadius=0; // average distance from the "mass center" of the sencors to the sensors
public double disparityRadius=0; // distance between cameras to normalize disparity units to. sqrt(2)*disparityRadius for quad camera
public double cameraRadius=0; // average distance from the "mass center" of the sensors to the sensors
public double disparityRadius=0; // distance between cameras to normalize disparity units to. sqrt(2)*disparityRadius for quad camera (~=150mm)?
private double [] rByRDist=null;
private double stepR=0.001;
......@@ -307,7 +309,18 @@ public class GeometryCorrection {
// return distance from disparity (in pixel units) for the current camera geometry
public double getZFromDisparity(double disparity){
return disparity * this.focalLength * 0.001*this.pixelSize / this.disparityRadius;
return SCENE_UNITS_SCALE * this.focalLength * this.disparityRadius / (disparity * 0.001*this.pixelSize);
}
public double getFOVPix(){ // get ratio of 1 pixel X/Y to Z (distance to object)
return 0.001 * this.pixelSize / this.focalLength;
}
public double getFOVWidth(){ // get FOV ratio: width to distance
return this.pixelCorrectionWidth * 0.001 * this.pixelSize / this.focalLength;
}
public double getFOVHeight(){ // get FOV ratio: width to distance
return this.pixelCorrectionHeight * 0.001 * this.pixelSize / this.focalLength;
}
/*
......
This diff is collapsed.
......@@ -29,7 +29,10 @@ public class PolynomialApproximation {
}
S[2*N]+=wxn;
if (this.debugLevel>1){
if (data[i].length > 2)
System.out.println("polynomialApproximation1d() |"+i+"|: x=|"+data[i][0]+"| f(x)=|"+data[i][1]+"| (w=\t|"+data[i][2]+"|\t)");
else
System.out.println("polynomialApproximation1d() |"+i+"|: x=|"+data[i][0]+"| f(x)=|"+data[i][1]+"|\t)");
}
}
}
......
import java.util.ArrayList;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
**
** X3dOutput - generate x3d representation of the model
**
** Copyright (C) 2017 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** X3dOutput.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/>.
** -----------------------------------------------------------------------------**
**
*/
// Will use 1m units
public class X3dOutput {
GeometryCorrection geometry_correction;
public ArrayList <EyesisDCT.CLTPass3d> clt_3d_passes;
public EyesisCorrectionParameters.CLTParameters clt_parameters;
public EyesisCorrectionParameters.CorrectionParameters correctionsParameters;
public int debugLevel = 1;
Document x3dDoc;
Element el_X3d;
Element el_Scene;
Element el_TopGroup;
public X3dOutput(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.CorrectionParameters correctionsParameters,
GeometryCorrection geometry_correction,
ArrayList <EyesisDCT.CLTPass3d> clt_3d_passes){
this.clt_parameters = clt_parameters;
this.correctionsParameters = correctionsParameters;
this.geometry_correction = geometry_correction;
this.clt_3d_passes = clt_3d_passes;
}
// init document, bounding box, backdrop
public void generateBackground()
{
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
x3dDoc = docBuilder.newDocument();
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
}
// root elements
el_X3d = x3dDoc.createElement("x3d");
el_X3d.setAttribute("profile","Interchange");
el_X3d.setAttribute("version","3.3");
x3dDoc.appendChild(el_X3d);
el_Scene = x3dDoc.createElement("Scene");
el_X3d.appendChild(el_Scene);
el_TopGroup = x3dDoc.createElement("Group");
double [][] bbox = getBBox();
el_TopGroup.setAttribute("class","GroupTop");
el_TopGroup.setAttribute("id", "GroupTop");
el_TopGroup.setAttribute("bboxCenter", String.format("%.3f %.3f %.3f ",bbox[0][0],bbox[0][1],bbox[0][2]));
el_TopGroup.setAttribute("bboxSize", String.format("%.3f %.3f %.3f ",bbox[1][0],bbox[1][1],bbox[1][2]));
el_Scene.appendChild(el_TopGroup);
EyesisDCT.CLTPass3d bgnd_pass = clt_3d_passes.get(0);
Element el_Bgnd = x3dDoc.createElement("Background");
el_Bgnd.setAttribute("class","Background");
el_Bgnd.setAttribute("id", "Background");
el_Bgnd.setAttribute("frontUrl", bgnd_pass.texture);
// temporarily - add same picture to all other sides. Actually - any square will work, make some
// perspective grids/ colors to simplify orientation when looking wrong way
el_Bgnd.setAttribute("backUrl", bgnd_pass.texture);
el_Bgnd.setAttribute("leftUrl", bgnd_pass.texture);
el_Bgnd.setAttribute("rightUrl", bgnd_pass.texture);
el_Bgnd.setAttribute("topUrl", bgnd_pass.texture);
el_Bgnd.setAttribute("bottomUrl", bgnd_pass.texture);
el_Scene.appendChild(el_Bgnd);
}
// close document, generate x3d file
public void generateX3D(String path)
{
try {
// write the content into xml file
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(x3dDoc);
StreamResult result = new StreamResult(new File(path));
// Output to console for testing
// StreamResult result = new StreamResult(System.out);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(source, result);
System.out.println("x3d file saved to "+path);
} catch (TransformerException tfe) {
tfe.printStackTrace();
}
}
public double [][] getBBox() // center: x,y,z, size:x,y,z
{
double depth = geometry_correction.getZFromDisparity(clt_parameters.bgnd_range);
double width = depth * geometry_correction.getFOVWidth();
double height = depth * geometry_correction.getFOVHeight();
double [][] bbox = {{0, 0, depth/2},{width,height,depth}};
return bbox;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment