Commit 340188d0 authored by Jan Smid's avatar Jan Smid
Browse files

[multi_face_heatmap] Adds ICP and Procrustes face registration support

parent 8844018d
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -34,6 +35,15 @@ public final class MultiComparisonPanel extends ControlPanel {
    /** Action command for metric changed. */
    public static final String ACTION_METRIC_CHANGED = "metricChanged";

    /** Action command for register all. */
    public static final String ACTION_REGISTER_ALL = "registerAll";

    /** Available registration methods. */
    public static final String[] REGISTRATION_METHODS = {
            "ICP (mesh-based)",
            "Procrustes (landmarks)"
    };

    private static final int GAP_SMALL = 5;
    private static final int GAP_MEDIUM = 10;
    private static final int GAP_LARGE = 15;
@@ -44,6 +54,9 @@ public final class MultiComparisonPanel extends ControlPanel {
    private final JToggleButton computeButton = new JToggleButton("Compute");
    private final JComboBox<VariationMetric> metricSelector =
            new JComboBox<>(VariationMetric.values());
    private final JComboBox<String> registrationMethodSelector =
            new JComboBox<>(REGISTRATION_METHODS);
    private final JButton registerAllButton = new JButton("Register All");

    /**
     * Constructor.
@@ -90,6 +103,16 @@ public final class MultiComparisonPanel extends ControlPanel {
        metricSelector.setEnabled(enabled);
    }

    /**
     * Enables or disables registration controls.
     *
     * @param enabled true to enable, false to disable
     */
    public void setRegistrationEnabled(final boolean enabled) {
        registerAllButton.setEnabled(enabled);
        registrationMethodSelector.setEnabled(enabled);
    }

    /**
     * Returns the selected variation metric.
     *
@@ -99,6 +122,24 @@ public final class MultiComparisonPanel extends ControlPanel {
        return (VariationMetric) metricSelector.getSelectedItem();
    }

    /**
     * Returns the selected registration method name.
     *
     * @return the selected registration method
     */
    public String getSelectedRegistrationMethod() {
        return (String) registrationMethodSelector.getSelectedItem();
    }

    /**
     * Checks if ICP registration method is selected.
     *
     * @return true if ICP is selected, false for Procrustes
     */
    public boolean isIcpSelected() {
        return REGISTRATION_METHODS[0].equals(getSelectedRegistrationMethod());
    }

    private void initComponents() {
        setLayout(new BorderLayout(GAP_MEDIUM, GAP_MEDIUM));
        setBorder(BorderFactory.createEmptyBorder(
@@ -114,6 +155,19 @@ public final class MultiComparisonPanel extends ControlPanel {
        topPanel.add(titleLabel);
        topPanel.add(Box.createVerticalStrut(GAP_LARGE));

        JPanel registrationPanel = new JPanel(
                new FlowLayout(FlowLayout.CENTER, GAP_MEDIUM, GAP_SMALL));
        registrationPanel.setBorder(
                BorderFactory.createTitledBorder("Registration"));
        registrationPanel.add(registrationMethodSelector);
        registerAllButton.setToolTipText(
                "Register all faces to the template (first face)");
        registerAllButton.addActionListener(
                createListener(getActionListener(), ACTION_REGISTER_ALL));
        registrationPanel.add(registerAllButton);
        topPanel.add(registrationPanel);
        topPanel.add(Box.createVerticalStrut(GAP_MEDIUM));

        JPanel metricPanel = new JPanel(
                new FlowLayout(FlowLayout.CENTER, GAP_MEDIUM, GAP_SMALL));
        metricPanel.setBorder(