Beispiel #1
0
  public final void run(
      final ImagePlus imp,
      final int width,
      final int height,
      final double minLambda,
      final double minPhi,
      final double hfov,
      final double vfov) {
    ip = imp.getProcessor().createProcessor(width, height);
    final ImagePlus impViewer = new ImagePlus("Panorama View", ip);

    /* initialize projection */
    p.setMinLambda(minLambda);
    p.setMinPhi(minPhi);
    p.setLambdaPiScale(Math.PI / hfov * imp.getWidth());
    p.setPhiPiScale(Math.PI / vfov * (imp.getHeight() - 1));
    p.setTargetWidth(ip.getWidth());
    p.setTargetHeight(ip.getHeight());
    p.setF(0.5);

    System.out.println(p.getLambdaPiScale() + " " + p.getPhiPiScale());

    /* TODO calculate proper size */

    // final int cubeSize = 500;
    final int cubeSize =
        (int) Math.round(Math.max(p.getPhiPiScale(), p.getLambdaPiScale()) * 2.0 / Math.PI);

    frontSource = ip.createProcessor(cubeSize + 1, cubeSize + 1);
    backSource = ip.createProcessor(cubeSize + 1, cubeSize + 1);
    leftSource = ip.createProcessor(cubeSize + 1, cubeSize + 1);
    rightSource = ip.createProcessor(cubeSize + 1, cubeSize + 1);
    topSource = ip.createProcessor(cubeSize + 1, cubeSize + 1);
    bottomSource = ip.createProcessor(cubeSize + 1, cubeSize + 1);

    renderCubeFaces(hfov, vfov);

    /* instantiate and run mapper and painter */
    final Mapper mapper =
        new CubeFaceMapper(
            frontSource, backSource, leftSource, rightSource, topSource, bottomSource, p);
    painter = new MappingThread(imp, impViewer, mapper, ip, p);

    impViewer.show();

    gui = new GUI(impViewer);

    gui.backupGui();
    gui.takeOverGui();

    painter.start();
    update(false);
  }
Beispiel #2
0
 @Override
 public void keyPressed(final KeyEvent e) {
   if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_ENTER) {
     painter.interrupt();
     imp.getCanvas().setDisplayList(null);
     gui.restoreGui();
     if (e.getKeyCode() == KeyEvent.VK_ESCAPE) gui.close();
   } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
     dLambda *= 10;
     dPhi *= 10;
   } else if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
     dLambda /= 10;
     dPhi /= 10;
   } else {
     final double v = keyModfiedSpeed(e.getModifiersEx());
     if (e.getKeyCode() == KeyEvent.VK_LEFT) {
       lambda -= v * step;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
       lambda += v * step;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_UP) {
       phi -= v * step;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
       phi += v * step;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_PLUS || e.getKeyCode() == KeyEvent.VK_EQUALS) {
       p.setF(p.getF() * (1 + 0.1f * v));
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_MINUS) {
       p.setF(p.getF() / (1 + 0.1f * v));
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
       renderCubeFaces(hfov, vfov);
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_I) {
       painter.toggleInterpolation();
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_V) {
       painter.toggleVisualization();
       imp.getCanvas().setDisplayList(null);
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_A) {
       naviMode = NaviMode.PAN_TILT;
       dLambda = dPhi = 0;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_P) {
       naviMode = NaviMode.PAN_ONLY;
       dLambda = dPhi = 0;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_T) {
       naviMode = NaviMode.TILT_ONLY;
       dLambda = dPhi = 0;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_R) {
       naviMode = NaviMode.ROLL_ONLY;
       dLambda = dPhi = 0;
       update(false);
     } else if (e.getKeyCode() == KeyEvent.VK_F1) {
       IJ.showMessage(
           "Interactive Panorama Viewer",
           "Mouse control:"
               + NL
               + " "
               + NL
               + "Pan and tilt the panorama by dragging the image in the canvas and"
               + NL
               + "zoom in and out using the mouse-wheel."
               + NL
               + " "
               + NL
               + "Key control:"
               + NL
               + " "
               + NL
               + "CURSOR LEFT - Pan left."
               + NL
               + "CURSOR RIGHT - Pan right."
               + NL
               + "CURSOR UP - Tilt up."
               + NL
               + "CURSOR DOWN - Tilt down."
               + NL
               + "SHIFT - Move 10x faster."
               + NL
               + "CTRL - Move browse 10x slower."
               + NL
               + "ENTER/ESC - Leave interactive mode."
               + NL
               + "I - Toggle interpolation."
               + NL
               + "V - Toggle FOV visualization."
               + NL
               + "R - Roll-mode (roll via mouse drag)."
               + NL
               + "P - Pan/Tilt-mode (pan/tilt via mouse drag).");
     }
   }
 }
Beispiel #3
0
 private final void update(final boolean keepPainting) {
   painter.repaint(keepPainting);
 }