X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FFrame.java;h=c0bc76c020997913720edfe8d18b5da6c3d5520d;hb=da7bef43fc02577bf25293b0cda7e7fca01f26ec;hp=07a6ffd0744c8229eee43c25430af4a6cd9fec94;hpb=03b67a7377d6d23d517d33e47f338bb7859596ed;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/Frame.java b/src/kaka/cakelight/Frame.java index 07a6ffd..c0bc76c 100644 --- a/src/kaka/cakelight/Frame.java +++ b/src/kaka/cakelight/Frame.java @@ -1,6 +1,5 @@ package kaka.cakelight; -import javafx.scene.paint.Color; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.Size; @@ -34,6 +33,7 @@ public class Frame { 3) Resize to 2 images where each led uses 2 pixels: vertical - 16 x <#leds> horizontal - <#leds> x 9 + 4) Resize to cols x rows first, then resize to a vertical and a horizontal like in (3). */ Mat src = new Mat(config.video.height, config.video.width, CvType.CV_8UC2); // 8-bit, unsigned, 2 channels src.put(0, 0, data); @@ -53,7 +53,7 @@ public class Frame { config.video.width - config.video.crop.right ); converted = new Mat(); - Imgproc.cvtColor(cropped, converted, Imgproc.COLOR_YUV2RGB_YUYV); + Imgproc.cvtColor(cropped, converted, config.video.format); // timeIt("model 1", () -> model1(converted, Imgproc.INTER_AREA)); // timeIt("model 2", () -> model2(converted, Imgproc.INTER_AREA)); timeIt("model 3", () -> model3(converted, Imgproc.INTER_AREA)); @@ -81,6 +81,7 @@ public class Frame { } public Color getLedColor(ListPosition listPosition, int xy) { + // TODO: maybe use highest value from pixels? 100 % from 1st, 66 % from 2nd, 33 % from 3rd. colors might be strange. switch (listPosition) { case LEFT: return interpolatedRowColor(xy, 0, 1, 2); @@ -133,15 +134,15 @@ public class Frame { } /** - * Creates a LED frame going clockwise from the bottom-left corner, sans the corners. + * Creates a LED frame going counter-clockwise from the bottom-left corner, sans the corners. */ public LedFrame getLedFrame() { LedFrame frame = LedFrame.from(config); int led = 0; - for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, getLedColor(ListPosition.LEFT, i)); - for (int i = 0; i < config.leds.cols; i++) frame.setLedColor(led++, getLedColor(ListPosition.TOP, i)); - for (int i = 0; i < config.leds.rows; i++) frame.setLedColor(led++, getLedColor(ListPosition.RIGHT, i)); - for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, getLedColor(ListPosition.BOTTOM, i)); + for (int i = 0; i < config.leds.cols; i++) frame.setLedColor(led++, getLedColor(ListPosition.BOTTOM, i)); + for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, getLedColor(ListPosition.RIGHT, i)); + for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, getLedColor(ListPosition.TOP, i)); + for (int i = 0; i < config.leds.rows; i++) frame.setLedColor(led++, getLedColor(ListPosition.LEFT, i)); return frame; } }