commit 26/05/2025
Tambah Crop Setting
This commit is contained in:
@@ -50,6 +50,31 @@ public class ConfigFile {
|
||||
|
||||
private @Getter double SharpnessThreshold;
|
||||
|
||||
private @Getter final double topcropmax = 30.0;
|
||||
private @Getter final double bottomcropmax = 30.0;
|
||||
private @Getter final double leftcropmax = 30.0;
|
||||
private @Getter final double rightcropmax = 30.0;
|
||||
private @Getter double Cam1TopCrop = 10.0;
|
||||
private @Getter double Cam1BottomCrop = 10.0;
|
||||
private @Getter double Cam1LeftCrop = 10.0;
|
||||
private @Getter double Cam1RightCrop = 10.0;
|
||||
private @Getter double Cam2TopCrop = 10.0;
|
||||
private @Getter double Cam2BottomCrop = 10.0;
|
||||
private @Getter double Cam2LeftCrop = 10.0;
|
||||
private @Getter double Cam2RightCrop = 10.0;
|
||||
private @Getter double Cam3TopCrop = 10.0;
|
||||
private @Getter double Cam3BottomCrop = 10.0;
|
||||
private @Getter double Cam3LeftCrop = 10.0;
|
||||
private @Getter double Cam3RightCrop = 10.0;
|
||||
private @Getter double Cam4TopCrop = 10.0;
|
||||
private @Getter double Cam4BottomCrop = 10.0;
|
||||
private @Getter double Cam4LeftCrop = 10.0;
|
||||
private @Getter double Cam4RightCrop = 10.0;
|
||||
private @Getter double Cam5TopCrop = 10.0;
|
||||
private @Getter double Cam5BottomCrop = 10.0;
|
||||
private @Getter double Cam5LeftCrop = 10.0;
|
||||
private @Getter double Cam5RightCrop = 10.0;
|
||||
|
||||
private boolean needsave = false;
|
||||
|
||||
public ConfigFile(){
|
||||
@@ -58,6 +83,188 @@ public class ConfigFile {
|
||||
Load();
|
||||
}
|
||||
|
||||
public void setCam1TopCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam1TopCrop && v <= topcropmax && v >= 0.0){
|
||||
Cam1TopCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCam1BottomCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam1BottomCrop && v <= bottomcropmax && v >= 0.0){
|
||||
Cam1BottomCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam1LeftCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam1LeftCrop && v <= leftcropmax && v >= 0.0){
|
||||
Cam1LeftCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam1RightCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam1RightCrop && v <= rightcropmax && v >= 0.0){
|
||||
Cam1RightCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam2TopCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam2TopCrop && v <= topcropmax && v >= 0.0){
|
||||
Cam2TopCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam2BottomCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam2BottomCrop && v <= bottomcropmax && v >= 0.0){
|
||||
Cam2BottomCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam2LeftCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam2LeftCrop && v <= leftcropmax && v >= 0.0){
|
||||
Cam2LeftCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam2RightCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam2RightCrop && v <= rightcropmax && v >= 0.0){
|
||||
Cam2RightCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam3TopCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam3TopCrop && v <= topcropmax && v >= 0.0){
|
||||
Cam3TopCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam3BottomCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam3BottomCrop && v <= bottomcropmax && v >= 0.0){
|
||||
Cam3BottomCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam3LeftCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam3LeftCrop && v <= leftcropmax && v >= 0.0){
|
||||
Cam3LeftCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam3RightCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam3RightCrop && v <= rightcropmax && v >= 0.0){
|
||||
Cam3RightCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam4TopCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam4TopCrop && v <= topcropmax && v >= 0.0){
|
||||
Cam4TopCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam4BottomCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam4BottomCrop && v <= bottomcropmax && v >= 0.0){
|
||||
Cam4BottomCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam4LeftCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam4LeftCrop && v <= leftcropmax && v >= 0.0){
|
||||
Cam4LeftCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam4RightCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam4RightCrop && v <= rightcropmax && v >= 0.0){
|
||||
Cam4RightCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam5TopCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam5TopCrop && v <= topcropmax && v >= 0.0){
|
||||
Cam5TopCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam5BottomCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam5BottomCrop && v <= bottomcropmax && v >= 0.0){
|
||||
Cam5BottomCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam5LeftCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam5LeftCrop && v <= leftcropmax && v >= 0.0){
|
||||
Cam5LeftCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setCam5RightCrop(String value){
|
||||
if (ValidDouble(value)){
|
||||
double v = toDouble(value);
|
||||
if (v != Cam5RightCrop && v <= rightcropmax && v >= 0.0){
|
||||
Cam5RightCrop = v;
|
||||
needsave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMirrorCamera(boolean value){
|
||||
if (MirrorCamera != value){
|
||||
MirrorCamera = value;
|
||||
@@ -596,6 +803,28 @@ public class ConfigFile {
|
||||
if (prop.getProperty("cascadeMinSize") == null) allcorrect = false;
|
||||
if (prop.getProperty("cascadeMaxSize") == null) allcorrect = false;
|
||||
|
||||
if (prop.getProperty("Cam1TopCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam1BottomCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam1LeftCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam1RightCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam2TopCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam2BottomCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam2LeftCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam2RightCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam3TopCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam3BottomCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam3LeftCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam3RightCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam4TopCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam4BottomCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam4LeftCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam4RightCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam5TopCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam5BottomCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam5LeftCrop") == null) allcorrect = false;
|
||||
if (prop.getProperty("Cam5RightCrop") == null) allcorrect = false;
|
||||
|
||||
|
||||
if (allcorrect){
|
||||
AudioPhase1 = prop.getProperty("AudioPhase1");
|
||||
AudioPhase2 = prop.getProperty("AudioPhase2");
|
||||
@@ -622,7 +851,7 @@ public class ConfigFile {
|
||||
ConfigRight45 = gson.fromJson(prop.getProperty(CameraConfigEnum.CameraConfigRight45.toString()), CameraConfig.class);
|
||||
ConfigRight90 = gson.fromJson(prop.getProperty(CameraConfigEnum.CameraConfigRight90.toString()), CameraConfig.class);
|
||||
|
||||
cascadeScaleFactor = toDouble(prop.getProperty("cascadeScaleFactor"));
|
||||
cascadeScaleFactor = cascadetoDouble(prop.getProperty("cascadeScaleFactor"));
|
||||
cascadeMinNeighbors = toInt(prop.getProperty("cascadeMinNeighbors"));
|
||||
cascadeMinSize = toInt(prop.getProperty("cascadeMinSize"));
|
||||
cascadeMaxSize = toInt(prop.getProperty("cascadeMaxSize"));
|
||||
@@ -636,6 +865,28 @@ public class ConfigFile {
|
||||
|
||||
SharpnessThreshold = toDouble(prop.getProperty("SharpnessThreshold"));
|
||||
|
||||
Cam1TopCrop = toDouble(prop.getProperty("Cam1TopCrop"));
|
||||
Cam1BottomCrop = toDouble(prop.getProperty("Cam1BottomCrop"));
|
||||
Cam1LeftCrop = toDouble(prop.getProperty("Cam1LeftCrop"));
|
||||
Cam1RightCrop = toDouble(prop.getProperty("Cam1RightCrop"));
|
||||
Cam2TopCrop = toDouble(prop.getProperty("Cam2TopCrop"));
|
||||
Cam2BottomCrop = toDouble(prop.getProperty("Cam2BottomCrop"));
|
||||
Cam2LeftCrop = toDouble(prop.getProperty("Cam2LeftCrop"));
|
||||
Cam2RightCrop = toDouble(prop.getProperty("Cam2RightCrop"));
|
||||
Cam3TopCrop = toDouble(prop.getProperty("Cam3TopCrop"));
|
||||
Cam3BottomCrop = toDouble(prop.getProperty("Cam3BottomCrop"));
|
||||
Cam3LeftCrop = toDouble(prop.getProperty("Cam3LeftCrop"));
|
||||
Cam3RightCrop = toDouble(prop.getProperty("Cam3RightCrop"));
|
||||
Cam4TopCrop = toDouble(prop.getProperty("Cam4TopCrop"));
|
||||
Cam4BottomCrop = toDouble(prop.getProperty("Cam4BottomCrop"));
|
||||
Cam4LeftCrop = toDouble(prop.getProperty("Cam4LeftCrop"));
|
||||
Cam4RightCrop = toDouble(prop.getProperty("Cam4RightCrop"));
|
||||
Cam5TopCrop = toDouble(prop.getProperty("Cam5TopCrop"));
|
||||
Cam5BottomCrop = toDouble(prop.getProperty("Cam5BottomCrop"));
|
||||
Cam5LeftCrop = toDouble(prop.getProperty("Cam5LeftCrop"));
|
||||
Cam5RightCrop = toDouble(prop.getProperty("Cam5RightCrop"));
|
||||
|
||||
|
||||
Logger.info("Config Loaded");
|
||||
MakeDirectories();
|
||||
return;
|
||||
@@ -651,7 +902,7 @@ public class ConfigFile {
|
||||
CreateDefault();
|
||||
}
|
||||
|
||||
private double toDouble(String cascadeScaleFactor) {
|
||||
private double cascadetoDouble(String cascadeScaleFactor) {
|
||||
try{
|
||||
return Double.parseDouble(cascadeScaleFactor);
|
||||
} catch (Exception e){
|
||||
@@ -659,6 +910,14 @@ public class ConfigFile {
|
||||
}
|
||||
}
|
||||
|
||||
private double toDouble(String value) {
|
||||
try{
|
||||
return Double.parseDouble(value);
|
||||
} catch (Exception e){
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateDefault(){
|
||||
AudioPhase1 = Path.of(currentDirectory, "audio", "phase1.mp3").toString();
|
||||
AudioPhase2 = Path.of(currentDirectory, "audio", "phase2.mp3").toString();
|
||||
@@ -691,6 +950,32 @@ public class ConfigFile {
|
||||
MirrorCamera = false;
|
||||
FlipCamera = false;
|
||||
SharpnessThreshold = 300.0;
|
||||
|
||||
Cam1TopCrop = 10.0;
|
||||
Cam1BottomCrop = 10.0;
|
||||
Cam1LeftCrop = 10.0;
|
||||
Cam1RightCrop = 10.0;
|
||||
|
||||
Cam2TopCrop = 10.0;
|
||||
Cam2BottomCrop = 10.0;
|
||||
Cam2LeftCrop = 10.0;
|
||||
Cam2RightCrop = 10.0;
|
||||
|
||||
Cam3TopCrop = 10.0;
|
||||
Cam3BottomCrop = 10.0;
|
||||
Cam3LeftCrop = 10.0;
|
||||
Cam3RightCrop = 10.0;
|
||||
|
||||
Cam4TopCrop = 10.0;
|
||||
Cam4BottomCrop = 10.0;
|
||||
Cam4LeftCrop = 10.0;
|
||||
Cam4RightCrop = 10.0;
|
||||
|
||||
Cam5TopCrop = 10.0;
|
||||
Cam5BottomCrop = 10.0;
|
||||
Cam5LeftCrop = 10.0;
|
||||
Cam5RightCrop = 10.0;
|
||||
|
||||
Logger.info("Default Config Created");
|
||||
needsave = true;
|
||||
Save();
|
||||
@@ -751,6 +1036,28 @@ public class ConfigFile {
|
||||
prop.setProperty("FlipCamera", String.valueOf(FlipCamera));
|
||||
prop.setProperty("SharpnessThreshold", String.valueOf(SharpnessThreshold));
|
||||
|
||||
prop.setProperty("Cam1TopCrop", String.valueOf(Cam1TopCrop));
|
||||
prop.setProperty("Cam1BottomCrop", String.valueOf(Cam1BottomCrop));
|
||||
prop.setProperty("Cam1LeftCrop", String.valueOf(Cam1LeftCrop));
|
||||
prop.setProperty("Cam1RightCrop", String.valueOf(Cam1RightCrop));
|
||||
prop.setProperty("Cam2TopCrop", String.valueOf(Cam2TopCrop));
|
||||
prop.setProperty("Cam2BottomCrop", String.valueOf(Cam2BottomCrop));
|
||||
prop.setProperty("Cam2LeftCrop", String.valueOf(Cam2LeftCrop));
|
||||
prop.setProperty("Cam2RightCrop", String.valueOf(Cam2RightCrop));
|
||||
prop.setProperty("Cam3TopCrop", String.valueOf(Cam3TopCrop));
|
||||
prop.setProperty("Cam3BottomCrop", String.valueOf(Cam3BottomCrop));
|
||||
prop.setProperty("Cam3LeftCrop", String.valueOf(Cam3LeftCrop));
|
||||
prop.setProperty("Cam3RightCrop", String.valueOf(Cam3RightCrop));
|
||||
prop.setProperty("Cam4TopCrop", String.valueOf(Cam4TopCrop));
|
||||
prop.setProperty("Cam4BottomCrop", String.valueOf(Cam4BottomCrop));
|
||||
prop.setProperty("Cam4LeftCrop", String.valueOf(Cam4LeftCrop));
|
||||
prop.setProperty("Cam4RightCrop", String.valueOf(Cam4RightCrop));
|
||||
prop.setProperty("Cam5TopCrop", String.valueOf(Cam5TopCrop));
|
||||
prop.setProperty("Cam5BottomCrop", String.valueOf(Cam5BottomCrop));
|
||||
prop.setProperty("Cam5LeftCrop", String.valueOf(Cam5LeftCrop));
|
||||
prop.setProperty("Cam5RightCrop", String.valueOf(Cam5RightCrop));
|
||||
|
||||
|
||||
try{
|
||||
prop.store(new FileOutputStream(Path.of(currentDirectory, "config.properties").toString()), null);
|
||||
Logger.info("Config Saved");
|
||||
|
||||
Reference in New Issue
Block a user