package kaka.cakelight;
+import org.opencv.imgproc.Imgproc;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
private List<Map.Entry<String, String>> settings = new ArrayList<>();
public VideoConfiguration video;
public LedConfiguration leds;
+ public double gamma;
private Configuration(Properties prop) {
video = new VideoConfiguration(prop);
leds = new LedConfiguration(prop);
+ gamma = Double.parseDouble(get(prop,"gamma", "1"));
}
public static Configuration from(String propertiesFile) {
}
public class VideoConfiguration {
- public String device;
public int width;
public int height;
public int bpp;
+ public int format;
+ public CropConfiguration crop;
private VideoConfiguration(Properties prop) {
- device = get(prop, "video.device", "/dev/video0");
width = Integer.parseInt(get(prop, "video.width", "720"));
height = Integer.parseInt(get(prop, "video.height", "576"));
bpp = Integer.parseInt(get(prop, "video.bpp", "2"));
+ switch (get(prop, "video.format", "").toUpperCase()) {
+ case "YUYV":
+ format = Imgproc.COLOR_YUV2BGR_YUYV;
+ break;
+ case "YVYU":
+ format = Imgproc.COLOR_YUV2BGR_YVYU;
+ break;
+ default:
+ format = Imgproc.COLOR_YUV2BGR_UYVY;
+ }
+ crop = new CropConfiguration(prop);
+ }
+
+ public class CropConfiguration {
+ public int left, right, top, bottom;
+
+ private CropConfiguration(Properties prop) {
+ left = Integer.parseInt(get(prop, "video.crop.left", "0"));
+ right = Integer.parseInt(get(prop, "video.crop.right", "0"));
+ top = Integer.parseInt(get(prop, "video.crop.top", "0"));
+ bottom = Integer.parseInt(get(prop, "video.crop.bottom", "0"));
+ }
}
}
cols = Integer.parseInt(get(prop, "leds.cols"));
rows = Integer.parseInt(get(prop, "leds.rows"));
}
+
+ public int getCount() {
+ return cols * 2 + rows * 2;
+ }
}
}