private void processStream(CameraPinholeBrown intrinsic , SimpleImageSequence<GrayU8> sequence , ImagePanel gui , long pauseMilli) {

		Font font = new Font("Serif", Font.BOLD, 24);

		Se3_F64 fiducialToCamera = new Se3_F64();
		int frameNumber = 0;
		while( sequence.hasNext() ) {
			long before = System.currentTimeMillis();
			GrayU8 input = sequence.next();
			BufferedImage buffered = sequence.getGuiImage();
			try {
				detector.detect(input);
			} catch( RuntimeException e ) {
				System.err.println("BUG!!! saving image to crash_image.png");
				UtilImageIO.saveImage(buffered,"crash_image.png");
				throw e;
			}

			Graphics2D g2 = buffered.createGraphics();

			for (int i = 0; i < detector.totalFound(); i++) {
				detector.getFiducialToCamera(i,fiducialToCamera);
				long id = detector.getId(i);
				double width = detector.getWidth(i);

				VisualizeFiducial.drawCube(fiducialToCamera,intrinsic,width,3,g2);
				VisualizeFiducial.drawLabelCenter(fiducialToCamera,intrinsic,""+id,g2);
			}
			saveResults(frameNumber++);

			if( intrinsicPath == null ) {
				g2.setColor(Color.RED);
				g2.setFont(font);
				g2.drawString("Uncalibrated",10,20);
			}

			gui.setImage(buffered);

			long after = System.currentTimeMillis();
			long time = Math.max(0,pauseMilli-(after-before));
			if( time > 0 ) {
				try { Thread.sleep(time); } catch (InterruptedException ignore) {}
			}
		}
	}
private void processStream ( CameraPinholeBrown intrinsic , SimpleImageSequence < GrayU8 > sequence , ImagePanel gui , long pauseMilli ) { Font font = new Font ( "Serif" , Font . BOLD , 24 ) ; Se3_F64 fiducialToCamera = new Se3_F64 ( ) ; int frameNumber = 0 ; while ( sequence . hasNext ( ) ) { long before = System . currentTimeMillis ( ) ; GrayU8 input = sequence . next ( ) ; BufferedImage buffered = sequence . getGuiImage ( ) ; try { detector . detect ( input ) ; } catch ( RuntimeException e ) { System . err . println ( "BUG!!! saving image to crash_image.png" ) ; UtilImageIO . saveImage ( buffered , "crash_image.png" ) ; throw e ; } Graphics2D g2 = buffered . createGraphics ( ) ; for ( int i = 0 ; i < detector . totalFound ( ) ; i ++ ) { detector . getFiducialToCamera ( i , fiducialToCamera ) ; long id = detector . getId ( i ) ; double width = detector . getWidth ( i ) ; VisualizeFiducial . drawCube ( fiducialToCamera , intrinsic , width , 3 , g2 ) ; VisualizeFiducial . drawLabelCenter ( fiducialToCamera , intrinsic , "" + id , g2 ) ; } saveResults ( frameNumber ++ ) ; if ( intrinsicPath == null ) { g2 . setColor ( Color . RED ) ; g2 . setFont ( font ) ; g2 . drawString ( "Uncalibrated" , 10 , 20 ) ; } gui . setImage ( buffered ) ; long after = System . currentTimeMillis ( ) ; long time = Math . max ( 0 , pauseMilli - ( after - before ) ) ; if ( time > 0 ) { try { Thread . sleep ( time ) ; } catch ( InterruptedException ignore ) { } } } }
Displays a continuous stream of images