From adc29b9a70fa1d03ac67b0b3f397fed7a75f4d7b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sat, 23 Mar 2019 12:02:42 +0100 Subject: [PATCH] Renamed Frame to VideoFrame --- src/kaka/cakelight/CakeLight.java | 2 +- src/kaka/cakelight/FrameGrabber.java | 4 ++-- src/kaka/cakelight/GuiTest.java | 8 ++++---- src/kaka/cakelight/{Frame.java => VideoFrame.java} | 8 ++++---- src/kaka/cakelight/VideoMode.java | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) rename src/kaka/cakelight/{Frame.java => VideoFrame.java} (97%) diff --git a/src/kaka/cakelight/CakeLight.java b/src/kaka/cakelight/CakeLight.java index 95a3be1..3769dce 100644 --- a/src/kaka/cakelight/CakeLight.java +++ b/src/kaka/cakelight/CakeLight.java @@ -30,7 +30,7 @@ public class CakeLight { // TODO // FrameGrabber grabber = FrameGrabber.from(config); // grabber.prepare(); -// Frame frame = grabber.grabFrame(); +// VideoFrame frame = grabber.grabFrame(); // double time = 0; // for (int i = 0; i < 100; i++) { // time += timeIt("frame", () -> grabber.grabFrame()); diff --git a/src/kaka/cakelight/FrameGrabber.java b/src/kaka/cakelight/FrameGrabber.java index dbf620a..1db5c2c 100644 --- a/src/kaka/cakelight/FrameGrabber.java +++ b/src/kaka/cakelight/FrameGrabber.java @@ -37,12 +37,12 @@ public class FrameGrabber implements Closeable { /** * Must be run in the same thread as {@link #prepare}. */ - public Optional grabFrame() { + public Optional grabFrame() { try { byte[] data = new byte[bytesPerFrame]; int count = fileStream.read(data); log("# of bytes read = " + count); - return Optional.of(Frame.of(data, config)); + return Optional.of(VideoFrame.of(data, config)); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/kaka/cakelight/GuiTest.java b/src/kaka/cakelight/GuiTest.java index c72519a..0d199c2 100644 --- a/src/kaka/cakelight/GuiTest.java +++ b/src/kaka/cakelight/GuiTest.java @@ -68,7 +68,7 @@ public class GuiTest extends Application { return javafx.scene.paint.Color.rgb(c.r(), c.g(), c.b()); } - private void drawFrame(GraphicsContext gc, Frame frame) { + private void drawFrame(GraphicsContext gc, VideoFrame frame) { if (paused) return; System.out.println("Drawing a frame"); drawCols(gc, frame); @@ -100,7 +100,7 @@ public class GuiTest extends Application { } } - private void drawVideo(GraphicsContext gc, Frame frame) { + private void drawVideo(GraphicsContext gc, VideoFrame frame) { byte[] rgb = new byte[3]; Mat img = frame.getConvertedImage(); float colSize = 16 * BLOCK / (float)img.cols(); @@ -114,7 +114,7 @@ public class GuiTest extends Application { } } - private void drawCols(GraphicsContext gc, Frame frame) { + private void drawCols(GraphicsContext gc, VideoFrame frame) { byte[] rgb = new byte[3]; for (int x = 0; x < config.leds.cols; x++) { for (int y = 0; y < 9; y++) { @@ -124,7 +124,7 @@ public class GuiTest extends Application { } } - private void drawRows(GraphicsContext gc, Frame frame) { + private void drawRows(GraphicsContext gc, VideoFrame frame) { byte[] rgb = new byte[3]; for (int y = 0; y < config.leds.rows; y++) { for (int x = 0; x < 16; x++) { diff --git a/src/kaka/cakelight/Frame.java b/src/kaka/cakelight/VideoFrame.java similarity index 97% rename from src/kaka/cakelight/Frame.java rename to src/kaka/cakelight/VideoFrame.java index 053b713..30d8593 100644 --- a/src/kaka/cakelight/Frame.java +++ b/src/kaka/cakelight/VideoFrame.java @@ -8,7 +8,7 @@ import org.opencv.imgproc.Imgproc; import static kaka.cakelight.Main.saveFile; import static kaka.cakelight.Main.timeIt; -public class Frame { +public class VideoFrame { private byte[] data; private Configuration config; // private Mat colImage; @@ -16,12 +16,12 @@ public class Frame { private Mat converted; private Mat[] images; - private Frame(byte[] data) { + private VideoFrame(byte[] data) { this.data = data; } - public static Frame of(byte[] data, Configuration config) { - Frame frame = new Frame(data); + public static VideoFrame of(byte[] data, Configuration config) { + VideoFrame frame = new VideoFrame(data); frame.config = config; frame.convert(); return frame; diff --git a/src/kaka/cakelight/VideoMode.java b/src/kaka/cakelight/VideoMode.java index 1f6d68f..134fa2d 100644 --- a/src/kaka/cakelight/VideoMode.java +++ b/src/kaka/cakelight/VideoMode.java @@ -8,7 +8,7 @@ import java.util.function.Consumer; public class VideoMode extends Mode { private Configuration config; private Thread grabberThread; - private Consumer frameConsumer; + private Consumer frameConsumer; private VideoDeviceListener deviceListener; public VideoMode() { @@ -34,9 +34,9 @@ public class VideoMode extends Mode { public void run() { try (FrameGrabber grabber = FrameGrabber.from(videoDevice, config)) { while (!isInterrupted()) { - Optional frame = grabber.grabFrame(); + Optional frame = grabber.grabFrame(); if (frameConsumer != null) frame.ifPresent(frameConsumer); - frame.ifPresent(VideoMode.this::onFrame); + frame.ifPresent(VideoMode.this::onVideoFrame); // timeIt("frame", grabber::grabFrame); } } catch (IOException e) { @@ -47,11 +47,11 @@ public class VideoMode extends Mode { grabberThread.start(); } - public void onVideoFrame(Consumer consumer) { + public void onVideoFrame(Consumer consumer) { frameConsumer = consumer; } - private void onFrame(Frame frame) { + private void onVideoFrame(VideoFrame frame) { updateWithFrame(frame.getLedFrame()); } -- 2.11.0