/*
* Copyright (c) 2011-2015, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package boofcv.gui.calibration;
import boofcv.abst.geo.calibration.ImageResults;
import boofcv.alg.geo.calibration.CalibrationObservation;
import boofcv.alg.geo.calibration.Zhang99ParamAll;
import boofcv.gui.StandardAlgConfigPanel;
import boofcv.struct.calib.IntrinsicParameters;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
/**
* GUI interface for CalibrateMonoPlanarGuiApp. Displays results for each calibration
* image in a window.
*
* @author Peter Abeles
*/
public class MonoPlanarPanel extends JPanel implements ItemListener ,
ListSelectionListener, ChangeListener
{
CalibratedImageGridPanel mainView = new CalibratedImageGridPanel();
JCheckBox checkPoints;
JCheckBox checkErrors;
JCheckBox checkUndistorted;
JCheckBox checkAll;
JCheckBox checkNumbers;
JSpinner selectErrorScale;
JList imageList;
JTextArea meanError;
JTextArea maxError;
JTextArea paramCenterX;
JTextArea paramCenterY;
JTextArea paramA;
JTextArea paramB;
JTextArea paramC;
boolean showPoints = true;
boolean showErrors = true;
boolean showUndistorted = false;
boolean showAll = false;
boolean showNumbers = true;
int selectedImage = 0;
List names = new ArrayList();
List images = new ArrayList();
List features = new ArrayList();
List results = new ArrayList();
int errorScale = 20;
public MonoPlanarPanel() {
super(new BorderLayout());
JToolBar toolBar = createToolBar();
imageList = new JList();
imageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
imageList.addListSelectionListener(this);
meanError = createErrorComponent();
maxError = createErrorComponent();
paramCenterX = createErrorComponent();
paramCenterY = createErrorComponent();
paramA = createErrorComponent();
paramB = createErrorComponent();
paramC = createErrorComponent();
mainView.setImages(images);
mainView.setResults(features,results);
mainView.setDisplay(showPoints,showErrors,showUndistorted,showAll,showNumbers,errorScale);
add(toolBar, BorderLayout.PAGE_START);
add(mainView, BorderLayout.CENTER);
add(new SideBar(), BorderLayout.WEST);
}
private JToolBar createToolBar() {
JToolBar toolBar = new JToolBar("Controls");
checkPoints = new JCheckBox("Show Points");
checkPoints.setSelected(showPoints);
checkPoints.addItemListener(this);
checkErrors = new JCheckBox("Show Errors");
checkErrors.setSelected(showErrors);
checkErrors.addItemListener(this);
checkAll = new JCheckBox("All Points");
checkAll.setSelected(showAll);
checkAll.addItemListener(this);
checkUndistorted = new JCheckBox("Undistort");
checkUndistorted.setSelected(showUndistorted);
checkUndistorted.addItemListener(this);
checkUndistorted.setEnabled(false);
checkNumbers = new JCheckBox("Numbers");
checkNumbers.setSelected(showNumbers);
checkNumbers.addItemListener(this);
selectErrorScale = new JSpinner(new SpinnerNumberModel(errorScale, 1, 100, 5));
selectErrorScale.addChangeListener(this);
selectErrorScale.setMaximumSize(selectErrorScale.getPreferredSize());
toolBar.add(checkPoints);
toolBar.add(checkErrors);
toolBar.add(checkAll);
toolBar.add(checkUndistorted);
toolBar.add(checkNumbers);
toolBar.add(new JLabel("| Error Scale"));
toolBar.add(selectErrorScale);
return toolBar;
}
private JTextArea createErrorComponent() {
JTextArea comp = new JTextArea(1,6);
comp.setMaximumSize(comp.getPreferredSize());
comp.setEditable(false);
return comp;
}
public void addImage( String name , BufferedImage image )
{
names.add(name);
images.add(image);
imageList.removeListSelectionListener(this);
imageList.setListData(new Vector
Ads help maintain this website.