/*
* 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.demonstrations.calibration;
import boofcv.abst.geo.calibration.ImageResults;
import boofcv.alg.geo.calibration.CalibrationObservation;
import boofcv.gui.StandardAlgConfigPanel;
import boofcv.gui.calibration.CalibratedImageGridPanel;
import boofcv.struct.calib.IntrinsicParameters;
import org.ejml.data.DenseMatrix64F;
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.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
/**
* Panel for displaying information on observed calibration grids during the calibration process.
*
* @author Peter Abeles
*/
public class StereoPlanarPanel extends JPanel
implements ListSelectionListener, ItemListener, ChangeListener, MouseListener
{
// display for calibration information on individual cameras
CalibratedImageGridPanel leftView = new CalibratedImageGridPanel();
CalibratedImageGridPanel rightView = new CalibratedImageGridPanel();
// list of images and calibration results
List listLeft = new ArrayList();
List listRight = new ArrayList();
List leftResults;
List rightResults;
// GUI components
JCheckBox checkPoints;
JCheckBox checkErrors;
JCheckBox checkUndistorted;
JCheckBox checkAll;
JCheckBox checkNumbers;
JSpinner selectErrorScale;
JTextArea meanErrorLeft;
JTextArea maxErrorLeft;
JTextArea meanErrorRight;
JTextArea maxErrorRight;
JList imageList;
List names = new ArrayList();
int selectedImage;
boolean showPoints = true;
boolean showErrors = true;
boolean showUndistorted = false;
boolean showAll = false;
boolean showNumbers = true;
double errorScale = 20;
public StereoPlanarPanel() {
super(new BorderLayout());
leftView.setImages(listLeft);
rightView.setImages(listRight);
imageList = new JList();
imageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
imageList.addListSelectionListener(this);
meanErrorLeft = createTextComponent();
maxErrorLeft = createTextComponent();
meanErrorRight = createTextComponent();
maxErrorRight = createTextComponent();
leftView.addMouseListener(this);
rightView.addMouseListener(this);
JToolBar toolBar = createToolBar();
JPanel center = new JPanel();
center.setLayout(new GridLayout(1,2));
center.add(leftView);
center.add(rightView);
add(toolBar, BorderLayout.PAGE_START);
add(center, BorderLayout.CENTER);
add(new SideBar(), BorderLayout.WEST);
}
private JTextArea createTextComponent() {
JTextArea comp = new JTextArea(1,6);
comp.setMaximumSize(comp.getPreferredSize());
comp.setEditable(false);
return comp;
}
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("Rectify");
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, 5, 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;
}
public void setRectification( IntrinsicParameters leftParam , DenseMatrix64F leftRect ,
IntrinsicParameters rightParam , DenseMatrix64F rightRect ) {
leftView.setDistorted(leftParam,leftRect);
rightView.setDistorted(rightParam,rightRect);
checkUndistorted.setEnabled(true);
}
public void addPair( String name , BufferedImage imageLeft , BufferedImage imageRight )
{
listLeft.add(imageLeft);
listRight.add(imageRight);
names.add(name);
imageList.removeListSelectionListener(this);
imageList.setListData(new Vector
Ads help maintain this website.