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++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user