use of boofcv.io.jcodec.JCodecSimplified in project BoofCV by lessthanoptimal.
the class ExampleJCodecDisplayFrames method main.
public static void main(String[] args) {
String fileName = UtilIO.pathExample("background/highway_bridge_jitter.mp4");
ImageType type = ImageType.pl(3, GrayU8.class);
// ImageType type = ImageType.single(GrayU8.class);
// ImageType type = ImageType.pl(3, GrayF32.class);
// ImageType type = ImageType.single(GrayF32.class);
JCodecSimplified sequence = new JCodecSimplified<>(fileName, type);
BufferedImage out;
if (sequence.hasNext()) {
ImageBase frame = sequence.next();
out = new BufferedImage(frame.width, frame.height, BufferedImage.TYPE_INT_RGB);
ConvertBufferedImage.convertTo(frame, out, false);
} else {
throw new RuntimeException("No first frame?!?!");
}
ImagePanel gui = new ImagePanel(out);
ShowImages.showWindow(gui, "Video!", true);
long totalNano = 0;
while (sequence.hasNext()) {
long before = System.nanoTime();
ImageBase frame = sequence.next();
totalNano += System.nanoTime() - before;
ConvertBufferedImage.convertTo(frame, out, false);
gui.repaint();
try {
Thread.sleep(22);
} catch (InterruptedException e) {
}
}
System.out.println("Only read FPS = " + (totalNano / 1000000.0) / sequence.getFrameNumber());
}
Aggregations