commit 24/03/2025
This commit is contained in:
@@ -102,6 +102,17 @@ public class Cameradetail {
|
||||
@FXML
|
||||
private Slider exposureSlider;
|
||||
|
||||
@FXML
|
||||
private Label face_indicator;
|
||||
|
||||
@FXML
|
||||
private Label eye_indicator;
|
||||
|
||||
@FXML
|
||||
private Label sharpness_indicator;
|
||||
|
||||
private Double sharpness_value = 0.0;
|
||||
|
||||
private @Getter final UMat BestMat = new UMat();
|
||||
private @Getter final UMat LiveMat = new UMat();
|
||||
private @Getter final UMat ReducedMat = new UMat();
|
||||
@@ -805,12 +816,7 @@ public class Cameradetail {
|
||||
System.out.println("Camera "+cameratitle+" started");
|
||||
|
||||
Capturing.set(true);
|
||||
// just information
|
||||
String ss = String.format("Camera Started with resolution %dx%d@%d", BestSize.width(), BestSize.height(),LiveFPS);
|
||||
Platform.runLater(()->setCameraStatus(ss));
|
||||
raise_log(ss);
|
||||
|
||||
|
||||
if (event!=null) event.onStartCapturing();
|
||||
|
||||
Task<Image> task = new Task<>() {
|
||||
@SuppressWarnings("BusyWait")
|
||||
@@ -826,7 +832,11 @@ public class Cameradetail {
|
||||
TimerTask fpsTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
LiveFPS = fps.getAndSet(0);
|
||||
int fpsval = fps.getAndSet(0);
|
||||
if (fpsval!=LiveFPS){
|
||||
LiveFPS = fpsval;
|
||||
if (event!=null) event.onStartCapturing();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -884,15 +894,29 @@ public class Cameradetail {
|
||||
fps.incrementAndGet();
|
||||
|
||||
UMat originalmat = new UMat();
|
||||
mat.copyTo(originalmat); // copy to BestMat for using OpenCL
|
||||
// revisi 18/03/2025
|
||||
UMat flippedmat = new UMat();
|
||||
opencv_core.flip(originalmat, flippedmat, 1); // flip horizontal
|
||||
opencv_core.rotate(flippedmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
||||
mat.copyTo(originalmat); // copy to originalmat for using OpenCL
|
||||
if (config.isMirrorCamera()){
|
||||
// revisi 18/03/2025
|
||||
UMat flippedmat = new UMat();
|
||||
opencv_core.flip(originalmat, flippedmat, 0); // flip vertical
|
||||
flippedmat.copyTo(originalmat);
|
||||
}
|
||||
if (config.isFlipCamera()){
|
||||
// revisi 18/03/2025
|
||||
UMat flippedmat = new UMat();
|
||||
opencv_core.flip(originalmat, flippedmat, 1); // flip horizontal
|
||||
flippedmat.copyTo(originalmat);
|
||||
}
|
||||
|
||||
// rotate 90 degree counter clockwise karena kamera potrait
|
||||
opencv_core.rotate(originalmat, originalmat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
||||
|
||||
|
||||
|
||||
IsGrabbingLiveView.set(false);
|
||||
|
||||
if (!BestMat.empty()) {
|
||||
opencv_imgproc.resize(BestMat, LiveMat, LiveSize); // resize to LiveSize
|
||||
if (!originalmat.empty()) {
|
||||
opencv_imgproc.resize(originalmat, LiveMat, LiveSize); // resize to LiveSize
|
||||
UMat graymat = new UMat(); // use OpenCL for grayscale
|
||||
opencv_imgproc.cvtColor(LiveMat,graymat, COLOR_BGR2GRAY); // convert to grayscale
|
||||
if (use_qr){
|
||||
@@ -950,6 +974,14 @@ public class Cameradetail {
|
||||
|
||||
no_face_counter = 0;
|
||||
if (event!=null) event.onFrontalFaceDetector(true, _face_width, _face_height);
|
||||
face_indicator.setVisible(true);
|
||||
|
||||
double sharpness = CalculateSharpness(originalmat);
|
||||
if (sharpness>=config.getSharpnessThreshold()){
|
||||
sharpness_value = sharpness;
|
||||
originalmat.copyTo(BestMat);
|
||||
Platform.runLater(()->sharpness_indicator.setText(String.format("%.2f", sharpness_value)));
|
||||
}
|
||||
|
||||
if (theface.getFace()!=null){
|
||||
LiveMatROI = new Rect(theface.getFace().x(), theface.getFace().y(), theface.getFace().width(), theface.getFace().height());
|
||||
@@ -963,12 +995,18 @@ public class Cameradetail {
|
||||
open_eye_counter++;
|
||||
continue;
|
||||
}
|
||||
System.out.println("Valid Open Eyes");
|
||||
//System.out.println("Valid Open Eyes");
|
||||
|
||||
|
||||
if (eye_state==0){
|
||||
if (eye_state!=1){
|
||||
// transisi dari tutup mata ke buka mata
|
||||
System.out.println("Transition from close to open eyes");
|
||||
eye_state = 1;
|
||||
if (event!=null) event.onEyeDetector(true);
|
||||
eye_indicator.setVisible(true);
|
||||
|
||||
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if (waiting_for_second_blink){
|
||||
long diff = now - last_blink;
|
||||
@@ -984,7 +1022,6 @@ public class Cameradetail {
|
||||
}
|
||||
last_blink = now;
|
||||
}
|
||||
eye_state = 1;
|
||||
} else {
|
||||
// ada muka, tidak ada mata
|
||||
// transisi dari buka mata ke tutup mata
|
||||
@@ -993,15 +1030,26 @@ public class Cameradetail {
|
||||
close_eye_counter++;
|
||||
continue;
|
||||
}
|
||||
System.out.println("Valid Closed Eyes");
|
||||
//System.out.println("Valid Closed Eyes");
|
||||
if (eye_state!=0){
|
||||
System.out.println("Transition from open to close eyes");
|
||||
eye_state = 0;
|
||||
if (event!=null) event.onEyeDetector(false);
|
||||
eye_indicator.setVisible(false);
|
||||
}
|
||||
eye_state = 0;
|
||||
}
|
||||
} else if (have_left_45_face ){
|
||||
no_face_counter = 0;
|
||||
if (event!=null) event.onProfileFaceDetector(true, _face_width, _face_height);
|
||||
face_indicator.setVisible(true);
|
||||
|
||||
double sharpness = CalculateSharpness(originalmat);
|
||||
if (sharpness>=config.getSharpnessThreshold()){
|
||||
sharpness_value = sharpness;
|
||||
originalmat.copyTo(BestMat);
|
||||
Platform.runLater(()->sharpness_indicator.setText(String.format("%.2f", sharpness_value)));
|
||||
}
|
||||
|
||||
} else {
|
||||
// no face detected, but let's not cancel the previous state immediately
|
||||
|
||||
@@ -1021,6 +1069,8 @@ public class Cameradetail {
|
||||
if (event!=null) {
|
||||
event.onFrontalFaceDetector(false, _face_width, _face_height);
|
||||
event.onProfileFaceDetector(false, _face_width, _face_height);
|
||||
face_indicator.setVisible(false);
|
||||
eye_indicator.setVisible(false);
|
||||
}
|
||||
} else no_face_counter++;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,11 @@ package id.co.gtc.erhacam;
|
||||
|
||||
import FTP.FTPCheck;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
@@ -13,6 +16,7 @@ import org.bytedeco.javacv.VideoInputFrameGrabber;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
import static Config.SomeCodes.*;
|
||||
|
||||
@@ -39,9 +43,18 @@ public class SettingView {
|
||||
@FXML
|
||||
private TextField FTPPath;
|
||||
|
||||
@FXML
|
||||
private TextField Sharpness;
|
||||
|
||||
@FXML
|
||||
private TextField PhotoDirectoryPath;
|
||||
|
||||
@FXML
|
||||
private CheckBox MirrorCamera;
|
||||
|
||||
@FXML
|
||||
private CheckBox FlipCamera;
|
||||
|
||||
|
||||
|
||||
final FileChooser jfc = new FileChooser();
|
||||
@@ -68,8 +81,20 @@ public class SettingView {
|
||||
PhotoDirectoryPath.setText(path);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void SharpnessApply(){
|
||||
String str = Sharpness.getText();
|
||||
if (ValidDouble(str)){
|
||||
config.setSharpnessThreshold(Double.parseDouble(str));
|
||||
config.Save();
|
||||
} else {
|
||||
ShowAlert(Alert.AlertType.ERROR, "Sharpness Setting Error", "Sharpness Setting Error", "Sharpness Setting must be a number");
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void CascadeSettingApply(){
|
||||
|
||||
String minsize = cascadeMinSize.getText();
|
||||
String scalefactor = cascadeScaleFactor.getText();
|
||||
String maxsize = cascadeMaxSize.getText();
|
||||
@@ -104,6 +129,7 @@ public class SettingView {
|
||||
} else show_cascade_alert("Max Size must not empty");
|
||||
} else show_cascade_alert("Min Size must not empty");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void show_cascade_alert(String content){
|
||||
@@ -123,7 +149,17 @@ public class SettingView {
|
||||
Logger.error("Unable to detect Cameras, Msg : "+e.getMessage());
|
||||
}
|
||||
|
||||
MirrorCamera.selectedProperty().addListener(((observable, oldValue, newValue) -> {
|
||||
System.out.println("Mirror option changed to : "+newValue);
|
||||
config.setMirrorCamera(newValue);
|
||||
config.Save();
|
||||
}));
|
||||
|
||||
FlipCamera.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
System.out.println("Flip option changed to : "+newValue);
|
||||
config.setFlipCamera(newValue);
|
||||
config.Save();
|
||||
});
|
||||
|
||||
|
||||
Platform.runLater(()->{
|
||||
@@ -166,6 +202,12 @@ public class SettingView {
|
||||
cascadeScaleFactor.setText(String.valueOf(config.getCascadeScaleFactor()));
|
||||
cascadeMinSize.setText(String.valueOf(config.getCascadeMinSize()));
|
||||
cascadeMaxSize.setText(String.valueOf(config.getCascadeMaxSize()));
|
||||
|
||||
MirrorCamera.setSelected(config.isMirrorCamera());
|
||||
FlipCamera.setSelected(config.isFlipCamera());
|
||||
|
||||
Sharpness.setText(String.valueOf(config.getSharpnessThreshold()));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user