commit 08/04/2025

This commit is contained in:
rdkartono
2025-04-08 15:27:12 +07:00
parent 6f3080293f
commit e72d25a213
8 changed files with 621 additions and 637 deletions

View File

@@ -1,6 +1,9 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,java.util.concurrent.Executors,newFixedThreadPool" />
</inspection_tool>
<inspection_tool class="CommentedOutCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="minLines" value="3" />
</inspection_tool>

Binary file not shown.

View File

@@ -3,8 +3,10 @@ package Config;
import com.google.gson.Gson;
import com.google.zxing.MultiFormatReader;
import javafx.application.Platform;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import org.bytedeco.javacv.Java2DFrameConverter;
import org.bytedeco.javacv.OpenCVFrameConverter;
@@ -15,9 +17,9 @@ import org.bytedeco.opencv.opencv_core.Mat;
import org.bytedeco.opencv.opencv_core.Rect;
import org.bytedeco.opencv.opencv_core.Size;
import org.bytedeco.opencv.opencv_core.UMat;
import org.opencv.core.MatOfDouble;
import org.tinylog.Logger;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
@@ -32,7 +34,6 @@ import java.util.ArrayList;
import java.util.List;
import static org.bytedeco.opencv.global.opencv_core.CV_64F;
import static org.bytedeco.opencv.global.opencv_core.CV_64FC3;
@SuppressWarnings("unused")
public class SomeCodes {
@@ -603,6 +604,52 @@ public class SomeCodes {
}
}
public static void SetText(Object obj, String text){
if (obj!=null && text!=null){
if (Platform.isFxApplicationThread()){
if (obj instanceof Label){
((Label) obj).setText(text);
} else if (obj instanceof TextArea){
((TextArea) obj).setText(text);
} else if (obj instanceof TextField){
((TextField) obj).setText(text);
}
} else{
Platform.runLater(()->{
if (obj instanceof Label){
((Label) obj).setText(text);
} else if (obj instanceof TextArea){
((TextArea) obj).setText(text);
} else if (obj instanceof TextField){
((TextField) obj).setText(text);
}
});
}
}
}
public static void LabelVisible(Label label, boolean visible){
if (label!=null){
if (visible){
if (Platform.isFxApplicationThread()){
label.setVisible(true);
} else{
Platform.runLater(()->{
label.setVisible(true);
});
}
} else {
if (Platform.isFxApplicationThread()){
label.setVisible(false);
} else{
Platform.runLater(()->{
label.setVisible(false);
});
}
}
}
}
public static void ShowAlert(Alert.AlertType type, String title, String header, String content){
Alert alert = new Alert(type);
alert.setTitle(title);
@@ -647,15 +694,25 @@ public class SomeCodes {
return false;
}
/**
* Calculate sharpness of image
* @param mat image in UMat format, expected in gray scale
* @return sharpness value
*/
public static double CalculateSharpness(UMat mat){
if (mat!=null && !mat.empty()){
UMat gray = new UMat();
opencv_imgproc.cvtColor(mat, gray, opencv_imgproc.COLOR_BGR2GRAY);
opencv_imgproc.equalizeHist(gray, gray);
if (mat.channels()!=1){
UMat grey = new UMat();
opencv_imgproc.cvtColor(mat, grey, opencv_imgproc.COLOR_BGR2GRAY);
mat = grey;
}
opencv_imgproc.equalizeHist(mat, mat);
UMat laplacian = new UMat();
opencv_imgproc.Laplacian(gray, laplacian, CV_64F);
opencv_imgproc.Laplacian(mat, laplacian, CV_64F);
UMat mean = new UMat(1,1, CV_64F);
UMat stddev = new UMat(1,1, CV_64F);

View File

@@ -111,11 +111,11 @@ public class Cameradetail {
@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();
private @Getter final UMat GrayMat = new UMat();
private @Getter Rect BestMatROI;
private @Getter Rect ReducedMatROI;
@@ -237,6 +237,7 @@ public class Cameradetail {
* @param title Title of the Camera
*/
public void setCameraTitle(String title){
if (ValidString(title)){
if (cameratitle!=null){
cameratitle.setText(title);
@@ -790,33 +791,33 @@ public class Cameradetail {
IsGrabbingLiveView.set(false);
}
public Rect GetFace(UMat mat, boolean isfrontal){
if (!mat.empty()){
Mat originalmat = new Mat();
mat.copyTo(originalmat);
Mat graymat = new Mat();
opencv_imgproc.cvtColor(originalmat,graymat, COLOR_BGR2GRAY); // convert to grayscale
int size = Math.min(graymat.cols(), graymat.rows());
int minsize = (int) (size * 0.4);
int maxsize = (int) (size * 0.9);
System.out.println("GetFace size = "+size+" minsize = "+minsize+" maxsize = "+maxsize);
RectVector faces = isfrontal ? Detectors.DetectFrontalFace(graymat, minsize, maxsize) : Detectors.DetectProfileFace(graymat, minsize, maxsize);
if (faces.size()>0){
Rect result = null;
for(Rect xx : faces.get()){
if (result==null){
result = xx;
} else {
if (xx.area()>result.area()){
result = xx;
}
}
}
return result;
}
} else raise_log("GetFace failed, Mat is empty");
return null;
}
// public Rect GetFace(UMat mat, boolean isfrontal){
// if (!mat.empty()){
// Mat originalmat = new Mat();
// mat.copyTo(originalmat);
// Mat graymat = new Mat();
// opencv_imgproc.cvtColor(originalmat,graymat, COLOR_BGR2GRAY); // convert to grayscale
// int size = Math.min(graymat.cols(), graymat.rows());
// int minsize = (int) (size * 0.4);
// int maxsize = (int) (size * 0.9);
// System.out.println("GetFace size = "+size+" minsize = "+minsize+" maxsize = "+maxsize);
// RectVector faces = isfrontal ? Detectors.DetectFrontalFace(graymat, minsize, maxsize) : Detectors.DetectProfileFace(graymat, minsize, maxsize);
// if (faces.size()>0){
// Rect result = null;
// for(Rect xx : faces.get()){
// if (result==null){
// result = xx;
// } else {
// if (xx.area()>result.area()){
// result = xx;
// }
// }
// }
// return result;
// }
// } else raise_log("GetFace failed, Mat is empty");
// return null;
// }
public boolean StartLiveView(LiveCamEvent event, String cameratitle, final boolean use_qr , final boolean use_face) {
this.event = event;
@@ -880,8 +881,8 @@ public class Cameradetail {
boolean have_fist = false;
int no_face_counter = 0;
int face_counter = 0;
int open_eye_counter = 0;
int close_eye_counter = 0;
//int open_eye_counter = 0;
//int close_eye_counter = 0;
while (Capturing.get()) {
try {
@@ -898,7 +899,7 @@ public class Cameradetail {
} catch (Exception e){
frame = null;
if (e.getMessage()!=null && e.getMessage().length()>0){
if (e.getMessage()!=null && !e.getMessage().isEmpty()){
String msg = e.getMessage();
if (msg.contains("start() been called")){
if (Capturing.get()){
@@ -941,11 +942,10 @@ public class Cameradetail {
if (!BestMat.empty()) {
opencv_imgproc.resize(BestMat, LiveMat, LiveSize); // resize to LiveSize
UMat graymat = new UMat(); // use OpenCL for grayscale
opencv_imgproc.cvtColor(LiveMat,graymat, COLOR_BGR2GRAY); // convert to grayscale
opencv_imgproc.cvtColor(LiveMat,GrayMat, COLOR_BGR2GRAY); // convert to grayscale
if (use_qr){
String qr = DetectQRFromMat(graymat);
String qr = DetectQRFromMat(GrayMat);
if (ValidBarCode(qr)){
qrtext = qr;
if (event!=null) event.onDetectedQRCode(qrtext);
@@ -958,7 +958,7 @@ public class Cameradetail {
_face_width = 0;
_face_height = 0;
List<DetectorResult> frontalfaces = HaveFrontalFace(graymat);
List<DetectorResult> frontalfaces = HaveFrontalFace(GrayMat);
if (!frontalfaces.isEmpty()){
for(DetectorResult rect : frontalfaces){
@@ -974,7 +974,7 @@ public class Cameradetail {
} else {
// gak punya frontal face
// coba cek punya profile left face 45 gak
List<DetectorResult> Left45Faces = HaveLeft45Face(graymat);
List<DetectorResult> Left45Faces = HaveLeft45Face(GrayMat);
if (!Left45Faces.isEmpty()){
for(DetectorResult rect : Left45Faces){
if (rect.haveFace()){
@@ -999,7 +999,7 @@ public class Cameradetail {
no_face_counter = 0;
if (event!=null) event.onFrontalFaceDetector(true, _face_width, _face_height);
face_indicator.setVisible(true);
LabelVisible(face_indicator,true);
if (theface.getFace()!=null){
LiveMatROI = new Rect(theface.getFace().x(), theface.getFace().y(), theface.getFace().width(), theface.getFace().height());
@@ -1008,32 +1008,36 @@ public class Cameradetail {
if (theface.haveEyes()){
// ada mata (buka mata)
close_eye_counter=0;
if (open_eye_counter<1){
open_eye_counter++;
continue;
}
// close_eye_counter=0;
// if (open_eye_counter<1){
// open_eye_counter++;
// continue;
// }
//System.out.println("Valid Open Eyes");
if (eye_state!=1){
// transisi dari tutup mata ke buka mata
if (eye_state==-1) {
System.out.println("First Eye Detected from camera "+cameratitle);
eye_state=1;
continue;
}
System.out.println("Transition from close to open eyes");
eye_state = 1;
if (event!=null) event.onEyeDetector(true);
eye_indicator.setVisible(true);
LabelVisible(eye_indicator,true);
long now = System.currentTimeMillis();
if (waiting_for_second_blink){
long diff = now - last_blink;
// kalau beda waktu antara blink 1 dan blink 2 kurang dari 10 detik
if (diff<=10000){
waiting_for_second_blink = false;
// kalau beda waktu antara blink 1 dan blink 2 kurang dari 2 detik
if (diff<=2000){
System.out.println("Double Blink Detected from camera "+cameratitle);
if (event!=null) event.onBlink((int)diff);
}
waiting_for_second_blink = false;
} else {
waiting_for_second_blink = true;
System.out.println("First Blink Detected from camera "+cameratitle);
@@ -1043,23 +1047,23 @@ public class Cameradetail {
} else {
// ada muka, tidak ada mata
// transisi dari buka mata ke tutup mata
open_eye_counter=0;
if (close_eye_counter<1){
close_eye_counter++;
continue;
}
// open_eye_counter=0;
// if (close_eye_counter<1){
// close_eye_counter++;
// continue;
// }
//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);
LabelVisible(eye_indicator,false);
}
}
} else if (have_left_45_face ){
no_face_counter = 0;
if (event!=null) event.onProfileFaceDetector(true, _face_width, _face_height);
face_indicator.setVisible(true);
LabelVisible(face_indicator,true);
} else {
// no face detected, but let's not cancel the previous state immediately
@@ -1071,17 +1075,17 @@ public class Cameradetail {
last_blink = 0;
waiting_for_second_blink = false;
face_counter = 0;
if (close_eye_counter!=0 || open_eye_counter!=0){
close_eye_counter=0;
open_eye_counter=0;
System.out.println("Reset Open and Close Eyes");
}
// if (close_eye_counter!=0 || open_eye_counter!=0){
// close_eye_counter=0;
// open_eye_counter=0;
// System.out.println("Reset Open and Close Eyes");
// }
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);
LabelVisible(face_indicator,false);
LabelVisible(eye_indicator,false);
}
} else no_face_counter++;
@@ -1089,21 +1093,6 @@ public class Cameradetail {
}
// if (HavePalm(graymat)) {
// if (!have_palm){
// have_fist = false;
// have_palm = true;
// System.out.println("Palm Detected from camera " + cameratitle);
// }
// }
// if (HaveFist(graymat)) {
// if (!have_fist) {
// have_palm = false;
// have_fist = true;
// System.out.println("Fist Detected from camera "+cameratitle);
// }
// }
UMat rgbmat = new UMat(LiveMat.size(), CV_8UC3);
cvtColor(LiveMat, rgbmat, COLOR_BGR2RGB);

View File

@@ -18,6 +18,7 @@ import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.AnchorPane;
import javafx.stage.DirectoryChooser;
@@ -66,32 +67,41 @@ public class CaptureView {
@FXML
private TextArea PatientName;
@FXML
private Button TakePhotoButton;
private AudioPlayer audioPlayer;
private String audio_posisikan_muka = "posisikan_wajah.wav";
private String audio_scan_barcode = "scan_barcode.wav";
private String audio_pengambilan_gagal = "pengambilan_gagal.wav";
private String audio_pengambilan_berhasil = "pengambilan_berhasil.wav";
private String audio_upload_berhasil = "upload_berhasil.wav";
private String audio_upload_gagal = "upload_gagal.wav";
private String audio_countdown = "countdown321.wav";
private String audio_camera_shutter = "camera-shutter-click-01.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 String audio_hubungi_staf_kami = "hubungistafkami.wav";
private List<String> cams;
private final AtomicBoolean[] have_face = new AtomicBoolean[5];
private final AtomicBoolean[] have_eyes = new AtomicBoolean[5];
private final AtomicBoolean[] have_profile = new AtomicBoolean[5];
private final AtomicBoolean[] have_left_ear = new AtomicBoolean[5];
private final AtomicBoolean[] have_right_ear = new AtomicBoolean[5];
private final AtomicBoolean[] have_left_eye = new AtomicBoolean[5];
private final AtomicBoolean[] have_right_eye = new AtomicBoolean[5];
private final AtomicBoolean isTakingPhoto = new AtomicBoolean(false);
private final ErhaAPI erhaAPI = new ErhaAPI(false);
private void TakePhotoButtonChange(){
boolean disabled = false;
String barcode = barcodeData.getText();
String medicalrecord = medicalRecordID.getText();
String patientname = PatientName.getText();
if (barcode.isBlank()) disabled = true;
if (medicalrecord.isBlank()) disabled = true;
if (patientname.isBlank()) disabled = true;
TakePhotoButton.setDisable(disabled);
}
@FXML
private void ChangeDirectory(){
DirectoryChooser dc = new DirectoryChooser();
@@ -126,11 +136,14 @@ public class CaptureView {
@SuppressWarnings("resource")
@FXML
private void TakePhotos(String directory, String prefix){
private void TakePhotos(){
String directory = config.getPhotoDirectory();
String prefix = RemoveSpaces(medicalRecordID.getText()) ;
boolean has_face = Arrays.stream(have_face).anyMatch(AtomicBoolean::get);
if (ValidDirectory(directory)){
if (ValidMedicalRecordId(prefix)){
isTakingPhoto.set(true);
if (has_face){
AutoCloseAlert.show("Pengambilan Foto", "Tahan Posisi Anda", "Proses ini kurang lebih 3 detik", 5, null);
if (audioPlayer!=null && audioPlayer.isInited()){
@@ -144,6 +157,76 @@ public class CaptureView {
@Override
public void onPlaybackFinished(String filename) {
audioPlayer.PlayFile(audio_countdown, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
}
@Override
public void onPlaybackFinished(String filename) {
take_photo_lanjutan(directory, prefix);
}
@Override
public void onPlaybackFailure(String filename) {
}
});
}
@Override
public void onPlaybackFailure(String filename) {
}
});
}
}
} else {
AutoCloseAlert.show("Error", "No Face Detected", "No Face Detected", 5, null);
isTakingPhoto.set(false);
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_posisikan_muka)) {
audioPlayer.StopCurrentPlayback();
audioPlayer.PlayFile(audio_posisikan_muka, null);
}
}
}
} else {
System.out.println("Prefix invalid, not taking photo");
isTakingPhoto.set(false);
//AutoCloseAlert.show("QR Code Not Available", "", "Please scan QR before continue", 5, s -> AutoCloseAlert.show("Scan Barcode", "Silahkan Scan Barcode Anda", "Arahkan kertas barcode ke kamera", 0, null));
if (!Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
if (AutoCloseAlert.banner_01!=null){
System.out.println("Showing banner 01 because prefix invalid");
AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0,null);
}
}
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
audioPlayer.StopCurrentPlayback();
audioPlayer.PlayFile(audio_scan_barcode, null);
}
}
}
} else {
System.out.println("Photo Directory invalid, not taking photo");
isTakingPhoto.set(false);
AutoCloseAlert.show("Invalid Photo Directory","Photo Directory not set", "Please set photo directory at Setting", 5, s -> AutoCloseAlert.show("Setting", "Setting", "Please set photo directory", 0, null));
}
}
private void take_photo_lanjutan(String directory, String prefix){
audioPlayer.PlayFile(audio_camera_shutter, null);
Size thumbsize = new Size(160,120);
PhotoReviewClass prc = new PhotoReviewClass();
@@ -153,13 +236,11 @@ public class CaptureView {
ExecutorService executor = Executors.newFixedThreadPool(5);
audioPlayer.PlayFile(audio_camera_shutter, null);
Callable<PhotoResult> task1 = ()->{
if (image1!=null) {
image1.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image1.getLiveMat());
double sharpness = CalculateSharpness(image1.getGrayMat());
image1.setSharpness_indicator(sharpness);
PhotoResult p1 = image1.TakePhoto(directory,prefix);
p1.setSharpscore(sharpness);
@@ -174,7 +255,7 @@ public class CaptureView {
Callable<PhotoResult> task2 = ()->{
if (image2!=null) {
image2.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image2.getLiveMat());
double sharpness = CalculateSharpness(image2.getGrayMat());
image2.setSharpness_indicator(sharpness);
PhotoResult p2 = image2.TakePhoto(directory,prefix);
p2.setSharpscore(sharpness);
@@ -190,7 +271,7 @@ public class CaptureView {
Callable<PhotoResult> task3 = ()->{
if (image3!=null) {
image3.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image3.getLiveMat());
double sharpness = CalculateSharpness(image3.getGrayMat());
image3.setSharpness_indicator(sharpness);
PhotoResult p3 = image3.TakePhoto(directory,prefix);
p3.setSharpscore(sharpness);
@@ -208,7 +289,7 @@ public class CaptureView {
Callable<PhotoResult> task4 = ()->{
if (image4!=null) {
image4.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image4.getLiveMat());
double sharpness = CalculateSharpness(image4.getGrayMat());
image4.setSharpness_indicator(sharpness);
PhotoResult p4 = image4.TakePhoto(directory,prefix);
p4.setSharpscore(sharpness);
@@ -226,7 +307,7 @@ public class CaptureView {
Callable<PhotoResult> task5 = ()->{
if (image5!=null) {
image5.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image5.getLiveMat());
double sharpness = CalculateSharpness(image5.getGrayMat());
image5.setSharpness_indicator(sharpness);
PhotoResult p5 = image5.TakePhoto(directory,prefix);
p5.setSharpscore(sharpness);
@@ -491,36 +572,6 @@ public class CaptureView {
}
}
@Override
public void onPlaybackFailure(String filename) {
}
});
}
}
// try{
// AutoFocus();
// Thread.sleep(1000);
// } catch (InterruptedException e){
// Logger.error("Error AutoFocus: "+e.getMessage());
// }
} else {
AutoCloseAlert.show("Error", "No Face Detected", "No Face Detected", 5, null);
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_posisikan_muka)) {
audioPlayer.StopCurrentPlayback();
audioPlayer.PlayFile(audio_posisikan_muka, null);
}
}
}
}
private void UploadFiles(PhotoReviewClass prc, String prefix){
String[] files = prc.compressed();
if (files.length>0){
@@ -558,17 +609,6 @@ public class CaptureView {
uploadtask.setOnSucceeded(e-> {
System.out.println("UploadTask succeeded");
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_upload_berhasil)){
audioPlayer.StopCurrentPlayback();
audioPlayer.PlayFile(audio_upload_berhasil, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
}
@Override
public void onPlaybackFinished(String filename) {
Platform.runLater(()->{
AutoCloseAlert.close();
barcodeData.setText("");
@@ -576,25 +616,6 @@ public class CaptureView {
PatientName.setText("");
isTakingPhoto.set(false);
});
}
@Override
public void onPlaybackFailure(String filename) {
}
});
}
}
// AutoCloseAlert.show("Upload Success", "Upload Success", "Upload Success", 5, s -> {
// isTakingPhoto.set(false);
// Platform.runLater(()->{
// barcodeData.setText("");
// medicalRecordID.setText("");
// PatientName.setText("");
// });
// });
});
@@ -627,14 +648,12 @@ public class CaptureView {
audio_pengambilan_berhasil = ExtractResource("/pengambilan_berhasil.wav");
audio_pengambilan_gagal = ExtractResource("/pengambilan_gagal.wav");
audio_scan_barcode = ExtractResource("/scan_barcode.wav");
audio_upload_berhasil = ExtractResource("/upload_berhasil.wav");
audio_upload_gagal = ExtractResource("/upload_gagal.wav");
audio_countdown = ExtractResource("/countdown321.wav");
audio_camera_shutter = ExtractResource("/camera-shutter-click-01.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");
audio_hubungi_staf_kami = ExtractResource("/hubungistafkami.wav");
//tambahan 19/03/2025
barcodeData.textProperty().addListener((observable, oldValue, newValue) -> {
@@ -650,7 +669,10 @@ public class CaptureView {
AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0, null);
}
}
TakePhotoButtonChange();
});
medicalRecordID.textProperty().addListener((observable, oldValue, newValue) -> TakePhotoButtonChange());
PatientName.textProperty().addListener((observable, oldValue, newValue) -> TakePhotoButtonChange());
barcodeData.setText("");
@@ -770,59 +792,6 @@ public class CaptureView {
config.Save();
}
// final PlaybackStatus ps = new PlaybackStatus(){
//
// @Override
// public void onPlaybackStarted(String filename) {
// if (filename.contains(audio_posisikan_muka)){
// Logger.info("Audio Positikan Muka Started");
// } else if (filename.contains(audio_pengambilan_berhasil)){
// Logger.info("Audio Pengambilan Berhasil Started");
// } else if (filename.contains(audio_pengambilan_gagal)){
// Logger.info("Audio Pengambilan Gagal Started");
// } else if (filename.contains(audio_scan_barcode)){
// Logger.info("Audio Scan Barcode Started");
// } else if (filename.contains(audio_upload_berhasil)){
// Logger.info("Audio Upload Berhasil Started");
// } else if (filename.contains(audio_upload_gagal)){
// Logger.info("Audio Upload Gagal Started");
// }
// }
//
// @Override
// public void onPlaybackFinished(String filename) {
// if (filename.contains(audio_posisikan_muka)){
// Logger.info("Audio Positikan Muka Finished");
// } else if (filename.contains(audio_scan_barcode)){
// Logger.info("Audio Scan Barcode Finished");
// } else if (filename.contains(audio_upload_berhasil)){
// Logger.info("Audio Upload Berhasil Finished");
// } else if (filename.contains(audio_upload_gagal)){
// Logger.info("Audio Upload Gagal Finished");
// } else if (filename.contains(audio_pengambilan_berhasil)){
// Logger.info("Audio Pengambilan Berhasil Finished");
// } else if (filename.contains(audio_pengambilan_gagal)){
// Logger.info("Audio Pengambilan Gagal Finished");
// }
// }
//
// @Override
// public void onPlaybackFailure(String filename) {
// if (filename.contains(audio_posisikan_muka)){
// Logger.info("Audio Positikan Muka Failure");
// } else if (filename.contains(audio_upload_gagal)){
// Logger.info("Audio Upload Gagal Failure");
// } else if (filename.contains(audio_upload_berhasil)){
// Logger.info("Audio Upload Berhasil Failure");
// } else if (filename.contains(audio_pengambilan_berhasil)){
// Logger.info("Audio Pengambilan Berhasil Failure");
// } else if (filename.contains(audio_pengambilan_gagal)){
// Logger.info("Audio Pengambilan Gagal Failure");
// } else if (filename.contains(audio_scan_barcode)){
// Logger.info("Audio Scan Barcode Failure");
// }
// }
// };
private void SetupCameraWithController(Cameradetail image, String cameraname, int devicenumber){
if (image!=null){
@@ -859,37 +828,7 @@ public class CaptureView {
case CameraConfigRight90 -> have_eyes[4];
};
final AtomicBoolean _have_left_ear = switch (image.getCameraConfigEnum()){
case CameraConfigCenter -> have_left_ear[2];
case CameraConfigLeft45 -> have_left_ear[1];
case CameraConfigLeft90 -> have_left_ear[0];
case CameraConfigRight45 -> have_left_ear[3];
case CameraConfigRight90 -> have_left_ear[4];
};
final AtomicBoolean _have_right_ear = switch (image.getCameraConfigEnum()){
case CameraConfigCenter -> have_right_ear[2];
case CameraConfigLeft45 -> have_right_ear[1];
case CameraConfigLeft90 -> have_right_ear[0];
case CameraConfigRight45 -> have_right_ear[3];
case CameraConfigRight90 -> have_right_ear[4];
};
final AtomicBoolean _have_left_eye = switch (image.getCameraConfigEnum()){
case CameraConfigCenter -> have_left_eye[2];
case CameraConfigLeft45 -> have_left_eye[1];
case CameraConfigLeft90 -> have_left_eye[0];
case CameraConfigRight45 -> have_left_eye[3];
case CameraConfigRight90 -> have_left_eye[4];
};
final AtomicBoolean _have_right_eye = switch (image.getCameraConfigEnum()){
case CameraConfigCenter -> have_right_eye[2];
case CameraConfigLeft45 -> have_right_eye[1];
case CameraConfigLeft90 -> have_right_eye[0];
case CameraConfigRight45 -> have_right_eye[3];
case CameraConfigRight90 -> have_right_eye[4];
};
Platform.runLater(()-> image.setCameraTitle(title));
if (devicenumber!=-1){
@@ -1065,26 +1004,22 @@ public class CaptureView {
@Override
public void onLeftEarDetector(boolean hasLeftEar, int width, int height) {
// _have_left_ear.set(hasLeftEar);
// update_status(image);
}
@Override
public void onRightEarDetector(boolean hasRightEar, int width, int height) {
// _have_right_ear.set(hasRightEar);
// update_status(image);
}
@Override
public void onLeftEyeDetector(boolean hasLeftEye, int width, int height) {
// _have_left_eye.set(hasLeftEye);
// update_status(image);
}
@Override
public void onRightEyeDetector(boolean hasRightEye, int width, int height) {
// _have_right_eye.set(hasRightEye);
// update_status(image);
}
@Override
@@ -1096,36 +1031,39 @@ public class CaptureView {
@Override
public void onBlink(int counter) {
System.out.println("Blink detected at camera "+title+" delay= "+counter);
if (audioPlayer!=null && audioPlayer.isPlaying()) return; // let audio finish playback
if (isTakingPhoto.get()) return; // other camera is taking picture
String directory = config.getPhotoDirectory();
String prefix = RemoveSpaces(medicalRecordID.getText()) ;
if (ValidDirectory(directory)){
if (ValidMedicalRecordId(prefix)){
isTakingPhoto.set(true);
TakePhotos(directory,prefix);
} else {
System.out.println("Prefix invalid, not taking photo");
isTakingPhoto.set(false);
//AutoCloseAlert.show("QR Code Not Available", "", "Please scan QR before continue", 5, s -> AutoCloseAlert.show("Scan Barcode", "Silahkan Scan Barcode Anda", "Arahkan kertas barcode ke kamera", 0, null));
if (!Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
if (AutoCloseAlert.banner_01!=null){
System.out.println("Showing banner 01 because prefix invalid");
AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0,null);
}
}
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
audioPlayer.StopCurrentPlayback();
audioPlayer.PlayFile(audio_scan_barcode, null);
}
}
}
} else {
System.out.println("Photo Directory invalid, not taking photo");
isTakingPhoto.set(false);
AutoCloseAlert.show("Invalid Photo Directory","Photo Directory not set", "Please set photo directory at Setting", 5, s -> AutoCloseAlert.show("Setting", "Setting", "Please set photo directory", 0, null));
}
// revisi 08/04/2025
TakePhotos();
// String directory = config.getPhotoDirectory();
// String prefix = RemoveSpaces(medicalRecordID.getText()) ;
// if (ValidDirectory(directory)){
// if (ValidMedicalRecordId(prefix)){
// isTakingPhoto.set(true);
// TakePhotos();
// } else {
// System.out.println("Prefix invalid, not taking photo");
// isTakingPhoto.set(false);
// //AutoCloseAlert.show("QR Code Not Available", "", "Please scan QR before continue", 5, s -> AutoCloseAlert.show("Scan Barcode", "Silahkan Scan Barcode Anda", "Arahkan kertas barcode ke kamera", 0, null));
// if (!Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
// if (AutoCloseAlert.banner_01!=null){
// System.out.println("Showing banner 01 because prefix invalid");
// AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0,null);
// }
// }
// if (audioPlayer!=null && audioPlayer.isInited()){
// if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
// audioPlayer.StopCurrentPlayback();
// audioPlayer.PlayFile(audio_scan_barcode, null);
// }
// }
// }
// } else {
// System.out.println("Photo Directory invalid, not taking photo");
// isTakingPhoto.set(false);
// AutoCloseAlert.show("Invalid Photo Directory","Photo Directory not set", "Please set photo directory at Setting", 5, s -> AutoCloseAlert.show("Setting", "Setting", "Please set photo directory", 0, null));
// }
}
@Override
@@ -1146,21 +1084,14 @@ public class CaptureView {
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");
//if (_have_profile.get()) sb.append(", Face");
//if (_have_eye.get()) sb.append(", Eye");
// if (_have_left_eye.get()) sb.append(", Left Eye");
// if (_have_right_eye.get()) sb.append(", Right Eye");
// if (_have_left_ear.get()) sb.append(", Left Ear");
// if (_have_right_ear.get()) sb.append(", Right Ear");
image.setCameraStatus(sb.toString());
String sb = "Camera Started, " +
image.getBestWidth() +
"x" +
image.getBestHeight() +
"@" +
image.getLiveFPS();
image.setCameraStatus(sb);
});
}
};
@@ -1180,10 +1111,7 @@ public class CaptureView {
have_face[camid-1] = new AtomicBoolean(false);
have_eyes[camid-1] = new AtomicBoolean(false);
have_profile[camid-1] = new AtomicBoolean(false);
have_left_ear[camid-1] = new AtomicBoolean(false);
have_right_ear[camid-1] = new AtomicBoolean(false);
have_left_eye[camid-1] = new AtomicBoolean(false);
have_right_eye[camid-1] = new AtomicBoolean(false);
FXMLLoader loader = new FXMLLoader(getClass().getResource("cameradetail.fxml"));
AnchorPane child = loader.load();

View File

@@ -34,7 +34,7 @@ public class MainApplication extends Application {
Screen screen = Screen.getPrimary();
Rectangle2D screenbound = screen.getVisualBounds();
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
stage.setTitle("MultiCam Capture App for ERHA 27032025-001");
stage.setTitle("MultiCam Capture App for ERHA 08042025-003");
stage.setScene(scene);
stage.setResizable(true);
stage.setMaximized(true);

View File

@@ -5,7 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="CaptureViewAnchor" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.co.gtc.erhacam.CaptureView">
<AnchorPane fx:id="CaptureViewAnchor" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="id.co.gtc.erhacam.CaptureView">
<children>
<GridPane layoutX="147.0" layoutY="239.0" AnchorPane.bottomAnchor="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
@@ -38,7 +38,14 @@
<AnchorPane fx:id="controlpane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<padding>
<Insets top="5.0" />
</padding></AnchorPane>
</padding>
<children>
<Button fx:id="TakePhotoButton" disable="true" mnemonicParsing="false" onAction="#TakePhotos" prefHeight="175.0" prefWidth="512.0" text="Take Photo" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
<font>
<Font size="48.0" />
</font>
</Button>
</children></AnchorPane>
<AnchorPane prefHeight="200.0" prefWidth="200.0">
<children>
<GridPane layoutX="68.0" layoutY="14.0" prefHeight="175.2" prefWidth="512.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">

BIN
voices/hubungistafkami.wav Normal file

Binary file not shown.