private synchronized void changeImageView ( ) { JComponent comp ; if ( control . selectedView < 3 ) { BufferedImage img ; switch ( control . selectedView ) { case 0 : img = disparityOut ; break ; case 1 : img = colorLeft ; break ; case 2 : img = colorRight ; break ; default : throw new RuntimeException ( "Unknown option" ) ; } gui . setImage ( img ) ; gui . setPreferredSize ( new Dimension ( origLeft . getWidth ( ) , origLeft . getHeight ( ) ) ) ; comp = gui ; } else { if ( ! computedCloud ) { computedCloud = true ; DisparityToColorPointCloud d2c = new DisparityToColorPointCloud ( ) ; double baseline = calib . getRightToLeft ( ) . getT ( ) . norm ( ) ; d2c . configure ( baseline , rectK , rectR , leftRectToPixel , control . minDisparity , control . maxDisparity ) ; d2c . process ( activeAlg . getDisparity ( ) , colorLeft ) ; CameraPinhole rectifiedPinhole = PerspectiveOps . matrixToPinhole ( rectK , colorLeft . getWidth ( ) , colorLeft . getHeight ( ) , null ) ; pcv . clearPoints ( ) ; pcv . setCameraHFov ( PerspectiveOps . computeHFov ( rectifiedPinhole ) ) ; pcv . setTranslationStep ( 5 ) ; pcv . addCloud ( d2c . getCloud ( ) , d2c . getCloudColor ( ) ) ; } comp = pcv . getComponent ( ) ; comp . requestFocusInWindow ( ) ; } panel . remove ( gui ) ; panel . remove ( pcv . getComponent ( ) ) ; panel . add ( comp , BorderLayout . CENTER ) ; panel . validate ( ) ; comp . repaint ( ) ; processedImage = true ; }
Changes which image is being displayed depending on GUI selection