commit 21/03/2025

This commit is contained in:
rdkartono
2025-03-24 08:10:17 +07:00
parent 093c32058c
commit 58194d8979
7 changed files with 24414 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
#Mon Mar 17 15:01:40 WIB 2025 #Fri Mar 21 14:45:24 ICT 2025
AudioPhase1=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase1.mp3 AudioPhase1=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase1.mp3
AudioPhase2=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase2.mp3 AudioPhase2=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase2.mp3
AudioPhase3=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase3.mp3 AudioPhase3=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase3.mp3
@@ -11,7 +11,7 @@ CameraConfigLeft90={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0
CameraConfigRight45={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true} CameraConfigRight45={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true}
CameraConfigRight90={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true} CameraConfigRight90={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true}
CameraLeft45= CameraLeft45=
CameraLeft90=ACER QHD User Facing CameraLeft90=OBSBOT Meet 2 StreamCamera
CameraRight45= CameraRight45=
CameraRight90= CameraRight90=
FTPHost=192.168.10.2 FTPHost=192.168.10.2
@@ -19,7 +19,7 @@ FTPPass=password
FTPPath=/ FTPPath=/
FTPPort=21 FTPPort=21
FTPUser=user FTPUser=user
PhotoDirectory=C\:\\Users\\rdkar\\OneDrive\\Desktop\\Erha Capture PhotoDirectory=C\:\\Users\\Erha\\Desktop\\ErhaCapture
cascadeMaxSize=500 cascadeMaxSize=500
cascadeMinNeighbors=3 cascadeMinNeighbors=3
cascadeMinSize=250 cascadeMinSize=250

BIN
countdown321.wav Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
kesalahan_server.wav Normal file

Binary file not shown.

View File

@@ -13,6 +13,7 @@ import javafx.stage.StageStyle;
import javafx.util.Duration; import javafx.util.Duration;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer;
public class AutoCloseAlert { public class AutoCloseAlert {
@@ -43,8 +44,9 @@ public class AutoCloseAlert {
* @param header the header of the alert * @param header the header of the alert
* @param content the content of the alert * @param content the content of the alert
* @param seconds the number of seconds before the alert is closed, or put 0 to keep it open * @param seconds the number of seconds before the alert is closed, or put 0 to keep it open
* @param onClose What to do after auto close
*/ */
public static void show(String title, String header, String content, int seconds) { public static void show(String title, String header, String content, int seconds, Consumer<String> onClose) {
Platform.runLater(()->{ Platform.runLater(()->{
// close previous alert before showing a new one // close previous alert before showing a new one
Optional.ofNullable(currentAlertStage).ifPresent(Stage::close); Optional.ofNullable(currentAlertStage).ifPresent(Stage::close);
@@ -88,6 +90,7 @@ public class AutoCloseAlert {
if (currentAlertStage == alertStage) { if (currentAlertStage == alertStage) {
currentAlertStage = null; currentAlertStage = null;
} }
if (onClose!=null) onClose.accept(shownTitle);
clear(); clear();
} ); } );
delay.play(); delay.play();

View File

@@ -31,6 +31,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Alert.AlertType;
import org.bytedeco.javacv.OpenCVFrameGrabber; import org.bytedeco.javacv.OpenCVFrameGrabber;
@@ -77,6 +78,8 @@ public class CaptureView {
private String audio_upload_gagal = "upload_gagal.wav"; private String audio_upload_gagal = "upload_gagal.wav";
private String audio_countdown = "countdown321.wav"; private String audio_countdown = "countdown321.wav";
private String audio_tahan_posisi = "tahan_posisi.wav"; private String audio_tahan_posisi = "tahan_posisi.wav";
private String audio_data_barcode_tidak_ditemukan = "data_barcode_tidak_ditemukan.wav";
private String audio_kesalahan_server = "kesalahan_server.wav";
private List<String> cams; private List<String> cams;
@@ -131,7 +134,7 @@ public class CaptureView {
private void TakePhotos(){ private void TakePhotos(){
boolean has_face = Arrays.stream(have_face).anyMatch(AtomicBoolean::get); boolean has_face = Arrays.stream(have_face).anyMatch(AtomicBoolean::get);
if (has_face){ if (has_face){
AutoCloseAlert.show("Pengambilan Foto", "Tahan Posisi Anda", "Proses ini kurang lebih 3 detik", 5); AutoCloseAlert.show("Pengambilan Foto", "Tahan Posisi Anda", "Proses ini kurang lebih 3 detik", 5, null);
if (audioPlayer!=null && audioPlayer.isInited()){ if (audioPlayer!=null && audioPlayer.isInited()){
if (!audioPlayer.getCurrentFile().equals(audio_countdown)) { if (!audioPlayer.getCurrentFile().equals(audio_countdown)) {
audioPlayer.StopCurrentPlayback(); audioPlayer.StopCurrentPlayback();
@@ -170,7 +173,7 @@ public class CaptureView {
double sharpness = CalculateSharpness(image1.getBestMat()); double sharpness = CalculateSharpness(image1.getBestMat());
if (sharpness<sharpness_threshold){ if (sharpness<sharpness_threshold){
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 1 with sharpness score "+sharpness, 5); AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 1 with sharpness score "+sharpness, 5, null);
return null; return null;
} }
PhotoResult p1 = image1.TakePhoto(directory,prefix); PhotoResult p1 = image1.TakePhoto(directory,prefix);
@@ -188,7 +191,7 @@ public class CaptureView {
image2.RemapROI(0.1,0.3, false); image2.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image2.getBestMat()); double sharpness = CalculateSharpness(image2.getBestMat());
if (sharpness<sharpness_threshold){ if (sharpness<sharpness_threshold){
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 2 with sharpness score "+sharpness, 5); AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 2 with sharpness score "+sharpness, 5, null);
return null; return null;
} }
PhotoResult p2 = image2.TakePhoto(directory,prefix); PhotoResult p2 = image2.TakePhoto(directory,prefix);
@@ -207,7 +210,7 @@ public class CaptureView {
image3.RemapROI(0.1,0.3, false); image3.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image3.getBestMat()); double sharpness = CalculateSharpness(image3.getBestMat());
if (sharpness<sharpness_threshold){ if (sharpness<sharpness_threshold){
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 3 with sharpness score "+sharpness, 5); AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 3 with sharpness score "+sharpness, 5, null);
return null; return null;
} }
PhotoResult p3 = image3.TakePhoto(directory,prefix); PhotoResult p3 = image3.TakePhoto(directory,prefix);
@@ -228,7 +231,7 @@ public class CaptureView {
image4.RemapROI(0.1,0.3, false); image4.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image4.getBestMat()); double sharpness = CalculateSharpness(image4.getBestMat());
if (sharpness<sharpness_threshold){ if (sharpness<sharpness_threshold){
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 4 with sharpness score "+sharpness, 5); AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 4 with sharpness score "+sharpness, 5, null);
return null; return null;
} }
PhotoResult p4 = image4.TakePhoto(directory,prefix); PhotoResult p4 = image4.TakePhoto(directory,prefix);
@@ -249,7 +252,7 @@ public class CaptureView {
image5.RemapROI(0.1,0.3, false); image5.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image5.getBestMat()); double sharpness = CalculateSharpness(image5.getBestMat());
if (sharpness<sharpness_threshold){ if (sharpness<sharpness_threshold){
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 5 with sharpness score "+sharpness, 5); AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at Camera 5 with sharpness score "+sharpness, 5, null);
return null; return null;
} }
PhotoResult p5 = image5.TakePhoto(directory,prefix); PhotoResult p5 = image5.TakePhoto(directory,prefix);
@@ -320,7 +323,7 @@ public class CaptureView {
else if (lowest==score3) culprit = "camera 3"; else if (lowest==score3) culprit = "camera 3";
else if (lowest==score4) culprit = "camera 4"; else if (lowest==score4) culprit = "camera 4";
else if (lowest==score5) culprit = "camera 5"; else if (lowest==score5) culprit = "camera 5";
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at "+culprit+" with sharpness score "+lowest, 5); AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at "+culprit+" with sharpness score "+lowest, 5, null);
return; return;
} }
@@ -472,7 +475,7 @@ public class CaptureView {
long duration = (System.nanoTime() - nanostart) / 1000000; // in milliseconds long duration = (System.nanoTime() - nanostart) / 1000000; // in milliseconds
System.out.println("TakePhotos duration: "+duration+" ms"); System.out.println("TakePhotos duration: "+duration+" ms");
AutoCloseAlert.show("Photos Taken", "Photos Taken", "Photos Taken", 5); AutoCloseAlert.show("Photos Taken", "Photos Taken", "Photos Taken", 5, null);
if (audioPlayer!=null && audioPlayer.isInited()){ if (audioPlayer!=null && audioPlayer.isInited()){
if (!audioPlayer.getCurrentFile().equals(audio_pengambilan_berhasil)) { if (!audioPlayer.getCurrentFile().equals(audio_pengambilan_berhasil)) {
@@ -527,7 +530,7 @@ public class CaptureView {
audioPlayer.PlayFile(audio_upload_berhasil, ps); audioPlayer.PlayFile(audio_upload_berhasil, ps);
} else System.out.println("audioPlayer already playing upload berhasil"); } else System.out.println("audioPlayer already playing upload berhasil");
} }
AutoCloseAlert.show("Upload Success", "Upload Success", "Upload Success", 5); AutoCloseAlert.show("Upload Success", "Upload Success", "Upload Success", 5, null);
Platform.runLater(()->{ Platform.runLater(()->{
barcodeData.setText(""); barcodeData.setText("");
medicalRecordID.setText(""); medicalRecordID.setText("");
@@ -546,7 +549,7 @@ public class CaptureView {
} else System.out.println("audioPlayer already playing upload gagal"); } else System.out.println("audioPlayer already playing upload gagal");
} }
AutoCloseAlert.show("Upload Failed", "Upload Failed", "Upload Failed", 5); AutoCloseAlert.show("Upload Failed", "Upload Failed", "Upload Failed", 5, null);
Platform.runLater(()->{ Platform.runLater(()->{
barcodeData.setText(""); barcodeData.setText("");
medicalRecordID.setText(""); medicalRecordID.setText("");
@@ -563,7 +566,7 @@ public class CaptureView {
} else { } else {
AutoCloseAlert.show("Error", "No Face Detected", "No Face Detected", 5); AutoCloseAlert.show("Error", "No Face Detected", "No Face Detected", 5, null);
if (audioPlayer!=null && audioPlayer.isInited()){ if (audioPlayer!=null && audioPlayer.isInited()){
if (!audioPlayer.getCurrentFile().equals(audio_posisikan_muka)) { if (!audioPlayer.getCurrentFile().equals(audio_posisikan_muka)) {
audioPlayer.StopCurrentPlayback(); audioPlayer.StopCurrentPlayback();
@@ -587,6 +590,8 @@ public class CaptureView {
audio_upload_gagal = ExtractResource("/upload_gagal.wav"); audio_upload_gagal = ExtractResource("/upload_gagal.wav");
audio_countdown = ExtractResource("/countdown321.wav"); audio_countdown = ExtractResource("/countdown321.wav");
audio_tahan_posisi = ExtractResource("/tahan_posisi.wav"); audio_tahan_posisi = ExtractResource("/tahan_posisi.wav");
audio_kesalahan_server = ExtractResource("/kesalahan_server.wav");
audio_data_barcode_tidak_ditemukan = ExtractResource("/data_barcode_tidak_ditemukan.wav");
//tambahan 19/03/2025 //tambahan 19/03/2025
@@ -600,7 +605,7 @@ public class CaptureView {
AutoCloseAlert.close(); AutoCloseAlert.close();
} }
} else { } else {
AutoCloseAlert.show("Scan Barcode", "Silahkan Scan Barcode Anda", "Arahkan kertas barcode ke kamera", 0); AutoCloseAlert.show("Scan Barcode", "Silahkan Scan Barcode Anda", "Arahkan kertas barcode ke kamera", 0, null);
} }
} }
}); });
@@ -896,7 +901,7 @@ public class CaptureView {
Platform.runLater(()-> barcodeData.setText(finalbarCode)); Platform.runLater(()-> barcodeData.setText(finalbarCode));
Task<PatientRecord> checkpatientID = new Task<>() { Task<PatientRecord> checkpatientID = new Task<>() {
@Override @Override
protected PatientRecord call() { protected PatientRecord call() throws Exception {
BarcodeResullt br = erhaAPI.Validate_Barcode(finalbarCode,true); BarcodeResullt br = erhaAPI.Validate_Barcode(finalbarCode,true);
if (br!=null){ if (br!=null){
if (br.message.startsWith("Records found")){ if (br.message.startsWith("Records found")){
@@ -906,13 +911,29 @@ public class CaptureView {
if (!pr.name.isEmpty()){ if (!pr.name.isEmpty()){
super.succeeded(); super.succeeded();
return pr; return pr;
} else System.out.println("PatientRecord name is empty"); } else {
} else System.out.println("PatientRecord medical_record_detail_id is empty"); Logger.error("Barcode ",finalbarCode," PatientRecord name is empty");
} else System.out.println("BarcodeResullt data is empty"); throw new Exception("Barcode "+finalbarCode+" PatientRecord name kosong");
} else System.out.println("BarcodeResullt message is not Records found"); }
} else System.out.println("BarcodeResullt is null"); } else {
super.failed(); Logger.error("Barcode ",finalbarCode," PatientRecord medical_record_detail_id is empty");
return null; throw new Exception("Data dengan barcode "+finalbarCode+", PatientRecord medical_record_detail_id kosong");
}
} else {
Logger.error("Record associated with barcode ",finalbarCode," is empty");
//AutoCloseAlert.show("Data Tidak Ditemukan","Data dengan barcode "+finalbarCode+" ditemukan di server, tetapi kosong","Pastikan data barcode anda benar", 5);
throw new Exception("Data dengan barcode "+finalbarCode+" ditemukan di server, tetapi kosong");
}
} else {
Logger.error("Record associated with barcode ",finalbarCode," is not found");
//AutoCloseAlert.show("Data Tidak Ditemukan","Data dengan barcode "+finalbarCode+" tidak ditemukan di server","Pastikan data barcode anda benar",5);
throw new Exception("Data dengan barcode "+finalbarCode+" tidak ditemukan di server");
}
} else {
Logger.error("BarcodeResullt with barcode ",finalbarCode," is null");
//AutoCloseAlert.show("Data Tidak Ditemukan", "BarcodeResult dengan barcode "+finalbarCode+" menghasilkan null", "Pastikan data barcode anda benar", 5);
throw new Exception("BarcodeResult dengan barcode "+finalbarCode+" menghasilkan null");
}
} }
}; };
@@ -937,15 +958,23 @@ public class CaptureView {
}); });
checkpatientID.setOnFailed(event -> { checkpatientID.setOnFailed(event -> {
audioPlayer.PlayFile(audio_data_barcode_tidak_ditemukan,ps);
Task<?> failed = (Task<?>) event.getSource();
Throwable t = failed.getException();
final String message = t.getMessage();
System.out.println("checkpatientID.setOnFailed message : "+message);
AutoCloseAlert.show("Data Tidak Ditemukan", message, "Pastikan data barcode anda benar", 5, new Consumer<String>() {
@Override
public void accept(String s) {
Platform.runLater(()->{ Platform.runLater(()->{
medicalRecordID.setText(""); medicalRecordID.setText("");
PatientName.setText(""); PatientName.setText("");
barcodeData.setText(""); barcodeData.setText("");
isTakingPhoto.set(false); isTakingPhoto.set(false);
}); });
}
});
System.out.println("checkpatientID failed");
AutoCloseAlert.show("Error","checkpatientID failed","checkpatientID failed",5);
}); });
new Thread(checkpatientID).start(); new Thread(checkpatientID).start();
@@ -1024,7 +1053,7 @@ public class CaptureView {
} else { } else {
System.out.println("Prefix invalid, not taking photo"); System.out.println("Prefix invalid, not taking photo");
isTakingPhoto.set(false); isTakingPhoto.set(false);
AutoCloseAlert.show("QR Code Not Available", "", "Please scan QR before continue", 5); AutoCloseAlert.show("QR Code Not Available", "", "Please scan QR before continue", 5, null);
if (audioPlayer!=null && audioPlayer.isInited()){ if (audioPlayer!=null && audioPlayer.isInited()){
if (!audioPlayer.getCurrentFile().equals(audio_scan_barcode)) { if (!audioPlayer.getCurrentFile().equals(audio_scan_barcode)) {
audioPlayer.StopCurrentPlayback(); audioPlayer.StopCurrentPlayback();