Skip to content
Snippets Groups Projects
Commit 4123f32e authored by Jakub Kolman's avatar Jakub Kolman
Browse files

[#38] documentation: adding java docs

parent 83ec7a7c
No related branches found
No related tags found
No related merge requests found
...@@ -2,16 +2,11 @@ package cz.fidentis.analyst.procrustes; ...@@ -2,16 +2,11 @@ package cz.fidentis.analyst.procrustes;
import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePoint;
import cz.fidentis.analyst.icp.IcpTransformation;
import cz.fidentis.analyst.mesh.core.MeshPoint; import cz.fidentis.analyst.mesh.core.MeshPoint;
import cz.fidentis.analyst.procrustes.exceptions.ProcrustesAnalysisException; import cz.fidentis.analyst.procrustes.exceptions.ProcrustesAnalysisException;
import cz.fidentis.analyst.procrustes.utils.ProcrustesAnalysisUtils; import cz.fidentis.analyst.procrustes.utils.ProcrustesAnalysisUtils;
import org.ejml.data.Matrix;
import org.ejml.simple.SimpleMatrix; import org.ejml.simple.SimpleMatrix;
import org.ejml.simple.SimpleSVD; import org.ejml.simple.SimpleSVD;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import javax.vecmath.Point3d; import javax.vecmath.Point3d;
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cz.fidentis.analyst.procrustes; package cz.fidentis.analyst.procrustes;
import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.face.HumanFaceFactory; import cz.fidentis.analyst.face.HumanFaceFactory;
import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePoint;
import cz.fidentis.analyst.feature.services.FeaturePointCsvLoader;
import cz.fidentis.analyst.feature.services.FeaturePointExportService;
import cz.fidentis.analyst.feature.services.FeaturePointImportService; import cz.fidentis.analyst.feature.services.FeaturePointImportService;
import cz.fidentis.analyst.feature.utils.FileResourcesUtils; import cz.fidentis.analyst.feature.utils.FileResourcesUtils;
import cz.fidentis.analyst.mesh.core.MeshModel;
import cz.fidentis.analyst.mesh.io.MeshObjLoader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
/** /**
* Class used for testing procrustes analysis and converting feature point file formats.
* *
* @author Jakub Kolman * @author Jakub Kolman
*/ */
...@@ -51,9 +38,12 @@ public class ProcrustesAnalysisComparison { ...@@ -51,9 +38,12 @@ public class ProcrustesAnalysisComparison {
private static final Path OLD_HEAD_02_PATH = Paths.get( private static final Path OLD_HEAD_02_PATH = Paths.get(
"cz", "fidentis", "comparison", "procrustesAnalysis", "faces", "3points_head02_ECA.obj"); "cz", "fidentis", "comparison", "procrustesAnalysis", "faces", "3points_head02_ECA.obj");
/**
* main class used to
* @param args
* @throws IOException
* @throws URISyntaxException
*/
public static void main(String[] args) throws IOException, URISyntaxException { public static void main(String[] args) throws IOException, URISyntaxException {
FileResourcesUtils fru = new FileResourcesUtils(); FileResourcesUtils fru = new FileResourcesUtils();
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cz.fidentis.analyst.procrustes; package cz.fidentis.analyst.procrustes;
import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.face.HumanFace;
...@@ -10,7 +5,6 @@ import cz.fidentis.analyst.feature.FeaturePoint; ...@@ -10,7 +5,6 @@ import cz.fidentis.analyst.feature.FeaturePoint;
import cz.fidentis.analyst.mesh.core.MeshModel; import cz.fidentis.analyst.mesh.core.MeshModel;
import cz.fidentis.analyst.mesh.core.MeshPoint; import cz.fidentis.analyst.mesh.core.MeshPoint;
import cz.fidentis.analyst.procrustes.utils.ProcrustesAnalysisUtils; import cz.fidentis.analyst.procrustes.utils.ProcrustesAnalysisUtils;
import org.ejml.simple.SimpleMatrix;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -29,6 +23,11 @@ public class ProcrustesAnalysisFaceModel { ...@@ -29,6 +23,11 @@ public class ProcrustesAnalysisFaceModel {
private MeshModel meshModel; private MeshModel meshModel;
private final HashMap<Integer, Integer> featurePointTypeCorrespondence; private final HashMap<Integer, Integer> featurePointTypeCorrespondence;
/**
* constructor creating inner attributes used in procrustes analysis from face
*
* @param face
*/
public ProcrustesAnalysisFaceModel(HumanFace face) { public ProcrustesAnalysisFaceModel(HumanFace face) {
this.humanFace = face; this.humanFace = face;
// getFeaturePoints() returns unmodifiable List. To sort it we need to make copy first // getFeaturePoints() returns unmodifiable List. To sort it we need to make copy first
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cz.fidentis.analyst.procrustes.utils; package cz.fidentis.analyst.procrustes.utils;
import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePoint;
import cz.fidentis.analyst.feature.api.IPosition; import cz.fidentis.analyst.feature.api.IPosition;
import cz.fidentis.analyst.feature.provider.FeaturePointTypeProvider;
import cz.fidentis.analyst.mesh.core.MeshPoint;
import cz.fidentis.analyst.procrustes.ProcrustesAnalysisFaceModel; import cz.fidentis.analyst.procrustes.ProcrustesAnalysisFaceModel;
import org.ejml.simple.SimpleMatrix; import org.ejml.simple.SimpleMatrix;
import javax.vecmath.Point3d; import javax.vecmath.Point3d;
import javax.vecmath.Vector3f; import java.util.Collections;
import java.util.*; import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
/** /**
* @author Jakub Kolman * @author Jakub Kolman
......
...@@ -137,13 +137,7 @@ ...@@ -137,13 +137,7 @@
<artifactId>AbsoluteLayout</artifactId> <artifactId>AbsoluteLayout</artifactId>
<version>RELEASE123</version> <version>RELEASE123</version>
</dependency> </dependency>
<!-- http://ejml.org/wiki/index.php?title=Main_Page -->
<dependency>
<groupId>org.ejml</groupId>
<artifactId>ejml-all</artifactId>
<version>0.41</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
...@@ -14,7 +14,6 @@ import cz.fidentis.analyst.mesh.core.MeshFacet; ...@@ -14,7 +14,6 @@ import cz.fidentis.analyst.mesh.core.MeshFacet;
import cz.fidentis.analyst.mesh.core.MeshPoint; import cz.fidentis.analyst.mesh.core.MeshPoint;
import cz.fidentis.analyst.procrustes.ProcrustesAnalysis; import cz.fidentis.analyst.procrustes.ProcrustesAnalysis;
import cz.fidentis.analyst.visitors.mesh.HausdorffDistance; import cz.fidentis.analyst.visitors.mesh.HausdorffDistance;
import org.ejml.simple.SimpleMatrix;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
...@@ -30,13 +29,13 @@ import javax.vecmath.Vector3d; ...@@ -30,13 +29,13 @@ import javax.vecmath.Vector3d;
/** /**
* Action listener for the curvature computation. * Action listener for the curvature computation.
* *
* @author Richard Pajersky * @author Richard Pajersky
* @author Radek Oslejsek * @author Radek Oslejsek
* @author Daniel Schramm * @author Daniel Schramm
*/ */
public class RegistrationAction extends ControlPanelAction { public class RegistrationAction extends ControlPanelAction {
/* /*
* Attributes handling the state * Attributes handling the state
*/ */
...@@ -48,24 +47,24 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -48,24 +47,24 @@ public class RegistrationAction extends ControlPanelAction {
private String strategy = RegistrationPanel.STRATEGY_POINT_TO_POINT; private String strategy = RegistrationPanel.STRATEGY_POINT_TO_POINT;
private boolean relativeDist = false; private boolean relativeDist = false;
private boolean heatmapRender = false; private boolean heatmapRender = false;
/* /*
* Coloring threshold and statistical values of feature point distances: * Coloring threshold and statistical values of feature point distances:
*/ */
private double fpThreshold = 5.0; private double fpThreshold = 5.0;
private final RegistrationPanel controlPanel; private final RegistrationPanel controlPanel;
/** /**
* Constructor. * Constructor.
* *
* @param canvas OpenGL canvas * @param canvas OpenGL canvas
* @param topControlPanel Top component for placing control panels * @param topControlPanel Top component for placing control panels
*/ */
public RegistrationAction(Canvas canvas, JTabbedPane topControlPanel) { public RegistrationAction(Canvas canvas, JTabbedPane topControlPanel) {
super(canvas, topControlPanel); super(canvas, topControlPanel);
this.controlPanel = new RegistrationPanel(this); this.controlPanel = new RegistrationPanel(this);
// Place control panel to the topControlPanel // Place control panel to the topControlPanel
topControlPanel.addTab(controlPanel.getName(), controlPanel.getIcon(), controlPanel); topControlPanel.addTab(controlPanel.getName(), controlPanel.getIcon(), controlPanel);
topControlPanel.addChangeListener(e -> { topControlPanel.addChangeListener(e -> {
...@@ -81,14 +80,13 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -81,14 +80,13 @@ public class RegistrationAction extends ControlPanelAction {
topControlPanel.setSelectedComponent(controlPanel); // Focus registration panel topControlPanel.setSelectedComponent(controlPanel); // Focus registration panel
calculateHausdorffDistance(); calculateHausdorffDistance();
} }
@Override @Override
public void actionPerformed(ActionEvent ae) { public void actionPerformed(ActionEvent ae) {
double value; double value;
String action = ae.getActionCommand(); String action = ae.getActionCommand();
// OutputWindow.print(ae.getActionCommand()); // OutputWindow.print(ae.getActionCommand());
switch (action) { switch (action) {
case RegistrationPanel.ACTION_COMMAND_APPLY_ICP: case RegistrationPanel.ACTION_COMMAND_APPLY_ICP:
applyICP(); applyICP();
...@@ -98,7 +96,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -98,7 +96,7 @@ public class RegistrationAction extends ControlPanelAction {
setHeatmap(); setHeatmap();
break; break;
case RegistrationPanel.ACTION_COMMAND_SHIFT_X: case RegistrationPanel.ACTION_COMMAND_SHIFT_X:
value = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); value = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
getSecondaryDrawableFace().getTranslation().x = value; getSecondaryDrawableFace().getTranslation().x = value;
if (getSecondaryFeaturePoints() != null) { if (getSecondaryFeaturePoints() != null) {
getSecondaryFeaturePoints().getTranslation().x = value; getSecondaryFeaturePoints().getTranslation().x = value;
...@@ -107,7 +105,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -107,7 +105,7 @@ public class RegistrationAction extends ControlPanelAction {
//calculateHausdorffDistance(); //calculateHausdorffDistance();
break; break;
case RegistrationPanel.ACTION_COMMAND_SHIFT_Y: case RegistrationPanel.ACTION_COMMAND_SHIFT_Y:
value = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); value = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
getSecondaryDrawableFace().getTranslation().y = value; getSecondaryDrawableFace().getTranslation().y = value;
if (getSecondaryFeaturePoints() != null) { if (getSecondaryFeaturePoints() != null) {
getSecondaryFeaturePoints().getTranslation().y = value; getSecondaryFeaturePoints().getTranslation().y = value;
...@@ -116,7 +114,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -116,7 +114,7 @@ public class RegistrationAction extends ControlPanelAction {
//calculateHausdorffDistance(); //calculateHausdorffDistance();
break; break;
case RegistrationPanel.ACTION_COMMAND_SHIFT_Z: case RegistrationPanel.ACTION_COMMAND_SHIFT_Z:
value = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); value = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
getSecondaryDrawableFace().getTranslation().z = value; getSecondaryDrawableFace().getTranslation().z = value;
if (getSecondaryFeaturePoints() != null) { if (getSecondaryFeaturePoints() != null) {
getSecondaryFeaturePoints().getTranslation().z = value; getSecondaryFeaturePoints().getTranslation().z = value;
...@@ -125,7 +123,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -125,7 +123,7 @@ public class RegistrationAction extends ControlPanelAction {
//calculateHausdorffDistance(); //calculateHausdorffDistance();
break; break;
case RegistrationPanel.ACTION_COMMAND_ROTATE_X: case RegistrationPanel.ACTION_COMMAND_ROTATE_X:
value = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); value = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
getSecondaryDrawableFace().getRotation().x = value; getSecondaryDrawableFace().getRotation().x = value;
if (getSecondaryFeaturePoints() != null) { if (getSecondaryFeaturePoints() != null) {
getSecondaryFeaturePoints().getRotation().x = value; getSecondaryFeaturePoints().getRotation().x = value;
...@@ -134,7 +132,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -134,7 +132,7 @@ public class RegistrationAction extends ControlPanelAction {
//calculateHausdorffDistance(); //calculateHausdorffDistance();
break; break;
case RegistrationPanel.ACTION_COMMAND_ROTATE_Y: case RegistrationPanel.ACTION_COMMAND_ROTATE_Y:
value = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); value = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
getSecondaryDrawableFace().getRotation().y = value; getSecondaryDrawableFace().getRotation().y = value;
if (getSecondaryFeaturePoints() != null) { if (getSecondaryFeaturePoints() != null) {
getSecondaryFeaturePoints().getRotation().y = value; getSecondaryFeaturePoints().getRotation().y = value;
...@@ -143,7 +141,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -143,7 +141,7 @@ public class RegistrationAction extends ControlPanelAction {
//calculateHausdorffDistance(); //calculateHausdorffDistance();
break; break;
case RegistrationPanel.ACTION_COMMAND_ROTATE_Z: case RegistrationPanel.ACTION_COMMAND_ROTATE_Z:
value = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); value = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
getSecondaryDrawableFace().getRotation().z = value; getSecondaryDrawableFace().getRotation().z = value;
if (getSecondaryFeaturePoints() != null) { if (getSecondaryFeaturePoints() != null) {
getSecondaryFeaturePoints().getRotation().z = value; getSecondaryFeaturePoints().getRotation().z = value;
...@@ -152,7 +150,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -152,7 +150,7 @@ public class RegistrationAction extends ControlPanelAction {
//calculateHausdorffDistance(); //calculateHausdorffDistance();
break; break;
case RegistrationPanel.ACTION_COMMAND_SCALE: case RegistrationPanel.ACTION_COMMAND_SCALE:
value = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); value = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
getSecondaryDrawableFace().getScale().x = value; getSecondaryDrawableFace().getScale().x = value;
getSecondaryDrawableFace().getScale().y = value; getSecondaryDrawableFace().getScale().y = value;
getSecondaryDrawableFace().getScale().z = value; getSecondaryDrawableFace().getScale().z = value;
...@@ -212,20 +210,20 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -212,20 +210,20 @@ public class RegistrationAction extends ControlPanelAction {
setTransparency(transparency); setTransparency(transparency);
break; break;
case RegistrationPanel.ACTION_COMMAND_FP_CLOSENESS_THRESHOLD: case RegistrationPanel.ACTION_COMMAND_FP_CLOSENESS_THRESHOLD:
fpThreshold = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); fpThreshold = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
calculateFeaturePoints(); calculateFeaturePoints();
break; break;
case RegistrationPanel.ACTION_COMMAND_ICP_SCALE: case RegistrationPanel.ACTION_COMMAND_ICP_SCALE:
this.scale = ((JCheckBox) ae.getSource()).isSelected(); this.scale = ((JCheckBox) ae.getSource()).isSelected();
break; break;
case RegistrationPanel.ACTION_COMMAND_ICP_MAX_ITERATIONS: case RegistrationPanel.ACTION_COMMAND_ICP_MAX_ITERATIONS:
maxIterations = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).intValue(); maxIterations = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).intValue();
break; break;
case RegistrationPanel.ACTION_COMMAND_ICP_ERROR: case RegistrationPanel.ACTION_COMMAND_ICP_ERROR:
error = ((Number)(((JFormattedTextField) ae.getSource()).getValue())).doubleValue(); error = ((Number) (((JFormattedTextField) ae.getSource()).getValue())).doubleValue();
break; break;
case RegistrationPanel.ACTION_COMMAND_ICP_UNDERSAMPLING: case RegistrationPanel.ACTION_COMMAND_ICP_UNDERSAMPLING:
String item = (String)((JComboBox) ae.getSource()).getSelectedItem(); String item = (String) ((JComboBox) ae.getSource()).getSelectedItem();
switch (item) { switch (item) {
case "None": case "None":
this.undersampling = new NoUndersampling(); this.undersampling = new NoUndersampling();
...@@ -259,14 +257,15 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -259,14 +257,15 @@ public class RegistrationAction extends ControlPanelAction {
initiateProcrustesAnalysis(); initiateProcrustesAnalysis();
break; break;
default: default:
// to nothing // to nothing
} }
renderScene(); renderScene();
} }
protected void initiateProcrustesAnalysis() { protected void initiateProcrustesAnalysis() {
OutputWindow.print("Procrustes Analysis"); Logger.print("Procrustes Analysis");
Logger out = Logger.measureTime();
HumanFace primaryFace = getScene().getHumanFace(0); HumanFace primaryFace = getScene().getHumanFace(0);
HumanFace secondaryFace = getScene().getHumanFace(1); HumanFace secondaryFace = getScene().getHumanFace(1);
...@@ -275,15 +274,24 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -275,15 +274,24 @@ public class RegistrationAction extends ControlPanelAction {
procrustesAnalysisInit.analyze(); procrustesAnalysisInit.analyze();
calculateFeaturePoints(); calculateFeaturePoints();
calculateHausdorffDistance(); calculateHausdorffDistance();
out.printDuration("Computation of Procrustes for models with "
+ getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ "/"
+ getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ " vertices and "
+ getPrimaryDrawableFace().getHumanFace().getFeaturePoints().size()
+ "feature points"
);
} }
protected void applyICP() { protected void applyICP() {
Logger out = Logger.measureTime(); Logger out = Logger.measureTime();
IcpTransformer visitor = new IcpTransformer(getPrimaryDrawableFace().getModel(), maxIterations, scale, error, undersampling); IcpTransformer visitor = new IcpTransformer(getPrimaryDrawableFace().getModel(), maxIterations, scale, error, undersampling);
getSecondaryDrawableFace().getModel().compute(visitor); // NOTE: the secondary face is physically transformed getSecondaryDrawableFace().getModel().compute(visitor); // NOTE: the secondary face is physically transformed
for (List<IcpTransformation> trList: visitor.getTransformations().values()) { for (List<IcpTransformation> trList : visitor.getTransformations().values()) {
for (IcpTransformation tr: trList) { for (IcpTransformation tr : trList) {
for (int i = 0; i < getSecondaryFeaturePoints().getFeaturePoints().size(); i++) { for (int i = 0; i < getSecondaryFeaturePoints().getFeaturePoints().size(); i++) {
FeaturePoint fp = getSecondaryFeaturePoints().getFeaturePoints().get(i); FeaturePoint fp = getSecondaryFeaturePoints().getFeaturePoints().get(i);
Point3d trPoint = tr.transformPoint(fp.getPosition(), scale); Point3d trPoint = tr.transformPoint(fp.getPosition(), scale);
...@@ -291,18 +299,20 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -291,18 +299,20 @@ public class RegistrationAction extends ControlPanelAction {
} }
} }
} }
out.printDuration("Computation of ICP for models with " out.printDuration("Computation of ICP for models with "
+ getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ "/" + "/"
+ getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ " vertices" + " vertices"
); );
} }
/** /**
* Sets the transparency of {@link #getPrimaryDrawableFace} or {@link #getSecondaryDrawableFace()} * Sets the transparency of {@link #getPrimaryDrawableFace} or
* based on the inputted value and {@link @TRANSPARENCY_RANGE} * {@link #getSecondaryDrawableFace()} based on the inputted value and
* {@link @TRANSPARENCY_RANGE}
*
* @param value Value * @param value Value
*/ */
private void setTransparency(int value) { private void setTransparency(int value) {
...@@ -319,25 +329,24 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -319,25 +329,24 @@ public class RegistrationAction extends ControlPanelAction {
getSecondaryDrawableFace().setTransparency((2 * RegistrationPanel.TRANSPARENCY_RANGE - value) / 10f); getSecondaryDrawableFace().setTransparency((2 * RegistrationPanel.TRANSPARENCY_RANGE - value) / 10f);
} }
} }
/** /**
* Calculates feature points which are too far away * Calculates feature points which are too far away and changes their color
* and changes their color to green * to green otherwise set color to default
* otherwise set color to default
*/ */
private void calculateFeaturePoints() { private void calculateFeaturePoints() {
Logger.print("Calculation of feature points"); Logger.print("Calculation of feature points");
if (getPrimaryDrawableFace() == null) { // scene not yet initiated if (getPrimaryDrawableFace() == null) { // scene not yet initiated
return; return;
} }
if (getPrimaryFeaturePoints() == null || if (getPrimaryFeaturePoints() == null
getSecondaryFeaturePoints() == null || || getSecondaryFeaturePoints() == null
getPrimaryFeaturePoints().getFeaturePoints().size() != getSecondaryFeaturePoints().getFeaturePoints().size()) { || getPrimaryFeaturePoints().getFeaturePoints().size() != getSecondaryFeaturePoints().getFeaturePoints().size()) {
return; return;
} }
double fpMaxDist = Double.NEGATIVE_INFINITY; double fpMaxDist = Double.NEGATIVE_INFINITY;
double fpMinDist = Double.POSITIVE_INFINITY; double fpMinDist = Double.POSITIVE_INFINITY;
double distSum = 0.0; double distSum = 0.0;
...@@ -347,9 +356,9 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -347,9 +356,9 @@ public class RegistrationAction extends ControlPanelAction {
Point3d transformed = new Point3d(secondary.getX(), secondary.getY(), secondary.getZ()); Point3d transformed = new Point3d(secondary.getX(), secondary.getY(), secondary.getZ());
transformPoint(transformed); transformPoint(transformed);
double distance = Math.sqrt( double distance = Math.sqrt(
Math.pow(transformed.x - primary.getX(), 2) + Math.pow(transformed.x - primary.getX(), 2)
Math.pow(transformed.y - primary.getY(), 2) + + Math.pow(transformed.y - primary.getY(), 2)
Math.pow(transformed.z - primary.getZ(), 2)); + Math.pow(transformed.z - primary.getZ(), 2));
if (distance > fpThreshold) { if (distance > fpThreshold) {
getPrimaryFeaturePoints().resetColorToDefault(i); getPrimaryFeaturePoints().resetColorToDefault(i);
getSecondaryFeaturePoints().resetColorToDefault(i); getSecondaryFeaturePoints().resetColorToDefault(i);
...@@ -364,27 +373,27 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -364,27 +373,27 @@ public class RegistrationAction extends ControlPanelAction {
double fpAvgDist = distSum / getPrimaryFeaturePoints().getFeaturePoints().size(); double fpAvgDist = distSum / getPrimaryFeaturePoints().getFeaturePoints().size();
this.controlPanel.updateFPStats(fpAvgDist, fpMaxDist, fpMinDist); this.controlPanel.updateFPStats(fpAvgDist, fpMaxDist, fpMinDist);
} }
private void calculateHausdorffDistance() { private void calculateHausdorffDistance() {
Logger out = Logger.measureTime(); Logger out = Logger.measureTime();
HumanFace primFace = getScene().getHumanFace(0); HumanFace primFace = getScene().getHumanFace(0);
primFace.computeKdTree(false); primFace.computeKdTree(false);
HausdorffDistance hd = new HausdorffDistance(primFace.getKdTree(), HausdorffDistance.Strategy.POINT_TO_POINT_DISTANCE_ONLY, false, true); HausdorffDistance hd = new HausdorffDistance(primFace.getKdTree(), HausdorffDistance.Strategy.POINT_TO_POINT_DISTANCE_ONLY, false, true);
getScene().getHumanFace(1).getMeshModel().compute(hd); getScene().getHumanFace(1).getMeshModel().compute(hd);
out.printDuration("Computation of Hausdorff distance for models with " out.printDuration("Computation of Hausdorff distance for models with "
+ getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ "/" + "/"
+ getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ " vertices" + " vertices"
); );
double min = Double.POSITIVE_INFINITY; double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY; double max = Double.NEGATIVE_INFINITY;
double sum = 0; double sum = 0;
int count = 0; int count = 0;
for (List<Double> distList: hd.getDistances().values()) { for (List<Double> distList : hd.getDistances().values()) {
for (double dist : distList) { for (double dist : distList) {
min = Math.min(min, dist); min = Math.min(min, dist);
max = Math.max(max, dist); max = Math.max(max, dist);
...@@ -392,14 +401,14 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -392,14 +401,14 @@ public class RegistrationAction extends ControlPanelAction {
count++; count++;
} }
} }
this.controlPanel.updateHDStats(sum/count, max, min); this.controlPanel.updateHDStats(sum / count, max, min);
} }
/** /**
* Applies carried out transformations * Applies carried out transformations first on
* first on {@link #getSecondaryDrawableFace} * {@link #getSecondaryDrawableFace} and then on
* and then on {@link #getSecondaryDrawableFace} feature points * {@link #getSecondaryDrawableFace} feature points
*/ */
private void transformFace() { private void transformFace() {
for (MeshFacet transformedFacet : getSecondaryDrawableFace().getFacets()) { for (MeshFacet transformedFacet : getSecondaryDrawableFace().getFacets()) {
...@@ -415,10 +424,11 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -415,10 +424,11 @@ public class RegistrationAction extends ControlPanelAction {
getSecondaryFeaturePoints().getFeaturePoints().set(i, point); getSecondaryFeaturePoints().getFeaturePoints().set(i, point);
} }
} }
/** /**
* Transforms point based on transformation info from {@link #getSecondaryDrawableFace} * Transforms point based on transformation info from
* * {@link #getSecondaryDrawableFace}
*
* @param point Point to transform * @param point Point to transform
*/ */
private void transformPoint(Point3d point) { private void transformPoint(Point3d point) {
...@@ -472,7 +482,7 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -472,7 +482,7 @@ public class RegistrationAction extends ControlPanelAction {
point.y *= 1 + getSecondaryDrawableFace().getScale().y; point.y *= 1 + getSecondaryDrawableFace().getScale().y;
point.z *= 1 + getSecondaryDrawableFace().getScale().z; point.z *= 1 + getSecondaryDrawableFace().getScale().z;
} }
protected void setHeatmap() { protected void setHeatmap() {
HausdorffDistance.Strategy useStrategy; HausdorffDistance.Strategy useStrategy;
switch (strategy) { switch (strategy) {
...@@ -485,22 +495,22 @@ public class RegistrationAction extends ControlPanelAction { ...@@ -485,22 +495,22 @@ public class RegistrationAction extends ControlPanelAction {
default: default:
throw new UnsupportedOperationException(strategy); throw new UnsupportedOperationException(strategy);
} }
if (hdVisitor == null) { if (hdVisitor == null) {
Logger out = Logger.measureTime(); Logger out = Logger.measureTime();
this.hdVisitor = new HausdorffDistance(getPrimaryDrawableFace().getModel(), useStrategy, relativeDist, true); this.hdVisitor = new HausdorffDistance(getPrimaryDrawableFace().getModel(), useStrategy, relativeDist, true);
getSecondaryDrawableFace().getModel().compute(hdVisitor); getSecondaryDrawableFace().getModel().compute(hdVisitor);
out.printDuration("Computation of Hausdorff distance for models with " out.printDuration("Computation of Hausdorff distance for models with "
+ getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + getPrimaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ "/" + "/"
+ getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices() + getSecondaryDrawableFace().getHumanFace().getMeshModel().getNumVertices()
+ " vertices" + " vertices"
); );
} }
getSecondaryDrawableFace().setHeatMap(hdVisitor.getDistances()); getSecondaryDrawableFace().setHeatMap(hdVisitor.getDistances());
} }
} }
...@@ -13,6 +13,12 @@ import javax.vecmath.Point3d; ...@@ -13,6 +13,12 @@ import javax.vecmath.Point3d;
* @author Jakub Kolman * @author Jakub Kolman
*/ */
public interface IPosition { public interface IPosition {
/**
* get position of Point3d object
*
* @return position of Point3d object
*/
Point3d getPosition(); Point3d getPosition();
default double getX() { default double getX() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment