Improvement 21/01/2025

This commit is contained in:
2025-01-21 10:53:41 +07:00
parent 30660b9afb
commit f80662a453
24 changed files with 210383 additions and 25739 deletions

View File

@@ -68,6 +68,8 @@ public class CaptureView {
private List<String> cams;
private final AtomicBoolean[] have_face = new AtomicBoolean[5];
private final AtomicBoolean[] have_eyes = new AtomicBoolean[5];
private final AtomicBoolean isTakingPhoto = new AtomicBoolean(false);
@FXML
private void ChangeDirectory(){
@@ -116,6 +118,7 @@ public class CaptureView {
String prefix = RemoveSpaces(prefixfile.getText()) ;
if (ValidDirectory(directory)){
if (ValidString(prefix)){
isTakingPhoto.set(true);
//audioPlayer.PlayFile(audio_posisi_diam, ps);
PhotoReviewClass prc = new PhotoReviewClass();
prc.setPrefix(prefix);
@@ -211,6 +214,8 @@ public class CaptureView {
long duration = (System.nanoTime() - nanostart) / 1000000; // in milliseconds
System.out.println("TakePhotos duration: "+duration+" ms");
// TODO test taruh sini
isTakingPhoto.set(false);
audioPlayer.PlayFile(audio_foto_selesai, ps);
String[] files = prc.files();
@@ -458,6 +463,14 @@ public class CaptureView {
case CameraConfigRight90 -> have_face[4];
};
final AtomicBoolean _have_eye = switch (image.getCameraConfigEnum()){
case CameraConfigCenter -> have_eyes[2];
case CameraConfigLeft45 -> have_eyes[1];
case CameraConfigLeft90 -> have_eyes[0];
case CameraConfigRight45 -> have_eyes[3];
case CameraConfigRight90 -> have_eyes[4];
};
Platform.runLater(()-> image.setCameraTitle(title));
if (devicenumber!=-1){
OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(devicenumber);
@@ -497,13 +510,9 @@ public class CaptureView {
}
image.SetGrabber(grabber, livewidth,liveheight,photowidth,photoheight,reducewidth,reduceheight);
//TODO reconfirm requirement again
boolean use_face_detector = true;
boolean use_qr_detector = true;
LiveCamEvent lce = new LiveCamEvent() {
@Override
public void onDetectedQRCode(String qrCode) {
@@ -513,13 +522,14 @@ public class CaptureView {
@Override
public void onFaceDetector(boolean hasface, int width, int height) {
Platform.runLater(()-> {
String ss = hasface ? String.format("Camera Started, %dx%d@%d, Face Detected", width, height, image.getLiveFPS()) : String.format("Camera Started, %dx%d@%d", width, height, image.getLiveFPS());
image.setCameraStatus(ss);
_have_face.set(hasface);
_have_face.set(hasface);
update_status(image);
}
//if (ValidString(qr) && hasface) audioPlayer.PlayFile(audio_posisikan_muka, ps);
});
@Override
public void onEyeDetector(boolean hasEye, int width, int height) {
_have_eye.set(hasEye);
update_status(image);
}
@Override
@@ -527,6 +537,31 @@ public class CaptureView {
String ss = String.format("[%s] : %s", title, log);
Logger.info(ss);
}
@Override
public void onBlink(int counter) {
String prefix = prefixfile.getText();
if (!prefix.isEmpty()){
if (isTakingPhoto.get()) return; // other camera already detect blinking
btnTakePhoto.fire();
}
}
private void update_status(Cameradetail image){
Platform.runLater(()-> {
StringBuilder sb = new StringBuilder();
sb.append("Camera Started, ");
sb.append(image.getBestWidth());
sb.append("x");
sb.append(image.getBestHeight());
sb.append("@");
sb.append(image.getLiveFPS());
if (_have_face.get()) sb.append(", Face Detected");
if (_have_eye.get()) sb.append(", Eye Detected");
image.setCameraStatus(sb.toString());
});
}
};
Platform.runLater(()-> image.setCameraStatus("Camera Starting"));
@@ -542,7 +577,7 @@ public class CaptureView {
try{
have_face[camid-1] = new AtomicBoolean(false);
have_eyes[camid-1] = new AtomicBoolean(false);
FXMLLoader loader = new FXMLLoader(getClass().getResource("cameradetail.fxml"));
AnchorPane child = loader.load();