Commit 18022025
This commit is contained in:
@@ -5,6 +5,7 @@ import Camera.LiveCamEvent;
|
||||
import Camera.ObsbotMeet2Preset;
|
||||
import Config.CameraConfigEnum;
|
||||
import Config.SomeCodes;
|
||||
import ErhaAPI.PhotoResult;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
@@ -109,9 +110,14 @@ public class Cameradetail {
|
||||
private @Getter Rect ReducedMatROI;
|
||||
private @Getter Rect LiveMatROI;
|
||||
|
||||
private Size LiveSize = new Size(640, 360);
|
||||
private Size ReducedSize = new Size(1280, 720);
|
||||
private Size BestSize = new Size(1920, 1080);
|
||||
// private Size LiveSize = new Size(640, 360);
|
||||
// private Size ReducedSize = new Size(1280, 720);
|
||||
// private Size BestSize = new Size(1920, 1080);
|
||||
|
||||
// putar portrait
|
||||
private Size LiveSize = new Size(360, 640);
|
||||
private Size ReducedSize = new Size(720, 1280);
|
||||
private Size BestSize = new Size(2160, 3840);
|
||||
|
||||
//TODO ini angka dari Erha, cek apakah masih cocok atau tidak
|
||||
private @Getter @Setter Size FullCropSize = new Size(1036,1036);
|
||||
@@ -345,15 +351,28 @@ public class Cameradetail {
|
||||
* @param photoheight Height used on photo capture
|
||||
* @param reducedwidth Width used on reduced resolution
|
||||
* @param reducedheight Height used on reduced resolution
|
||||
* @param isPotrait if true, set to portrait mode, otherwise landscape
|
||||
*/
|
||||
public void SetGrabber(OpenCVFrameGrabber grabber, int livewidth, int liveheight, int photowidth, int photoheight, int reducedwidth, int reducedheight){
|
||||
public void SetGrabber(OpenCVFrameGrabber grabber, int livewidth, int liveheight, int photowidth, int photoheight, int reducedwidth, int reducedheight, boolean isPotrait){
|
||||
if (mGrabber!=null) {
|
||||
StopLiveView();
|
||||
}
|
||||
LiveSize = new Size(livewidth, liveheight);
|
||||
BestSize = new Size(photowidth, photoheight);
|
||||
ReducedSize = new Size(reducedwidth, reducedheight);
|
||||
|
||||
if (isPotrait){
|
||||
// putar portrait
|
||||
LiveSize = new Size(liveheight, livewidth);
|
||||
BestSize = new Size(photoheight, photowidth);
|
||||
ReducedSize = new Size(reducedheight, reducedwidth);
|
||||
} else {
|
||||
LiveSize = new Size(livewidth, liveheight);
|
||||
BestSize = new Size(photowidth, photoheight);
|
||||
ReducedSize = new Size(reducedwidth, reducedheight);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mGrabber = grabber;
|
||||
|
||||
}
|
||||
|
||||
//Exposure and Focus Tricks :
|
||||
@@ -545,9 +564,8 @@ public class Cameradetail {
|
||||
* @param ROI_Compressed Region of Interest for Compressed Photo. If Null, will not save cropped photo
|
||||
* @return filename path of the saved photo, or null if failed
|
||||
*/
|
||||
@SuppressWarnings("BusyWait")
|
||||
public String TakePhoto(String directory, String prefix, Rect ROI_Full, Rect ROI_Compressed) throws InterruptedException {
|
||||
String result = null;
|
||||
public PhotoResult TakePhoto(String directory, String prefix, Rect ROI_Full, Rect ROI_Compressed) throws InterruptedException {
|
||||
PhotoResult result = new PhotoResult(cameratitle.getText());
|
||||
if (!ValidDirectory(directory)) directory = currentDirectory;
|
||||
|
||||
if (mGrabber!=null){
|
||||
@@ -577,33 +595,31 @@ public class Cameradetail {
|
||||
// save BestMat at quality 9 PNG
|
||||
String filename = Path.of(directory, "FullQuality", makeFileName(prefix,".png")).toString();
|
||||
if (imwrite(filename, BestMat, parampng)){
|
||||
result = filename;
|
||||
result.setFullres(filename);
|
||||
} else System.out.println("TakePhoto failed, Unable to Save FullQUality Photo for camera "+cameratitle.getText());
|
||||
|
||||
if (ROIInsideUMat(ROI_Full, BestMat)){
|
||||
// save ROI_Full at 100% JPEG
|
||||
UMat FullCrop = CropUMat(BestMat, ROI_Full);
|
||||
if (FullCrop!=null){
|
||||
String roifilename = Path.of(directory, "FullQualityCrop", makeFileName(prefix,".png")).toString();
|
||||
UMat ROI = new UMat(BestMat, ROI_Full);
|
||||
if (!imwrite(roifilename, ROI, paramjpeg)){
|
||||
if (!imwrite(roifilename, FullCrop, parampng)){
|
||||
System.out.println("TakePhoto failed, Unable to Save FullQUalityCrop for camera "+cameratitle.getText());
|
||||
}
|
||||
} else System.out.println("ROI_Full is outside of BestMat for camera "+cameratitle.getText());
|
||||
} else result.setFullcrop(roifilename);
|
||||
}
|
||||
|
||||
// save ReducedMat at 100% JPEG
|
||||
String reducedfilename = Path.of(directory, "Compressed", makeReducedFileName(prefix,".jpg")).toString();
|
||||
opencv_imgproc.resize(BestMat, ReducedMat, ReducedSize);
|
||||
if (!imwrite(reducedfilename, ReducedMat, paramjpeg)){
|
||||
System.out.println("TakePhoto failed, Unable to Save Reduced Photo for camera "+cameratitle.getText());
|
||||
}
|
||||
} else result.setCompressedfile(reducedfilename);
|
||||
|
||||
if (ROIInsideUMat(ROI_Compressed, ReducedMat)){
|
||||
// save ROI_Compressed at 100% JPEG
|
||||
UMat CompressedCrop = CropUMat(ReducedMat, ROI_Compressed);
|
||||
if (CompressedCrop!=null){
|
||||
String roifilename = Path.of(directory, "CompressedCrop", makeReducedFileName(prefix,".jpg")).toString();
|
||||
UMat ROI = new UMat(ReducedMat, ROI_Compressed);
|
||||
if (!imwrite(roifilename, ROI, paramjpeg)){
|
||||
if (!imwrite(roifilename, CompressedCrop, paramjpeg)){
|
||||
System.out.println("TakePhoto failed, Unable to Save CompressedCrop for camera "+cameratitle.getText());
|
||||
}
|
||||
} else System.out.println("ROI_Compressed is outside of ReducedMat for camera "+cameratitle.getText());
|
||||
} else result.setCompressedcrop(roifilename);
|
||||
}
|
||||
|
||||
|
||||
} else raise_log("TakePhoto failed, Live View is Empty");
|
||||
@@ -699,7 +715,8 @@ public class Cameradetail {
|
||||
int _face_height;
|
||||
boolean have_palm = false;
|
||||
boolean have_fist = false;
|
||||
long no_face_counter = 0;
|
||||
int no_face_counter = 0;
|
||||
int face_counter = 0;
|
||||
|
||||
while (Capturing.get()) {
|
||||
try {
|
||||
@@ -710,23 +727,30 @@ public class Cameradetail {
|
||||
|
||||
if (!Capturing.get()) return null;
|
||||
IsGrabbingLiveView.set(true);
|
||||
Frame frame = mGrabber.grab(); // grab frame
|
||||
Frame frame=null;
|
||||
try{
|
||||
frame = mGrabber.grab(); // grab frame
|
||||
} catch (Exception e){
|
||||
System.out.println("Exception on grab frame from camera "+cameratitle+", Message : "+e.getMessage());
|
||||
}
|
||||
if (frame==null) continue;
|
||||
Mat mat = matconverter.convert(frame); // convert to Mat
|
||||
fps.incrementAndGet();
|
||||
|
||||
mat.copyTo(BestMat); // copy to BestMat for using OpenCL
|
||||
UMat originalmat = new UMat();
|
||||
mat.copyTo(originalmat); // copy to BestMat for using OpenCL
|
||||
opencv_core.rotate(originalmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
||||
IsGrabbingLiveView.set(false);
|
||||
|
||||
if (frame != null) {
|
||||
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
|
||||
if (use_qr){
|
||||
String qr = DetectQRFromMat(graymat);
|
||||
if (ValidPatientID(qr)){
|
||||
if (ValidBarCode(qr)){
|
||||
if (!qr.equals(qrtext)){
|
||||
qrtext = qr;
|
||||
raise_log("QR Detected: " + qrtext);
|
||||
if (event!=null) event.onDetectedQRCode(qrtext);
|
||||
}
|
||||
}
|
||||
@@ -771,6 +795,12 @@ public class Cameradetail {
|
||||
|
||||
if (have_frontal_face){
|
||||
|
||||
if (face_counter<5){
|
||||
face_counter++;
|
||||
//System.out.println("Frontal Face Counter = "+face_counter+ " from camera "+cameratitle+" eye count = "+theface.getEyesCount());
|
||||
continue;
|
||||
}
|
||||
|
||||
no_face_counter = 0;
|
||||
if (event!=null) event.onFrontalFaceDetector(true, _face_width, _face_height);
|
||||
LiveMatROI = theface.getFace();
|
||||
@@ -805,20 +835,25 @@ public class Cameradetail {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else if (have_left_45_face ){
|
||||
|
||||
no_face_counter = 0;
|
||||
LiveMatROI = theface.getFace();
|
||||
if (event!=null) event.onProfileFaceDetector(true, _face_width, _face_height);
|
||||
} else {
|
||||
// no face detected, but lets not cancel the previous state immediately
|
||||
|
||||
if (no_face_counter>30){
|
||||
|
||||
} else {
|
||||
// no face detected, but let's not cancel the previous state immediately
|
||||
|
||||
if (no_face_counter>60){
|
||||
// kalau tidak ada face selama 30 frame, reset state
|
||||
// 30 frame approximately 2 second
|
||||
// 60 frame approximately 2 second
|
||||
eye_state = -1;
|
||||
last_blink = 0;
|
||||
waiting_for_second_blink = false;
|
||||
face_counter = 0;
|
||||
if (event!=null) {
|
||||
event.onFrontalFaceDetector(false, _face_width, _face_height);
|
||||
event.onProfileFaceDetector(false, _face_width, _face_height);
|
||||
@@ -880,16 +915,26 @@ public class Cameradetail {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RemapROI(){
|
||||
/**
|
||||
* Remap LiveMatROI to BestMatROI and ReducedMatROI Resolution
|
||||
* @param scale scale factor, 1.0 for 100%, 0.5 for 50%, etc
|
||||
*/
|
||||
public void RemapROI(double scale){
|
||||
if (ValidROI(LiveMatROI)){
|
||||
if (ROIInsideUMat(LiveMatROI, LiveMat)){
|
||||
System.out.println("LiveMatROI camera "+cameratitle.getText()+" = "+RectToString(LiveMatROI));
|
||||
double scaleXBest = 1.0*BestSize.width()/LiveSize.width();
|
||||
double scaleYBest = 1.0*BestSize.height()/LiveSize.height();
|
||||
double scaleXReduced = 1.0*ReducedSize.width()/LiveSize.width();
|
||||
double scaleYReduced = 1.0*ReducedSize.height()/LiveSize.height();
|
||||
BestMatROI = ScaleRect(LiveMatROI, scaleXBest, scaleYBest);
|
||||
ReducedMatROI = ScaleRect(LiveMatROI, scaleXReduced, scaleYReduced);
|
||||
|
||||
double scaleXBest = scale*BestSize.width()/LiveSize.width();
|
||||
double scaleYBest = scale*BestSize.height()/LiveSize.height();
|
||||
System.out.println("scaleXBest = "+scaleXBest+" scaleYBest = "+scaleYBest);
|
||||
double scaleXReduced = scale*ReducedSize.width()/LiveSize.width();
|
||||
double scaleYReduced = scale*ReducedSize.height()/LiveSize.height();
|
||||
System.out.println("scaleXReduced = "+scaleXReduced+" scaleYReduced = "+scaleYReduced);
|
||||
|
||||
BestMatROI = ResizeRect(LiveMatROI, scaleXBest, scaleYBest, 50,250);
|
||||
System.out.println("BestMatROI camera "+cameratitle.getText()+" = "+RectToString(BestMatROI));
|
||||
ReducedMatROI = ResizeRect(LiveMatROI, scaleXReduced, scaleYReduced, 50,250);
|
||||
System.out.println("ReducedMatROI camera "+cameratitle.getText()+" = "+RectToString(ReducedMatROI));
|
||||
|
||||
} else {
|
||||
System.out.println("LiveMatROI is Outside LiveMat for camera "+cameratitle.getText());
|
||||
|
||||
@@ -4,9 +4,13 @@ import BASS.AudioPlayer;
|
||||
import BASS.PlaybackStatus;
|
||||
import Camera.*;
|
||||
import Config.CameraConfigEnum;
|
||||
import Config.SomeCodes;
|
||||
import Database.PhotoReviewClass;
|
||||
import Database.Sqlite;
|
||||
import ErhaAPI.ErhaAPI;
|
||||
import ErhaAPI.BarcodeResullt;
|
||||
import ErhaAPI.PhotoResult;
|
||||
import ErhaAPI.PatientRecord;
|
||||
import ErhaAPI.UploadResult;
|
||||
import FTP.FTPUpload;
|
||||
import FTP.FTPUploadEvent;
|
||||
import FTP.FtpMonitorData;
|
||||
@@ -33,6 +37,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
||||
import org.bytedeco.javacv.VideoInputFrameGrabber;
|
||||
import org.bytedeco.opencv.opencv_core.Rect;
|
||||
import org.bytedeco.opencv.opencv_core.Size;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
@@ -44,13 +49,30 @@ public class CaptureView {
|
||||
private AnchorPane CaptureViewAnchor;
|
||||
|
||||
@FXML
|
||||
private AnchorPane cam1, cam2, cam3, cam4, cam5, controlpane;
|
||||
private AnchorPane cam1;
|
||||
@FXML
|
||||
private AnchorPane cam2;
|
||||
@FXML
|
||||
private AnchorPane cam3;
|
||||
@FXML
|
||||
private AnchorPane cam4;
|
||||
@FXML
|
||||
private AnchorPane cam5;
|
||||
@FXML
|
||||
private AnchorPane controlpane;
|
||||
|
||||
private Cameradetail image1, image2, image3, image4, image5;
|
||||
|
||||
|
||||
@FXML
|
||||
private TextArea directorypath, prefixfile;
|
||||
private TextArea directorypath;
|
||||
@FXML
|
||||
private TextArea barcodeData;
|
||||
@FXML
|
||||
private TextArea medicalRecordID;
|
||||
@FXML
|
||||
private TextArea PatientName;
|
||||
|
||||
@FXML
|
||||
private Button btnTakePhoto;
|
||||
@FXML
|
||||
@@ -80,6 +102,8 @@ public class CaptureView {
|
||||
private final AtomicBoolean[] have_right_eye = new AtomicBoolean[5];
|
||||
private final AtomicBoolean isTakingPhoto = new AtomicBoolean(false);
|
||||
|
||||
private final ErhaAPI erhaAPI = new ErhaAPI(false);
|
||||
|
||||
@FXML
|
||||
private void ChangeDirectory(){
|
||||
DirectoryChooser dc = new DirectoryChooser();
|
||||
@@ -95,11 +119,11 @@ public class CaptureView {
|
||||
if (image!=null){
|
||||
if (image.isCapturing()){
|
||||
image.setAutoFocus(false);
|
||||
Thread.sleep(2);
|
||||
image.setFocus(0.9);
|
||||
Thread.sleep(2);
|
||||
Thread.sleep(5);
|
||||
image.setFocus(0.7);
|
||||
Thread.sleep(5);
|
||||
image.setAutoFocus(true);
|
||||
Thread.sleep(2);
|
||||
Thread.sleep(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,16 +143,27 @@ public class CaptureView {
|
||||
private void TakePhotos(){
|
||||
boolean has_face = Arrays.stream(have_face).anyMatch(AtomicBoolean::get);
|
||||
if (has_face){
|
||||
if (audioPlayer.isPlaying()) audioPlayer.StopCurrentPlayback();
|
||||
audioPlayer.PlayFile(audio_countdown, ps);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_countdown)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_countdown, ps);
|
||||
}
|
||||
|
||||
btnAutoFocus.fire();
|
||||
|
||||
try{
|
||||
AutoFocus();
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e){
|
||||
Logger.error("Error AutoFocus: "+e.getMessage());
|
||||
}
|
||||
|
||||
Size thumbsize = new Size(160,120);
|
||||
String directory = directorypath.getText();
|
||||
String prefix = RemoveSpaces(prefixfile.getText()) ;
|
||||
String prefix = RemoveSpaces(medicalRecordID.getText()) ;
|
||||
if (ValidDirectory(directory)){
|
||||
if (ValidPatientID(prefix)){
|
||||
if (ValidMedicalRecordId(prefix)){
|
||||
|
||||
PhotoReviewClass prc = new PhotoReviewClass();
|
||||
prc.setPrefix(prefix);
|
||||
@@ -137,75 +172,181 @@ public class CaptureView {
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||
|
||||
// face detection Rect ROI to head detection Rect ROI
|
||||
// head is bigger than face, so we need to scale it
|
||||
final double face_to_head_scale = 1.2;
|
||||
Rect bestsize = new Rect(0,0,0,0);
|
||||
Rect reducedsize = new Rect(0,0,0,0);
|
||||
|
||||
if (image1!=null) {
|
||||
image1.RemapROI(face_to_head_scale);
|
||||
if (image1.getBestMatROI()!=null && image1.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image1.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
|
||||
if (image1.getReducedMatROI()!=null && image1.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image1.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image2!=null) {
|
||||
image2.RemapROI(face_to_head_scale);
|
||||
if (image2.getBestMatROI()!=null && image2.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image2.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image2.getReducedMatROI()!=null && image2.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image2.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image3!=null) {
|
||||
image3.RemapROI(face_to_head_scale);
|
||||
if (image3.getBestMatROI()!=null && image3.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image3.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image3.getReducedMatROI()!=null && image3.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image3.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image4!=null) {
|
||||
image4.RemapROI(face_to_head_scale);
|
||||
if (image4.getBestMatROI()!=null && image4.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image4.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image4.getReducedMatROI()!=null && image4.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image4.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image5!=null) {
|
||||
image5.RemapROI(face_to_head_scale);
|
||||
if (image5.getBestMatROI()!=null && image5.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image5.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image5.getReducedMatROI()!=null && image5.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image5.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
|
||||
// find biggest BestROI and ReducedROI
|
||||
final Rect finalbestsize = bestsize;
|
||||
final Rect finalreducedsize = reducedsize;
|
||||
|
||||
|
||||
Callable<String> task1 = ()->{
|
||||
if (image1!=null) {
|
||||
image1.RemapROI();
|
||||
String p1 = image1.TakePhoto(directory,prefix, image1.getBestMatROI(), image1.getReducedMatROI());
|
||||
if (ValidFile(p1)) {
|
||||
Platform.runLater(()->image1.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p1)));
|
||||
|
||||
prc.setFileLeft90(p1);
|
||||
String thumb1 = MakeThumbfile(p1, thumbsize);
|
||||
image1.RemapROI(face_to_head_scale);
|
||||
PhotoResult p1 = image1.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p1.getFullres())) {
|
||||
prc.setFileLeft90(p1.getFullres());
|
||||
String thumb1 = MakeThumbfile(p1.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb1)) {
|
||||
prc.setThumbLeft90(thumb1);
|
||||
}
|
||||
} else System.out.println("Image1 ValidFile is false");
|
||||
if (ValidFile(p1.getCompressedfile())){
|
||||
prc.setCompressedLeft90(p1.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p1.getFullcrop())){
|
||||
prc.setCroppedLeft90(p1.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p1.getCompressedcrop())){
|
||||
prc.setCompressedCropLeft90(p1.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image1 is null");
|
||||
return "Task 1 Done";
|
||||
};
|
||||
Callable<String> task2 = ()->{
|
||||
if (image2!=null) {
|
||||
image2.RemapROI();
|
||||
String p2 = image2.TakePhoto(directory,prefix, image2.getBestMatROI(), image2.getReducedMatROI());
|
||||
if (ValidFile(p2)) {
|
||||
Platform.runLater(()->image2.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p2)));
|
||||
|
||||
prc.setFileLeft45(p2);
|
||||
String thumb2 = MakeThumbfile(p2, thumbsize);
|
||||
image2.RemapROI(face_to_head_scale);
|
||||
PhotoResult p2 = image2.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p2.getFullres())) {
|
||||
prc.setFileLeft45(p2.getFullres());
|
||||
String thumb2 = MakeThumbfile(p2.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb2)) prc.setThumbLeft45(thumb2);
|
||||
} else System.out.println("Image2 ValidFile is false");
|
||||
if (ValidFile(p2.getCompressedfile())){
|
||||
prc.setCompressedLeft45(p2.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p2.getFullcrop())){
|
||||
prc.setCroppedLeft45(p2.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p2.getCompressedcrop())){
|
||||
prc.setCompressedCropLeft45(p2.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image2 is null");
|
||||
return "Task 2 Done";
|
||||
};
|
||||
|
||||
Callable<String> task3 = ()->{
|
||||
if (image3!=null) {
|
||||
image3.RemapROI();
|
||||
String p3 = image3.TakePhoto(directory,prefix, image3.getBestMatROI(), image3.getReducedMatROI());
|
||||
if (ValidFile(p3)) {
|
||||
Platform.runLater(()->image3.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p3)));
|
||||
prc.setFileCenter(p3);
|
||||
String thumb3 = MakeThumbfile(p3, thumbsize);
|
||||
image3.RemapROI(face_to_head_scale);
|
||||
PhotoResult p3 = image3.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p3.getFullres())) {
|
||||
prc.setFileCenter(p3.getFullres());
|
||||
String thumb3 = MakeThumbfile(p3.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb3)) prc.setThumbCenter(thumb3);
|
||||
} else System.out.println("Image3 ValidFile is false");
|
||||
if (ValidFile(p3.getCompressedfile())){
|
||||
prc.setCompressedCenter(p3.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p3.getFullcrop())){
|
||||
prc.setCroppedCenter(p3.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p3.getCompressedcrop())){
|
||||
prc.setCompressedCropCenter(p3.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image3 is null");
|
||||
return "Task 3 Done";
|
||||
};
|
||||
|
||||
Callable<String> task4 = ()->{
|
||||
if (image4!=null) {
|
||||
image4.RemapROI();
|
||||
String p4 = image4.TakePhoto(directory,prefix, image4.getBestMatROI(), image4.getReducedMatROI());
|
||||
if (ValidFile(p4)) {
|
||||
Platform.runLater(()->image4.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p4)));
|
||||
prc.setFileRight45(p4);
|
||||
String thumb4 = MakeThumbfile(p4, thumbsize);
|
||||
image4.RemapROI(face_to_head_scale);
|
||||
PhotoResult p4 = image4.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p4.getFullres())) {
|
||||
prc.setFileRight45(p4.getFullres());
|
||||
String thumb4 = MakeThumbfile(p4.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb4)) prc.setThumbRight45(thumb4);
|
||||
} else System.out.println("Image4 ValidFile is false");
|
||||
if (ValidFile(p4.getCompressedfile())){
|
||||
prc.setCompressedRight45(p4.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p4.getFullcrop())){
|
||||
prc.setCroppedRight45(p4.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p4.getCompressedcrop())){
|
||||
prc.setCompressedCropRight45(p4.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image4 is null");
|
||||
return "Task 4 Done";
|
||||
};
|
||||
|
||||
Callable<String> task5 = ()->{
|
||||
if (image5!=null) {
|
||||
image5.RemapROI();
|
||||
String p5 = image5.TakePhoto(directory,prefix, image5.getBestMatROI(), image5.getReducedMatROI());
|
||||
if (ValidFile(p5)) {
|
||||
Platform.runLater(()->image5.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p5)));
|
||||
prc.setFileRight90(p5);
|
||||
String thumb5 = MakeThumbfile(p5, thumbsize);
|
||||
image5.RemapROI(face_to_head_scale);
|
||||
PhotoResult p5 = image5.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p5.getFullres())) {
|
||||
prc.setFileRight90(p5.getFullres());
|
||||
String thumb5 = MakeThumbfile(p5.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb5)) prc.setThumbRight90(thumb5);
|
||||
} else System.out.println("Image5 ValidFile is false");
|
||||
if (ValidFile(p5.getCompressedfile())){
|
||||
prc.setCompressedRight90(p5.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p5.getFullcrop())){
|
||||
prc.setCroppedRight90(p5.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p5.getCompressedcrop())){
|
||||
prc.setCompressedCropRight90(p5.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image5 is null");
|
||||
return "Task 5 Done";
|
||||
};
|
||||
@@ -231,21 +372,81 @@ public class CaptureView {
|
||||
long duration = (System.nanoTime() - nanostart) / 1000000; // in milliseconds
|
||||
System.out.println("TakePhotos duration: "+duration+" ms");
|
||||
|
||||
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_pengambilan_berhasil.equals((audioPlayer.getCurrentFile()))){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_pengambilan_berhasil)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_pengambilan_berhasil, ps);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_pengambilan_berhasil, ps);
|
||||
String[] files = prc.files();
|
||||
if (files!=null && files.length>0){
|
||||
|
||||
String[] files = prc.compressed();
|
||||
|
||||
if (files.length>0){
|
||||
InsertSQL(prc);
|
||||
|
||||
progressanchor.getChildren().clear();
|
||||
prefixfile.setText("");
|
||||
Task<Void> uploadtask = new Task<>() {
|
||||
@Override
|
||||
protected Void call() {
|
||||
int totalfiles = files.length;
|
||||
int counter = 0;
|
||||
for (String ff : files) {
|
||||
UploadResult ur = erhaAPI.Upload_File(prefix, ff);
|
||||
if (ur != null) {
|
||||
if (ur.message.startsWith("Record has been created")) {
|
||||
counter++;
|
||||
updateMessage("Upload success for " + ff);
|
||||
} else updateMessage("Upload failed for " + ff+", Message : "+ur.message);
|
||||
} else updateMessage("Upload failed for " + ff+" because UploadResult is null");
|
||||
|
||||
}
|
||||
if (counter == totalfiles) {
|
||||
super.succeeded();
|
||||
} else super.failed();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
uploadtask.messageProperty().addListener((obs, oldval, newval)-> {
|
||||
System.out.println("UploadTask message: "+newval);
|
||||
Logger.info(newval);
|
||||
});
|
||||
|
||||
|
||||
uploadtask.setOnSucceeded(e-> {
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_upload_berhasil)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_upload_berhasil, ps);
|
||||
audioPlayer.WaitUntilFinished();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
uploadtask.setOnFailed(e-> {
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_upload_gagal)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_upload_gagal, ps);
|
||||
audioPlayer.WaitUntilFinished();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
new Thread(uploadtask).start();
|
||||
|
||||
|
||||
progressanchor.getChildren().clear();
|
||||
barcodeData.setText("");
|
||||
medicalRecordID.setText("");
|
||||
PatientName.setText("");
|
||||
|
||||
//TODO ganti ke API upload
|
||||
|
||||
// new Thread(()-> {
|
||||
// try{
|
||||
@@ -294,19 +495,21 @@ public class CaptureView {
|
||||
}
|
||||
|
||||
} else {
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_posisikan_muka.equals((audioPlayer.getCurrentFile()))){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_posisikan_muka)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
|
||||
}
|
||||
|
||||
isTakingPhoto.set(false);
|
||||
}
|
||||
|
||||
private void UpdateBtnTakePhoto(){
|
||||
boolean valid = ValidDirectory(directorypath.getText()) && ValidString(prefixfile.getText());
|
||||
boolean valid = ValidDirectory(directorypath.getText()) && ValidString(barcodeData.getText()) && ValidString(medicalRecordID.getText()) && ValidString(PatientName.getText());
|
||||
btnTakePhoto.setDisable(!valid);
|
||||
}
|
||||
|
||||
@@ -326,8 +529,9 @@ public class CaptureView {
|
||||
btnTakePhoto.setDisable(true);
|
||||
|
||||
directorypath.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
prefixfile.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
|
||||
barcodeData.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
medicalRecordID.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
PatientName.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
cams = null;
|
||||
try{
|
||||
String[] xxx = VideoInputFrameGrabber.getDeviceDescriptions();
|
||||
@@ -600,27 +804,69 @@ public class CaptureView {
|
||||
reducewidth = ObsbotMeet2.Mode3.getWidth();
|
||||
reduceheight = ObsbotMeet2.Mode3.getHeight();
|
||||
}
|
||||
image.SetGrabber(grabber, livewidth,liveheight,photowidth,photoheight,reducewidth,reduceheight);
|
||||
image.SetGrabber(grabber, livewidth,liveheight,photowidth,photoheight,reducewidth,reduceheight, true);
|
||||
|
||||
boolean use_face_detector = true;
|
||||
boolean use_qr_detector = true;
|
||||
|
||||
LiveCamEvent lce = new LiveCamEvent() {
|
||||
@Override
|
||||
public void onDetectedQRCode(String qrCode) {
|
||||
qrCode = RemoveSpaces(qrCode);
|
||||
if (ValidPatientID(qrCode)){
|
||||
String prefix = prefixfile.getText();
|
||||
if (!qrCode.equals(prefix)){
|
||||
String finalQrCode = qrCode;
|
||||
System.out.println("PatientID detected: "+finalQrCode);
|
||||
Platform.runLater(()->prefixfile.setText(finalQrCode));
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_posisikan_muka.equals((audioPlayer.getCurrentFile()))){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
public void onDetectedQRCode(String barCode) {
|
||||
barCode = RemoveSpaces(barCode);
|
||||
if (ValidBarCode(barCode)){
|
||||
String prefix = barcodeData.getText();
|
||||
if (!barCode.equals(prefix)){
|
||||
String finalbarCode = barCode;
|
||||
Platform.runLater(()-> barcodeData.setText(finalbarCode));
|
||||
Task<PatientRecord> checkpatientID = new Task<>() {
|
||||
@Override
|
||||
protected PatientRecord call() {
|
||||
BarcodeResullt br = erhaAPI.Validate_Barcode(finalbarCode);
|
||||
if (br!=null){
|
||||
if (br.message.startsWith("Records found")){
|
||||
if (br.data!=null && br.data.length>0){
|
||||
PatientRecord pr = br.data[0];
|
||||
if (!pr.medical_record_detail_id.isEmpty()){
|
||||
if (!pr.name.isEmpty()){
|
||||
super.succeeded();
|
||||
return pr;
|
||||
} else System.out.println("PatientRecord name is empty");
|
||||
} else System.out.println("PatientRecord medical_record_detail_id is empty");
|
||||
} else System.out.println("BarcodeResullt data is empty");
|
||||
} else System.out.println("BarcodeResullt message is not Records found");
|
||||
} else System.out.println("BarcodeResullt is null");
|
||||
super.failed();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
};
|
||||
|
||||
checkpatientID.setOnSucceeded(event -> {
|
||||
PatientRecord pr = checkpatientID.getValue();
|
||||
if (pr!=null){
|
||||
int medrecid = toInt(pr.medical_record_detail_id);
|
||||
medicalRecordID.setText(medrecid+"");
|
||||
PatientName.setText(pr.name);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_posisikan_muka)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
checkpatientID.setOnFailed(event -> {
|
||||
medicalRecordID.setText("");
|
||||
PatientName.setText("");
|
||||
barcodeData.setText("");
|
||||
System.out.println("checkpatientID failed");
|
||||
});
|
||||
|
||||
new Thread(checkpatientID).start();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -687,23 +933,21 @@ public class CaptureView {
|
||||
if (isTakingPhoto.get()) return; // other camera is taking picture
|
||||
System.out.println("Blink detected at camera "+title+" delay= "+counter);
|
||||
isTakingPhoto.set(true);
|
||||
Platform.runLater(()->{
|
||||
|
||||
String prefix = prefixfile.getText();
|
||||
if (prefix.length()==10){
|
||||
System.out.println("Prefix valid, taking photo");
|
||||
btnTakePhoto.fire();
|
||||
} else {
|
||||
System.out.println("Prefix not valid, not taking photo");
|
||||
isTakingPhoto.set(false);
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_scan_barcode.equals((audioPlayer.getCurrentFile()))){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
}
|
||||
String prefix = medicalRecordID.getText();
|
||||
if (!prefix.isEmpty()){
|
||||
System.out.println("Prefix valid, taking photo");
|
||||
btnTakePhoto.fire();
|
||||
} else {
|
||||
isTakingPhoto.set(false);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_scan_barcode)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_scan_barcode, ps);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -916,7 +1160,10 @@ public class CaptureView {
|
||||
public void onUploadFinished(int total, int success, int failed, String[] files) {
|
||||
Logger.info("Upload Finished, Total: {}, Success: {}, Failed: {}", total, success, failed);
|
||||
Platform.runLater(()->{
|
||||
if (audioPlayer.isPlaying()) audioPlayer.StopCurrentPlayback();
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_upload_berhasil)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_upload_berhasil, ps);
|
||||
Alert Alert = new Alert(AlertType.INFORMATION);
|
||||
Alert.setTitle("Upload Finished");
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Detectors {
|
||||
private static void LoadFistDetector(){
|
||||
String filename = SomeCodes.ExtractResource("/fist.xml");
|
||||
if (filename!=null) {
|
||||
System.out.println("Fist Detector file : " + filename);
|
||||
Logger.info("Fist Detector file : " + filename);
|
||||
if (fistDetector ==null) {
|
||||
try{
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Detectors {
|
||||
private static void LoadRightPalmDetector(){
|
||||
String filename = SomeCodes.ExtractResource("/rpalm.xml");
|
||||
if (filename!=null) {
|
||||
System.out.println("Right Palm Detector file : " + filename);
|
||||
Logger.info("Right Palm Detector file : " + filename);
|
||||
if (palmDetector ==null) {
|
||||
try{
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Detectors {
|
||||
private static void LoadFrontalFaceDetector(){
|
||||
String filename = SomeCodes.ExtractResource("/haarcascade_frontalface_default.xml");
|
||||
if (filename!=null) {
|
||||
System.out.println("Face Detector file : " + filename);
|
||||
Logger.info("Face Detector file : " + filename);
|
||||
if (frontalfaceDetector==null) {
|
||||
try{
|
||||
frontalfaceDetector = new CascadeClassifier(filename);
|
||||
@@ -97,7 +97,7 @@ public class Detectors {
|
||||
private static void LoadProfileFaceDetector(){
|
||||
String filename = SomeCodes.ExtractResource("/haarcascade_profileface.xml");
|
||||
if (filename!=null) {
|
||||
System.out.println("Profile Face Detector file : " + filename);
|
||||
Logger.info("Profile Face Detector file : " + filename);
|
||||
if (profilefaceDetector==null) {
|
||||
try{
|
||||
profilefaceDetector = new CascadeClassifier(filename);
|
||||
@@ -113,7 +113,7 @@ public class Detectors {
|
||||
private static void LoadEyeDetector(){
|
||||
String filename = SomeCodes.ExtractResource("/haarcascade_eye.xml");
|
||||
if (filename!=null) {
|
||||
System.out.println("Eye Detector file : " + filename);
|
||||
Logger.info("Eye Detector file : " + filename);
|
||||
if (eyeDetector==null) {
|
||||
try{
|
||||
|
||||
@@ -200,14 +200,14 @@ public class Detectors {
|
||||
if (FaceminSize.width()!=value || FaceminSize.height()!=value) {
|
||||
FaceminSize = new Size(value, value);
|
||||
EyeminSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
||||
System.out.println("FaceMinSize changed to : " + FaceminSize.width());
|
||||
System.out.println("EyeMinSize changed to : " + EyeminSize.width());
|
||||
Logger.info("FaceMinSize changed to : " + FaceminSize.width());
|
||||
Logger.info("EyeMinSize changed to : " + EyeminSize.width());
|
||||
}
|
||||
} else {
|
||||
FaceminSize = new Size(value, value);
|
||||
EyeminSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
||||
System.out.println("FaceMinSize created with value : " + FaceminSize.width());
|
||||
System.out.println("EyeMinSize created with value : " + EyeminSize.width());
|
||||
Logger.info("FaceMinSize created with value : " + FaceminSize.width());
|
||||
Logger.info("EyeMinSize created with value : " + EyeminSize.width());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -217,14 +217,14 @@ public class Detectors {
|
||||
if (FacemaxSize.width()!=value || FacemaxSize.height()!=value) {
|
||||
FacemaxSize = new Size(value, value);
|
||||
EyemaxSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
||||
System.out.println("FaceMaxSize changed to : " + FacemaxSize.width());
|
||||
System.out.println("EyeMaxSize changed to : " + EyemaxSize.width());
|
||||
Logger.info("FaceMaxSize changed to : " + FacemaxSize.width());
|
||||
Logger.info("EyeMaxSize changed to : " + EyemaxSize.width());
|
||||
}
|
||||
} else {
|
||||
FacemaxSize = new Size(value, value);
|
||||
EyemaxSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
||||
System.out.println("FaceMaxSize created with value : " + FacemaxSize.width());
|
||||
System.out.println("EyeMaxSize created with value : " + EyemaxSize.width());
|
||||
Logger.info("FaceMaxSize created with value : " + FacemaxSize.width());
|
||||
Logger.info("EyeMaxSize created with value : " + EyemaxSize.width());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,42 +1,90 @@
|
||||
package id.co.gtc.erhacam;
|
||||
|
||||
import Config.SomeCodes;
|
||||
import SecureDongle.SecureDongle;
|
||||
import SecureDongle.SecureDongleEvent;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Stage;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static Config.SomeCodes.ShowAlert;
|
||||
import static Config.SomeCodes.config;
|
||||
|
||||
|
||||
public class MainApplication extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("main-view.fxml"));
|
||||
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 03022025-070");
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(true);
|
||||
stage.setMaximized(true);
|
||||
stage.setOnCloseRequest(e->{
|
||||
config.Save();
|
||||
MainView mainView = fxmlLoader.getController();
|
||||
mainView.Unload();
|
||||
Logger.info("Application closed");
|
||||
});
|
||||
SomeCodes.LoadQRReader();
|
||||
Detectors.LoadAllDetectors();
|
||||
SecureDongle sd = new SecureDongle((short)0x4B30, (short)0xA66C, (short)0x3109, (short)0x37B1);
|
||||
if (sd.Find()){
|
||||
if (sd.Open()){
|
||||
String UserID = Integer.toHexString(sd.ReadUserID()) ;
|
||||
sd.Close();
|
||||
|
||||
stage.show();
|
||||
if (UserID.equals("14022025")){
|
||||
Logger.info("Secure Dongle UserID valid");
|
||||
|
||||
Logger.info("Application started");
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("main-view.fxml"));
|
||||
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 17022025-103");
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(true);
|
||||
stage.setMaximized(true);
|
||||
stage.setOnCloseRequest(e->{
|
||||
sd.StopMonitor();
|
||||
config.Save();
|
||||
MainView mainView = fxmlLoader.getController();
|
||||
mainView.Unload();
|
||||
Logger.info("Application closed");
|
||||
});
|
||||
SomeCodes.LoadQRReader();
|
||||
Detectors.LoadAllDetectors();
|
||||
|
||||
stage.show();
|
||||
|
||||
Logger.info("Application started");
|
||||
sd.setEvent(new SecureDongleEvent() {
|
||||
@Override
|
||||
public void onDongleMissing() {
|
||||
Logger.error("Secure Dongle Missing");
|
||||
Platform.runLater(()->{
|
||||
ShowAlert(Alert.AlertType.ERROR, "Secure Dongle Missing", "Secure Dongle Missing", "Secure Dongle Missing");
|
||||
Platform.exit();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDongleError(String function, int errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
sd.StartMonitor();
|
||||
|
||||
} else {
|
||||
ShowAlert(Alert.AlertType.ERROR, "Secure Dongle UserID not valid", "Secure Dongle UserID not valid", "Secure Dongle UserID not valid");
|
||||
Logger.error("Secure Dongle UserID not valid");
|
||||
Platform.exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
ShowAlert(Alert.AlertType.ERROR, "Secure Dongle cannot be opened", "Secure Dongle cannot be opened", "Secure Dongle cannot be opened");
|
||||
Logger.error("Secure Dongle cannot be opened");
|
||||
Platform.exit();
|
||||
}
|
||||
} else {
|
||||
ShowAlert(Alert.AlertType.ERROR, "Secure Dongle not found", "Secure Dongle not found", "Secure Dongle not found");
|
||||
Logger.error("Secure Dongle not found");
|
||||
Platform.exit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -45,5 +93,6 @@ public class MainApplication extends Application {
|
||||
SomeCodes.ExtractResource("/tinylog.properties");
|
||||
launch();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -92,8 +92,8 @@ public class MainView {
|
||||
currentcontroller = loader.getController();
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("Unable to load " + fxmlfile + ", exception : " + e.getMessage());
|
||||
Logger.error("Unable to load " ,fxmlfile, ", exception : ", e.getMessage());
|
||||
}
|
||||
} else Logger.info("Not loading empty fxml file");
|
||||
} else Logger.error("loadContent Not loading empty fxml file");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user