private void controlPointsModified() { synchronized (pointsUndistorted){ try { // transform needs to go from distorted image to undistorted image alg.setSource(pointsDistorted); alg.setDestination(pointsUndistorted); validTransform = true; } catch( RuntimeException e ) { // System.out.println("Failed because of "+e.getMessage()); // System.out.println(" total points "+pointsDistorted.size()); validTransform = false; } } distortImage.setModel(p2p); if( inputMethod == InputMethod.IMAGE ) { renderDistorted(null, undistorted); } gui.repaint(); }
@Override public void handleAlgorithmChange() { alg = FactoryDistort.deformMls(control.getConfigMLS()); p2p.setTransform(alg); alg.setImageShape(undistorted.width,undistorted.height); controlPointsModified(); }
@Override public void processImage(int sourceID, long frameID, BufferedImage buffered, final ImageBase undistorted) { // do this here instead of a reshape to ensure the number of bands is the same distorted = (T)undistorted.createSameShape(); BufferedImage tmp = distortedBuff; distortedBuff = ConvertBufferedImage.checkDeclare( undistorted.width,undistorted.height,distortedBuff,buffered.getType()); if( tmp != distortedBuff ) { distorted.reshape(undistorted.width, undistorted.height); this.undistorted.reshape(undistorted.width, undistorted.height); gui.setPreferredSize(new Dimension(undistorted.width,undistorted.height)); alg.setImageShape(undistorted.width,undistorted.height); synchronized (pointsUndistorted){ validTransform = false; pointsUndistorted.clear(); pointsDistorted.clear(); } } if( inputMethod == InputMethod.IMAGE ) { this.undistorted.setTo((T)undistorted); } renderDistorted(buffered, (T)undistorted); }