double marginX = Math.max(0.0, (markerSettings.getSpacingX()-markerSettings.getSizeX())/2);
double marginY = Math.max(0.0, (markerSettings.getSpacingY()-markerSettings.getSizeY())/2);
markers = Marker.createArray(markerSettings, marginX, marginY);
double width = (markerSettings.getColumns()-1)*markerSettings.getSpacingX() + markerSettings.getSizeX() + 2*marginX;
double height = (markerSettings.getRows()-1)*markerSettings.getSpacingY() + markerSettings.getSizeY() + 2*marginY;
boardPlane = new MarkedPlane((int)Math.ceil(width), (int)Math.ceil(height), markers[0], 1);
IplImage image = boardPlane.getImage();
int iconHeight = Toolkit.getDefaultToolkit().getScreenSize().height/10;
IplImage smallImage = IplImage.create(image.width()*iconHeight/image.height(), iconHeight, IPL_DEPTH_8U, 1);
cvResize(image, smallImage, CV_INTER_AREA);
boardPatternLabel.setText("Board (" + boardPlane.getWidth() + " x " + boardPlane.getHeight() + ")");
boardPatternLabel.setIcon(new ImageIcon(smallImage.getBufferedImage(
smallImage.getBufferedImageType() == BufferedImage.TYPE_CUSTOM ? 1.0 :
1.0/CanvasFrame.getGamma(boardPatternLabel.getGraphicsConfiguration().getDevice()))));
projectorPatternLabel.setText("No Projector");
projectorPatternLabel.setIcon(null);
projectorPatternLabel.setEnabled(false);
for (int i = 0; i < ps.length; i++) {
int w = ps[i].getImageWidth();
int h = ps[i].getImageHeight();
if (w > 0 && h > 0) {
MarkedPlane proj = new MarkedPlane(w, h, markers[1], true,
cvScalarAll(((ProjectorDevice.CalibrationSettings)ps[i]).getBrightnessForeground()*255),
cvScalarAll(((ProjectorDevice.CalibrationSettings)ps[i]).getBrightnessBackground()*255), 4);
image = proj.getImage();
smallImage = IplImage.create(image.width()*iconHeight/image.height(), iconHeight, IPL_DEPTH_8U, 1);
cvResize(image, smallImage, CV_INTER_AREA);
projectorPatternLabel.setText(ps[i].getName() + " (" + proj.getWidth() + " x " + proj.getHeight() + ")");
projectorPatternLabel.setIcon(new ImageIcon(smallImage.getBufferedImage(
smallImage.getBufferedImageType() == BufferedImage.TYPE_CUSTOM ? 1.0 :
1.0/CanvasFrame.getGamma(projectorPatternLabel.getGraphicsConfiguration().getDevice()))));
projectorPatternLabel.setEnabled(true);
break;