Merge branch 'master' of https://gitea.rdkartono.my.id/rdkartono/ErhaCam
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#Thu Mar 27 11:07:02 ICT 2025
|
#Thu Apr 10 16:17:13 ICT 2025
|
||||||
AudioPhase1=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase1.mp3
|
AudioPhase1=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase1.mp3
|
||||||
AudioPhase2=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase2.mp3
|
AudioPhase2=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase2.mp3
|
||||||
AudioPhase3=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase3.mp3
|
AudioPhase3=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase3.mp3
|
||||||
|
|||||||
BIN
database.db
BIN
database.db
Binary file not shown.
12213
haarcascade_eye.xml
12213
haarcascade_eye.xml
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -3,6 +3,8 @@ package BASS;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.tinylog.Logger;
|
import org.tinylog.Logger;
|
||||||
|
|
||||||
|
import static Config.SomeCodes.Wait;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class AudioPlayer {
|
public class AudioPlayer {
|
||||||
@@ -13,10 +15,7 @@ public class AudioPlayer {
|
|||||||
|
|
||||||
public void WaitUntilFinished(){
|
public void WaitUntilFinished(){
|
||||||
while(currentFileHandle!=0){
|
while(currentFileHandle!=0){
|
||||||
try {
|
Wait(10);
|
||||||
Thread.sleep(10);
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@ public class AudioPlayer {
|
|||||||
if (bass.BASS_ChannelStart(filehandle)){
|
if (bass.BASS_ChannelStart(filehandle)){
|
||||||
currentFile = filename;
|
currentFile = filename;
|
||||||
currentFileHandle = filehandle;
|
currentFileHandle = filehandle;
|
||||||
new Thread(()->{
|
Thread pl = new Thread(() -> {
|
||||||
if (playbackstatus!=null) playbackstatus.onPlaybackStarted(filename);
|
if (playbackstatus!=null) playbackstatus.onPlaybackStarted(filename);
|
||||||
boolean iscontinue = true;
|
boolean iscontinue = true;
|
||||||
while(iscontinue){
|
while(iscontinue){
|
||||||
@@ -122,18 +121,17 @@ public class AudioPlayer {
|
|||||||
iscontinue = false;
|
iscontinue = false;
|
||||||
break;
|
break;
|
||||||
default : {
|
default : {
|
||||||
try {
|
Wait(100);
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
iscontinue = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (playbackstatus!=null) playbackstatus.onPlaybackFinished(filename);
|
if (playbackstatus!=null) playbackstatus.onPlaybackFinished(filename);
|
||||||
currentFile = "";
|
currentFile = "";
|
||||||
currentFileHandle = 0;
|
currentFileHandle = 0;
|
||||||
}).start();
|
});
|
||||||
|
pl.setDaemon(true);
|
||||||
|
pl.start();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Logger.error("AudioPlayer PlayFile failed, BASS_ChannelStart failed, error code: "+bass.BASS_ErrorGetCode());
|
Logger.error("AudioPlayer PlayFile failed, BASS_ChannelStart failed, error code: "+bass.BASS_ErrorGetCode());
|
||||||
if (playbackstatus!=null) playbackstatus.onPlaybackFailure(filename);
|
if (playbackstatus!=null) playbackstatus.onPlaybackFailure(filename);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import javafx.application.Platform;
|
|||||||
import javafx.embed.swing.SwingFXUtils;
|
import javafx.embed.swing.SwingFXUtils;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextArea;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import org.bytedeco.javacv.Java2DFrameConverter;
|
import org.bytedeco.javacv.Java2DFrameConverter;
|
||||||
import org.bytedeco.javacv.OpenCVFrameConverter;
|
import org.bytedeco.javacv.OpenCVFrameConverter;
|
||||||
@@ -19,7 +21,6 @@ import org.bytedeco.opencv.opencv_core.Size;
|
|||||||
import org.bytedeco.opencv.opencv_core.UMat;
|
import org.bytedeco.opencv.opencv_core.UMat;
|
||||||
import org.tinylog.Logger;
|
import org.tinylog.Logger;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -512,9 +513,7 @@ public class SomeCodes {
|
|||||||
if (ROI.x()>=0){
|
if (ROI.x()>=0){
|
||||||
if (ROI.y()>=0){
|
if (ROI.y()>=0){
|
||||||
if (ROI.width()>0){
|
if (ROI.width()>0){
|
||||||
if (ROI.height()>0){
|
return ROI.height() > 0;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,7 +522,7 @@ public class SomeCodes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void Print(String... x){
|
public static void Print(String... x){
|
||||||
if (x!=null && x.length>0){
|
if (x != null){
|
||||||
for(String xx : x){
|
for(String xx : x){
|
||||||
System.out.println(xx);
|
System.out.println(xx);
|
||||||
}
|
}
|
||||||
@@ -604,53 +603,72 @@ public class SomeCodes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetText(Object obj, String text){
|
public static void LabelSetText(Label lbl, String text, String style){
|
||||||
if (obj!=null && ValidString(text)){
|
if (lbl!=null){
|
||||||
if (Platform.isFxApplicationThread()){
|
if (text!=null){
|
||||||
if (obj instanceof Label lbl){
|
if (text.equals(lbl.getText())) return;
|
||||||
if (text.equals(lbl.getText())) return;
|
if (Platform.isFxApplicationThread()){
|
||||||
lbl.setText(text);
|
lbl.setText(text);
|
||||||
} else if (obj instanceof TextArea ta){
|
if (style!=null && !style.isBlank()){
|
||||||
if (text.equals(ta.getText())) return;
|
lbl.setStyle(style);
|
||||||
ta.setText(text);
|
|
||||||
} else if (obj instanceof TextField tf){
|
|
||||||
if (text.equals(tf.getText())) return;
|
|
||||||
tf.setText(text);
|
|
||||||
}
|
|
||||||
} else{
|
|
||||||
Platform.runLater(()->{
|
|
||||||
if (obj instanceof Label lbl){
|
|
||||||
if (text.equals(lbl.getText())) return;
|
|
||||||
lbl.setText(text);
|
|
||||||
} else if (obj instanceof TextArea ta){
|
|
||||||
if (text.equals(ta.getText())) return;
|
|
||||||
ta.setText(text);
|
|
||||||
} else if (obj instanceof TextField tf){
|
|
||||||
if (text.equals(tf.getText())) return;
|
|
||||||
tf.setText(text);
|
|
||||||
}
|
}
|
||||||
});
|
} else{
|
||||||
|
Platform.runLater(()-> {
|
||||||
|
lbl.setText(text);
|
||||||
|
if (style!=null && !style.isBlank()){
|
||||||
|
lbl.setStyle(style);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void TextAreaSetText(TextArea ta, String text){
|
||||||
|
if (ta!=null){
|
||||||
|
if (text!=null){
|
||||||
|
if (text.equals(ta.getText())) return;
|
||||||
|
if (Platform.isFxApplicationThread()){
|
||||||
|
ta.setText(text);
|
||||||
|
} else{
|
||||||
|
Platform.runLater(()-> ta.setText(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TextFieldSetText(TextField tf, String text){
|
||||||
|
if (tf!=null){
|
||||||
|
if (text!=null){
|
||||||
|
if (text.equals(tf.getText())) return;
|
||||||
|
if (Platform.isFxApplicationThread()){
|
||||||
|
tf.setText(text);
|
||||||
|
} else{
|
||||||
|
Platform.runLater(()-> tf.setText(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void LabelVisible(Label label, boolean visible){
|
public static void LabelVisible(Label label, boolean visible){
|
||||||
if (label!=null){
|
if (label!=null){
|
||||||
if (visible){
|
if (visible){
|
||||||
if (Platform.isFxApplicationThread()){
|
if (Platform.isFxApplicationThread()){
|
||||||
label.setVisible(true);
|
label.setVisible(true);
|
||||||
} else{
|
} else{
|
||||||
Platform.runLater(()->{
|
Platform.runLater(()-> label.setVisible(true));
|
||||||
label.setVisible(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Platform.isFxApplicationThread()){
|
if (Platform.isFxApplicationThread()){
|
||||||
label.setVisible(false);
|
label.setVisible(false);
|
||||||
} else{
|
} else{
|
||||||
Platform.runLater(()->{
|
Platform.runLater(()-> label.setVisible(false));
|
||||||
label.setVisible(false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package SecureDongle;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.tinylog.Logger;
|
import org.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import static Config.SomeCodes.ToShort;
|
import static Config.SomeCodes.ToShort;
|
||||||
|
import static Config.SomeCodes.Wait;
|
||||||
|
|
||||||
public class SecureDongle {
|
public class SecureDongle {
|
||||||
|
|
||||||
@@ -108,6 +106,7 @@ public class SecureDongle {
|
|||||||
* Close SecureDongle
|
* Close SecureDongle
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public boolean Close(){
|
public boolean Close(){
|
||||||
handle[0] = Handle;
|
handle[0] = Handle;
|
||||||
short result = SD.SecureDongle(LibSecureDongle.SD_CLOSE, handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
short result = SD.SecureDongle(LibSecureDongle.SD_CLOSE, handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
@@ -118,12 +117,40 @@ public class SecureDongle {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write to User Data Zone (UDZ)
|
||||||
|
* @param StartAddress start address of UDZ, zero based
|
||||||
|
* @param length length of data to write, max 1000 bytes
|
||||||
|
* @param data data to write
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public boolean Write(short StartAddress, short length, byte[] data){
|
||||||
|
if (Opened){
|
||||||
|
handle[0] = Handle;
|
||||||
|
p1[0] = StartAddress>=0 ? StartAddress : 0;
|
||||||
|
if (length<1) length=1;
|
||||||
|
if (length>1000) length=1000;
|
||||||
|
p2[0] = length;
|
||||||
|
System.arraycopy(data, 0, buffer, 0, length);
|
||||||
|
short result = SD.SecureDongle(LibSecureDongle.SD_WRITE, handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
if (result== LibSecureDongle.ERR_SUCCESS){
|
||||||
|
//System.out.println("SecureDongle HardwareID="+HardwareID+" write success ");
|
||||||
|
return true;
|
||||||
|
} else if (event!=null) event.onDongleError("Write", result);
|
||||||
|
} //else System.out.println("SecureDongle not opened");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read from User Data Zone (UDZ)
|
* Read from User Data Zone (UDZ)
|
||||||
* @param StartAddress Start Address, zero based
|
* @param StartAddress Start Address, zero based
|
||||||
* @param Length Length of data to read, max 1000 bytes
|
* @param Length Length of data to read, max 1000 bytes
|
||||||
* @return byte array of data, length=0 if failed
|
* @return byte array of data, length=0 if failed
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public byte[] Read(short StartAddress, short Length){
|
public byte[] Read(short StartAddress, short Length){
|
||||||
if (Opened){
|
if (Opened){
|
||||||
handle[0] = Handle;
|
handle[0] = Handle;
|
||||||
@@ -143,35 +170,11 @@ public class SecureDongle {
|
|||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write to User Data Zone (UDZ)
|
|
||||||
* @param StartAddress start address of UDZ, zero based
|
|
||||||
* @param length length of data to write, max 1000 bytes
|
|
||||||
* @param data data to write
|
|
||||||
* @return true if success
|
|
||||||
*/
|
|
||||||
public boolean Write(short StartAddress, short length, byte[] data){
|
|
||||||
if (Opened){
|
|
||||||
handle[0] = Handle;
|
|
||||||
p1[0] = StartAddress>=0 ? StartAddress : 0;
|
|
||||||
if (length<1) length=1;
|
|
||||||
if (length>1000) length=1000;
|
|
||||||
p2[0] = length;
|
|
||||||
System.arraycopy(data, 0, buffer, 0, length);
|
|
||||||
short result = SD.SecureDongle(LibSecureDongle.SD_WRITE, handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
|
||||||
if (result== LibSecureDongle.ERR_SUCCESS){
|
|
||||||
//System.out.println("SecureDongle HardwareID="+HardwareID+" write success ");
|
|
||||||
return true;
|
|
||||||
} else if (event!=null) event.onDongleError("Write", result);
|
|
||||||
} //else System.out.println("SecureDongle not opened");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate Random Number
|
* Generate Random Number
|
||||||
* @return short array of random number
|
* @return short array of random number
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public short[] GenerateRandomNumber(){
|
public short[] GenerateRandomNumber(){
|
||||||
short[] random = new short[4];
|
short[] random = new short[4];
|
||||||
if (Opened){
|
if (Opened){
|
||||||
@@ -195,6 +198,7 @@ public class SecureDongle {
|
|||||||
* @param UserID UserID to write
|
* @param UserID UserID to write
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public boolean WriteUserID(int UserID){
|
public boolean WriteUserID(int UserID){
|
||||||
if (Opened){
|
if (Opened){
|
||||||
handle[0] = Handle;
|
handle[0] = Handle;
|
||||||
@@ -242,7 +246,7 @@ public class SecureDongle {
|
|||||||
* if dongle missing, will raise event onDongleMissing
|
* if dongle missing, will raise event onDongleMissing
|
||||||
*/
|
*/
|
||||||
public void StartMonitor(){
|
public void StartMonitor(){
|
||||||
new Thread(()->{
|
Thread tx = new Thread(()->{
|
||||||
if (HardwareID==0) Find();
|
if (HardwareID==0) Find();
|
||||||
Open();
|
Open();
|
||||||
int firstUserID = ReadUserID();
|
int firstUserID = ReadUserID();
|
||||||
@@ -251,11 +255,7 @@ public class SecureDongle {
|
|||||||
ismonitoring = true;
|
ismonitoring = true;
|
||||||
Logger.info("Start Monitoring UserID="+Integer.toHexString(firstUserID));
|
Logger.info("Start Monitoring UserID="+Integer.toHexString(firstUserID));
|
||||||
while (ismonitoring){
|
while (ismonitoring){
|
||||||
try {
|
Wait(5000);
|
||||||
Thread.sleep(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Open();
|
Open();
|
||||||
int newUserID = ReadUserID();
|
int newUserID = ReadUserID();
|
||||||
Close();
|
Close();
|
||||||
@@ -267,7 +267,9 @@ public class SecureDongle {
|
|||||||
System.out.println("Stop Monitoring");
|
System.out.println("Stop Monitoring");
|
||||||
} else System.out.println("Canceled Monitoring, UserID not found");
|
} else System.out.println("Canceled Monitoring, UserID not found");
|
||||||
|
|
||||||
}).start();
|
});
|
||||||
|
tx.setDaemon(true);
|
||||||
|
tx.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
package id.co.gtc.erhacam;
|
package id.co.gtc.erhacam;
|
||||||
|
|
||||||
|
import javafx.animation.KeyFrame;
|
||||||
import javafx.animation.PauseTransition;
|
import javafx.animation.PauseTransition;
|
||||||
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.InvalidationListener;
|
||||||
|
import javafx.beans.Observable;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
@@ -14,10 +21,7 @@ import javafx.scene.layout.StackPane;
|
|||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Circle;
|
import javafx.scene.shape.Circle;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.*;
|
||||||
import javafx.stage.Screen;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import javafx.stage.StageStyle;
|
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -87,27 +91,8 @@ public class AutoCloseAlert {
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show an alert with a title, content, and automatically close after a few seconds
|
|
||||||
* @param title the title 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 onClose What to do after auto close
|
|
||||||
*/
|
|
||||||
public static void show(String title, String content, int seconds, Consumer<String> onClose){
|
|
||||||
if (Platform.isFxApplicationThread()){
|
|
||||||
Stage alertStage = _showtext(title, "", content);
|
|
||||||
closeAlertStage(seconds, onClose, alertStage);
|
|
||||||
} else {
|
|
||||||
Platform.runLater(()->{
|
|
||||||
Stage alertStage = _showtext(title, "", content);
|
|
||||||
closeAlertStage(seconds, onClose, alertStage);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,6 +135,79 @@ public class AutoCloseAlert {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void showpictures(String[] pictures, int seconds, Consumer<String> onClose){
|
||||||
|
List<Image> images = new ArrayList<>();
|
||||||
|
|
||||||
|
if (pictures != null){
|
||||||
|
for(String pp : pictures){
|
||||||
|
Image ii = LoadImage(pp);
|
||||||
|
if (ii!=null) images.add(ii);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!images.isEmpty()){
|
||||||
|
Image[] source = images.toArray(new Image[0]);
|
||||||
|
if (Platform.isFxApplicationThread()){
|
||||||
|
_showpictures(source, seconds, onClose);
|
||||||
|
} else {
|
||||||
|
Platform.runLater(()-> _showpictures(source,seconds, onClose));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void _showpictures(Image[] pictures, int seconds, Consumer<String> onClose){
|
||||||
|
close();
|
||||||
|
|
||||||
|
Stage alertStage = new Stage();
|
||||||
|
alertStage.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
alertStage.initStyle(StageStyle.UTILITY);
|
||||||
|
alertStage.setAlwaysOnTop(true);
|
||||||
|
alertStage.setResizable(false);
|
||||||
|
int width = (int) Screen.getPrimary().getBounds().getWidth();
|
||||||
|
int height = (int) Screen.getPrimary().getBounds().getHeight();
|
||||||
|
|
||||||
|
ImageView imageView = new ImageView();
|
||||||
|
imageView.setPreserveRatio(true);
|
||||||
|
imageView.setFitWidth(width);
|
||||||
|
imageView.setFitHeight(height);
|
||||||
|
|
||||||
|
BorderPane borderPane = new BorderPane();
|
||||||
|
borderPane.setCenter(imageView);
|
||||||
|
|
||||||
|
alertStage.setScene(new Scene(borderPane, width, height));
|
||||||
|
alertStage.centerOnScreen();
|
||||||
|
|
||||||
|
Timeline timeline = new Timeline();
|
||||||
|
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(0), event -> {
|
||||||
|
alertStage.show();
|
||||||
|
}));
|
||||||
|
|
||||||
|
for(int xx = 0; xx < pictures.length; xx++){
|
||||||
|
final int index = xx;
|
||||||
|
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(seconds*(index+1)), event -> {
|
||||||
|
imageView.setImage(pictures[index]);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(seconds* (pictures.length+1)), event -> {
|
||||||
|
alertStage.close();
|
||||||
|
if (currentAlertStage == alertStage) {
|
||||||
|
currentAlertStage = null;
|
||||||
|
}
|
||||||
|
if (onClose!=null) onClose.accept(shownTitle);
|
||||||
|
clear();
|
||||||
|
}));
|
||||||
|
timeline.play();
|
||||||
|
|
||||||
|
currentAlertStage = alertStage;
|
||||||
|
shownTitle = "";
|
||||||
|
shownContent = "";
|
||||||
|
shownHeader = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static Stage _showbanner(Image image){
|
private static Stage _showbanner(Image image){
|
||||||
close();
|
close();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
|
|||||||
import com.google.zxing.common.HybridBinarizer;
|
import com.google.zxing.common.HybridBinarizer;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
|
||||||
import javafx.concurrent.Task;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Slider;
|
import javafx.scene.control.Slider;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
@@ -25,6 +24,7 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import org.bytedeco.javacv.Frame;
|
import org.bytedeco.javacv.Frame;
|
||||||
|
import org.bytedeco.javacv.FrameGrabber;
|
||||||
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
||||||
import org.bytedeco.opencv.global.opencv_core;
|
import org.bytedeco.opencv.global.opencv_core;
|
||||||
import org.bytedeco.opencv.global.opencv_imgcodecs;
|
import org.bytedeco.opencv.global.opencv_imgcodecs;
|
||||||
@@ -42,13 +42,15 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import static Config.SomeCodes.*;
|
import static Config.SomeCodes.*;
|
||||||
import static id.co.gtc.erhacam.Detectors.*;
|
import static id.co.gtc.erhacam.Detectors.*;
|
||||||
import static org.bytedeco.opencv.global.opencv_core.CV_8UC3;
|
import static org.bytedeco.opencv.global.opencv_core.CV_8UC3;
|
||||||
import static org.bytedeco.opencv.global.opencv_core.mean;
|
|
||||||
import static org.bytedeco.opencv.global.opencv_imgproc.*;
|
import static org.bytedeco.opencv.global.opencv_imgproc.*;
|
||||||
|
|
||||||
@SuppressWarnings({"unused"})
|
@SuppressWarnings({"unused"})
|
||||||
@@ -65,17 +67,14 @@ public class Cameradetail {
|
|||||||
|
|
||||||
}
|
}
|
||||||
private final AtomicBoolean Capturing = new AtomicBoolean(false);
|
private final AtomicBoolean Capturing = new AtomicBoolean(false);
|
||||||
private final AtomicBoolean TakingPhoto = new AtomicBoolean(false);
|
private CountDownLatch TakingPhoto = null;
|
||||||
private final AtomicBoolean IsGrabbingLiveView = new AtomicBoolean(false);
|
private final Semaphore IsGrabbingLiveView = new Semaphore(0);
|
||||||
private OpenCVFrameGrabber mGrabber = null;
|
private OpenCVFrameGrabber mGrabber = null;
|
||||||
private LiveCamEvent event = null;
|
private LiveCamEvent event = null;
|
||||||
private @Getter @Setter CameraConfigEnum cameraConfigEnum = CameraConfigEnum.CameraConfigCenter;
|
private @Getter @Setter CameraConfigEnum cameraConfigEnum = CameraConfigEnum.CameraConfigCenter;
|
||||||
private @Getter int LiveFPS = 0;
|
private @Getter int LiveFPS = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get detected QR text from Live View
|
|
||||||
*/
|
|
||||||
private @Getter String qrtext = null;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label cameratitle;
|
private Label cameratitle;
|
||||||
@@ -145,12 +144,27 @@ public class Cameradetail {
|
|||||||
int[] paramjpeg = {opencv_imgcodecs.IMWRITE_JPEG_QUALITY, 100};
|
int[] paramjpeg = {opencv_imgcodecs.IMWRITE_JPEG_QUALITY, 100};
|
||||||
int[] parampng = {opencv_imgcodecs.IMWRITE_PNG_COMPRESSION, 0};
|
int[] parampng = {opencv_imgcodecs.IMWRITE_PNG_COMPRESSION, 0};
|
||||||
|
|
||||||
|
private boolean use_qr = false;
|
||||||
|
private boolean use_face = false;
|
||||||
|
|
||||||
|
|
||||||
private void setSliderValue(Slider sld, CameraProperty prop, double value){
|
private void setSliderValue(Slider sld, CameraProperty prop, double value){
|
||||||
|
|
||||||
if (sld!=null){
|
if (sld!=null){
|
||||||
sld.setMin(prop.Min);
|
if (prop!=null){
|
||||||
sld.setMax(prop.Max);
|
if (Platform.isFxApplicationThread()){
|
||||||
sld.setValue(value);
|
sld.setMin(prop.Min);
|
||||||
|
sld.setMax(prop.Max);
|
||||||
|
sld.setValue(value);
|
||||||
|
} else {
|
||||||
|
Platform.runLater(()->{
|
||||||
|
sld.setMin(prop.Min);
|
||||||
|
sld.setMax(prop.Max);
|
||||||
|
sld.setValue(value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,33 +256,15 @@ public class Cameradetail {
|
|||||||
public void setCameraTitle(String title){
|
public void setCameraTitle(String title){
|
||||||
|
|
||||||
if (ValidString(title)){
|
if (ValidString(title)){
|
||||||
if (cameratitle!=null){
|
LabelSetText(cameratitle, title,null);
|
||||||
cameratitle.setText(title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSharpness_indicator(double value){
|
public void setSharpness_indicator(double value){
|
||||||
if (value >= config.getSharpnessThreshold()){
|
if (value >= config.getSharpnessThreshold()){
|
||||||
if (Platform.isFxApplicationThread()){
|
LabelSetText(sharpness_indicator, "OK","-fx-text-fill: green; -fx-border-color: black");
|
||||||
sharpness_indicator.setText("OK");
|
|
||||||
sharpness_indicator.setStyle("-fx-text-fill: green; -fx-border-color: black");
|
|
||||||
} else {
|
|
||||||
Platform.runLater(()->{
|
|
||||||
sharpness_indicator.setText("OK");
|
|
||||||
sharpness_indicator.setStyle("-fx-text-fill: green; -fx-border-color: black");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (Platform.isFxApplicationThread()) {
|
LabelSetText(sharpness_indicator,"BAD","-fx-text-fill: red; -fx-border-color: black");
|
||||||
sharpness_indicator.setText("BAD");
|
|
||||||
sharpness_indicator.setStyle("-fx-text-fill: red; -fx-border-color: black");
|
|
||||||
} else {
|
|
||||||
Platform.runLater(()->{
|
|
||||||
sharpness_indicator.setText("BAD");
|
|
||||||
sharpness_indicator.setStyle("-fx-text-fill: red; -fx-border-color: black");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,11 +323,7 @@ public class Cameradetail {
|
|||||||
* @param status Status of the Camera
|
* @param status Status of the Camera
|
||||||
*/
|
*/
|
||||||
public void setCameraStatus(String status){
|
public void setCameraStatus(String status){
|
||||||
if (ValidString(status)){
|
LabelSetText(camerastatus, status,null);
|
||||||
if (camerastatus!=null){
|
|
||||||
camerastatus.setText(status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,7 +344,11 @@ public class Cameradetail {
|
|||||||
public void setCameraStream(Image image){
|
public void setCameraStream(Image image){
|
||||||
if (image!=null){
|
if (image!=null){
|
||||||
if (camerastream!=null){
|
if (camerastream!=null){
|
||||||
camerastream.setImage(image);
|
if (Platform.isFxApplicationThread()){
|
||||||
|
camerastream.setImage(image);
|
||||||
|
} else {
|
||||||
|
Platform.runLater(()->camerastream.setImage(image));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -677,47 +673,54 @@ public class Cameradetail {
|
|||||||
* @param prefix filename prefix
|
* @param prefix filename prefix
|
||||||
* @return filename path of the saved photo, or null if failed
|
* @return filename path of the saved photo, or null if failed
|
||||||
*/
|
*/
|
||||||
public PhotoResult TakePhoto(String directory, String prefix) throws InterruptedException {
|
public PhotoResult TakePhoto(String directory, String prefix) {
|
||||||
PhotoResult result = new PhotoResult(cameratitle.getText());
|
PhotoResult result = new PhotoResult(cameratitle.getText());
|
||||||
if (!ValidDirectory(directory)) directory = currentDirectory;
|
if (!ValidDirectory(directory)) directory = currentDirectory;
|
||||||
|
|
||||||
if (mGrabber!=null){
|
if (mGrabber!=null){
|
||||||
while(IsGrabbingLiveView.get()){
|
try{
|
||||||
Thread.sleep(10);
|
// wait if the camera is still capturing
|
||||||
|
IsGrabbingLiveView.acquire();
|
||||||
|
TakingPhoto = new CountDownLatch(1);
|
||||||
|
|
||||||
|
|
||||||
|
if (!BestMat.empty()){
|
||||||
|
|
||||||
|
// save BestMat at quality 9 PNG
|
||||||
|
String filename = GetFullQualityPhotoPath(directory, prefix);
|
||||||
|
|
||||||
|
if (opencv_imgcodecs.imwrite(filename, BestMat, parampng)){
|
||||||
|
result.setFullres(filename);
|
||||||
|
} else System.out.println("TakePhoto failed, Unable to Save FullQUality Photo for camera "+cameratitle.getText());
|
||||||
|
|
||||||
|
String xx = CropBestMat(directory, prefix, BestMatROI);
|
||||||
|
if (ValidFile(xx)) {
|
||||||
|
result.setFullcrop(xx);
|
||||||
|
result.setBestROI(new Rect(BestMatROI.x(), BestMatROI.y(), BestMatROI.width(), BestMatROI.height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// save ReducedMat at 100% JPEG
|
||||||
|
String reducedfilename = GetReducedPhotoPath(directory, prefix);
|
||||||
|
opencv_imgproc.resize(BestMat, ReducedMat, ReducedSize);
|
||||||
|
if (!opencv_imgcodecs.imwrite(reducedfilename, ReducedMat, paramjpeg)){
|
||||||
|
System.out.println("TakePhoto failed, Unable to Save Reduced Photo for camera "+cameratitle.getText());
|
||||||
|
} else result.setCompressedfile(reducedfilename);
|
||||||
|
|
||||||
|
String xy = CropReducedMat(directory, prefix, ReducedMatROI);
|
||||||
|
if (ValidFile(xy)){
|
||||||
|
result.setCompressedcrop(xy);
|
||||||
|
result.setReducedROI(new Rect(ReducedMatROI.x(), ReducedMatROI.y(), ReducedMatROI.width(), ReducedMatROI.height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else raise_log("TakePhoto failed, Live View is Empty");
|
||||||
|
} catch (InterruptedException e){
|
||||||
|
System.out.println("TakePhoto IsGrabbingLiveView interrupted");
|
||||||
}
|
}
|
||||||
TakingPhoto.set(true);
|
|
||||||
if (!BestMat.empty()){
|
|
||||||
|
|
||||||
// save BestMat at quality 9 PNG
|
TakingPhoto.countDown();
|
||||||
String filename = GetFullQualityPhotoPath(directory, prefix);
|
|
||||||
|
|
||||||
if (opencv_imgcodecs.imwrite(filename, BestMat, parampng)){
|
|
||||||
result.setFullres(filename);
|
|
||||||
} else System.out.println("TakePhoto failed, Unable to Save FullQUality Photo for camera "+cameratitle.getText());
|
|
||||||
|
|
||||||
String xx = CropBestMat(directory, prefix, BestMatROI);
|
|
||||||
if (ValidFile(xx)) {
|
|
||||||
result.setFullcrop(xx);
|
|
||||||
result.setBestROI(new Rect(BestMatROI.x(), BestMatROI.y(), BestMatROI.width(), BestMatROI.height()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// save ReducedMat at 100% JPEG
|
|
||||||
String reducedfilename = GetReducedPhotoPath(directory, prefix);
|
|
||||||
opencv_imgproc.resize(BestMat, ReducedMat, ReducedSize);
|
|
||||||
if (!opencv_imgcodecs.imwrite(reducedfilename, ReducedMat, paramjpeg)){
|
|
||||||
System.out.println("TakePhoto failed, Unable to Save Reduced Photo for camera "+cameratitle.getText());
|
|
||||||
} else result.setCompressedfile(reducedfilename);
|
|
||||||
|
|
||||||
String xy = CropReducedMat(directory, prefix, ReducedMatROI);
|
|
||||||
if (ValidFile(xy)){
|
|
||||||
result.setCompressedcrop(xy);
|
|
||||||
result.setReducedROI(new Rect(ReducedMatROI.x(), ReducedMatROI.y(), ReducedMatROI.width(), ReducedMatROI.height()));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else raise_log("TakePhoto failed, Live View is Empty");
|
|
||||||
} else raise_log("TakePhoto failed, Grabber is null");
|
} else raise_log("TakePhoto failed, Grabber is null");
|
||||||
TakingPhoto.set(false);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,17 +787,320 @@ public class Cameradetail {
|
|||||||
try{
|
try{
|
||||||
mGrabber.close();
|
mGrabber.close();
|
||||||
System.out.println("Camera "+cameratitle.getText()+" stopped");
|
System.out.println("Camera "+cameratitle.getText()+" stopped");
|
||||||
Platform.runLater(()->setCameraStatus("Camera Stopped"));
|
setCameraStatus("Camera Stopped");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
raise_log("StopLiveView failed, Unable to Stop Camera, Error: " + e.getMessage());
|
raise_log("StopLiveView failed, Unable to Stop Camera, Error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TakingPhoto.set(false);
|
TakingPhoto = null;
|
||||||
IsGrabbingLiveView.set(false);
|
IsGrabbingLiveView.drainPermits();
|
||||||
|
|
||||||
|
// stop FPS calculation
|
||||||
|
timer.cancel();
|
||||||
|
// stop camera capture thread
|
||||||
|
cam_capture.interrupt();
|
||||||
|
// stop qr detection thread
|
||||||
|
qr_detect.interrupt();
|
||||||
|
// stop face detection thread
|
||||||
|
face_detect.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean StartLiveView(LiveCamEvent event, String cameratitle, final boolean use_qr , final boolean use_face) {
|
Timer timer = new java.util.Timer();
|
||||||
|
// FPS Calculator
|
||||||
|
AtomicInteger fps = new AtomicInteger(0);
|
||||||
|
|
||||||
|
// use for locking
|
||||||
|
final Object lockObject = new Object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// QR Detection Thread
|
||||||
|
Semaphore qr_semaphore = new Semaphore(0);
|
||||||
|
Thread qr_detect = new Thread(()->{
|
||||||
|
while(Capturing.get()){
|
||||||
|
try {
|
||||||
|
qr_semaphore.acquire();
|
||||||
|
UMat gray;
|
||||||
|
synchronized (lockObject){
|
||||||
|
gray = GrayMat;
|
||||||
|
}
|
||||||
|
String qr = DetectQRFromMat(gray);
|
||||||
|
if (ValidBarCode(qr)){
|
||||||
|
if (event!=null) event.onDetectedQRCode(qr);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
System.out.println(Thread.currentThread().getName()+" interrupted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Face Detection Thread
|
||||||
|
Semaphore face_semaphore = new Semaphore(0);
|
||||||
|
Thread face_detect = new Thread(()->{
|
||||||
|
// eye state = -1 means unknown, 0 means closed, 1 means open
|
||||||
|
final AtomicInteger eye_state = new AtomicInteger(-1);
|
||||||
|
final AtomicBoolean waiting_for_second_blink = new AtomicBoolean(false);
|
||||||
|
final AtomicLong last_blink = new AtomicLong(0);
|
||||||
|
final AtomicInteger no_face_counter = new AtomicInteger(0);
|
||||||
|
final AtomicInteger face_counter = new AtomicInteger(0);
|
||||||
|
final AtomicInteger blink_counter = new AtomicInteger(0);
|
||||||
|
final AtomicInteger no_eye_counter = new AtomicInteger(0);
|
||||||
|
final AtomicInteger have_eye_counter = new AtomicInteger(0);
|
||||||
|
while(Capturing.get()){
|
||||||
|
try {
|
||||||
|
face_semaphore.acquire();
|
||||||
|
UMat gray;
|
||||||
|
synchronized (lockObject){
|
||||||
|
gray = GrayMat;
|
||||||
|
}
|
||||||
|
|
||||||
|
DetectorResult theface = null;
|
||||||
|
boolean have_frontal_face = false;
|
||||||
|
boolean have_left_45_face = false;
|
||||||
|
int _face_width = 0;
|
||||||
|
int _face_height = 0;
|
||||||
|
|
||||||
|
List<DetectorResult> frontalfaces = HaveFrontalFace(gray);
|
||||||
|
if (!frontalfaces.isEmpty()){
|
||||||
|
for(DetectorResult rect : frontalfaces){
|
||||||
|
if (rect.haveFace() ){
|
||||||
|
rect.FaceRectangle(LiveMat);
|
||||||
|
if (rect.getFaceWidth()>_face_width) _face_width = rect.getFaceWidth();
|
||||||
|
if (rect.getFaceHeight()>_face_height) _face_height = rect.getFaceHeight();
|
||||||
|
theface = rect;
|
||||||
|
have_frontal_face = true;
|
||||||
|
if (rect.haveEyes()){
|
||||||
|
rect.EyesRectangle(LiveMat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// gak punya frontal face
|
||||||
|
// coba cek punya profile left face 45 gak
|
||||||
|
List<DetectorResult> Left45Faces = HaveLeft45Face(gray);
|
||||||
|
if (!Left45Faces.isEmpty()){
|
||||||
|
for(DetectorResult rect : Left45Faces){
|
||||||
|
if (rect.haveFace()){
|
||||||
|
rect.FaceRectangle(LiveMat);
|
||||||
|
if (rect.getFaceWidth()>_face_width) _face_width = rect.getFaceWidth();
|
||||||
|
if (rect.getFaceHeight()>_face_height) _face_height = rect.getFaceHeight();
|
||||||
|
have_left_45_face = true;
|
||||||
|
if (rect.haveEyes()){
|
||||||
|
rect.EyesRectangle(LiveMat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (have_frontal_face){
|
||||||
|
if (face_counter.incrementAndGet()<5) continue;
|
||||||
|
no_face_counter.set(0);
|
||||||
|
if (event!=null) event.onFrontalFaceDetector(true, _face_width, _face_height);
|
||||||
|
LabelVisible(face_indicator,true);
|
||||||
|
|
||||||
|
if (theface.getFace()!=null){
|
||||||
|
LiveMatROI = new Rect(theface.getFace().x(), theface.getFace().y(), theface.getFace().width(), theface.getFace().height());
|
||||||
|
//System.out.println("Frontal Face Detected from camera "+cameratitle+" "+RectToString(LiveMatROI));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theface.getEyesCount()>=2){
|
||||||
|
// ada mata (buka mata)
|
||||||
|
if (have_eye_counter.incrementAndGet()<5) continue;
|
||||||
|
no_eye_counter.set(0);
|
||||||
|
|
||||||
|
if (event!=null) event.onEyeDetector(true);
|
||||||
|
LabelVisible(eye_indicator,true);
|
||||||
|
|
||||||
|
//System.out.println("Valid Eye Detected from camera "+cameratitle);
|
||||||
|
// Valid eye condition
|
||||||
|
|
||||||
|
if (eye_state.get()!=1){
|
||||||
|
// transisi dari tutup mata ke buka mata
|
||||||
|
if (eye_state.get()==-1) {
|
||||||
|
System.out.println("First Eye Detected from camera "+cameratitle.getText());
|
||||||
|
eye_state.set(1);
|
||||||
|
} else {
|
||||||
|
System.out.println("Transition from close to open eyes");
|
||||||
|
eye_state.set(1);
|
||||||
|
|
||||||
|
blink_counter.incrementAndGet();
|
||||||
|
if (event!=null) event.onBlink(blink_counter.get());
|
||||||
|
LabelSetText(BlinkCounterLabel, String.valueOf(blink_counter.get()),null);
|
||||||
|
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if (waiting_for_second_blink.get()){
|
||||||
|
long diff = now - last_blink.get();
|
||||||
|
// kalau beda waktu antara blink 1 dan blink 2 kurang dari 3 detik
|
||||||
|
if (diff<=3000){
|
||||||
|
System.out.println("Double Blink Detected from camera "+cameratitle.getText());
|
||||||
|
if (event!=null) event.onDoubleBlink((int)diff);
|
||||||
|
}
|
||||||
|
waiting_for_second_blink.set(false);
|
||||||
|
} else {
|
||||||
|
waiting_for_second_blink.set(true);
|
||||||
|
System.out.println("First Blink Detected from camera "+cameratitle.getText());
|
||||||
|
}
|
||||||
|
last_blink.set(now);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// ada muka, tidak ada mata
|
||||||
|
// transisi dari buka mata ke tutup mata
|
||||||
|
if (no_eye_counter.incrementAndGet()<5) continue;
|
||||||
|
have_eye_counter.set(0);
|
||||||
|
|
||||||
|
if (event!=null) event.onEyeDetector(false);
|
||||||
|
LabelVisible(eye_indicator,false);
|
||||||
|
// Valid no eye condition
|
||||||
|
|
||||||
|
|
||||||
|
if (eye_state.get()!=0){
|
||||||
|
System.out.println("Transition from open to close eyes");
|
||||||
|
eye_state.set(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (have_left_45_face ){
|
||||||
|
if (event!=null) event.onProfileFaceDetector(true, _face_width, _face_height);
|
||||||
|
LabelVisible(face_indicator,true);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// no face detected, but let's not cancel the previous state immediately
|
||||||
|
if (no_face_counter.incrementAndGet()<30) continue;
|
||||||
|
// beneran dianggap no face detected
|
||||||
|
eye_state.set(-1);
|
||||||
|
last_blink.set(0);
|
||||||
|
waiting_for_second_blink.set(false);
|
||||||
|
face_counter.set(0);
|
||||||
|
blink_counter.set(0);
|
||||||
|
no_eye_counter.set(0);
|
||||||
|
have_eye_counter.set(0);
|
||||||
|
|
||||||
|
if (event!=null) {
|
||||||
|
event.onFrontalFaceDetector(false, _face_width, _face_height);
|
||||||
|
event.onProfileFaceDetector(false, _face_width, _face_height);
|
||||||
|
event.onEyeDetector(false);
|
||||||
|
event.onBlink(blink_counter.get());
|
||||||
|
|
||||||
|
LabelSetText(BlinkCounterLabel, "",null);
|
||||||
|
LabelVisible(face_indicator,false);
|
||||||
|
LabelVisible(eye_indicator,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
UMat rgbmat = new UMat(LiveMat.size(), CV_8UC3);
|
||||||
|
cvtColor(LiveMat, rgbmat, COLOR_BGR2RGB);
|
||||||
|
|
||||||
|
Mat imgmat = new Mat();
|
||||||
|
rgbmat.copyTo(imgmat); // copy back to CPU
|
||||||
|
// Update Task Value usign matToWritableImage
|
||||||
|
setCameraStream(matToWritableImage(imgmat));
|
||||||
|
//updateValue(matToWritableImage(imgmat));
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
System.out.println(Thread.currentThread().getName()+" interrupted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Camera Capture Thread
|
||||||
|
Thread cam_capture = new Thread(()->{
|
||||||
|
while (Capturing.get()) {
|
||||||
|
try {
|
||||||
|
// selama proses pengambilan foto, jangan ambil frame
|
||||||
|
if (TakingPhoto!=null) TakingPhoto.await();
|
||||||
|
|
||||||
|
IsGrabbingLiveView.drainPermits();
|
||||||
|
IsGrabbingLiveView.release();
|
||||||
|
//IsGrabbingLiveView.set(true);
|
||||||
|
Frame frame = null;
|
||||||
|
if (Capturing.get()) {
|
||||||
|
try{
|
||||||
|
frame = mGrabber.grab(); // grab frame
|
||||||
|
} catch (FrameGrabber.Exception e){
|
||||||
|
if (Capturing.get()){
|
||||||
|
// kalau ada exception padahal masih capturing. Kalau sudah tidak capturing, tidak peduli
|
||||||
|
if (ValidString(e.getMessage())){
|
||||||
|
String msg = e.getMessage();
|
||||||
|
System.out.println("Exception on "+Thread.currentThread().getName()+" :"+msg);
|
||||||
|
if (msg.contains("start() been called")){
|
||||||
|
if (Capturing.get()){
|
||||||
|
System.out.println("Camera "+Thread.currentThread().getName()+" has been stopped, restarting");
|
||||||
|
mGrabber.close();
|
||||||
|
//Wait(100);
|
||||||
|
mGrabber.start();
|
||||||
|
mGrabber.flush();
|
||||||
|
} else {
|
||||||
|
System.out.println("Camera "+Thread.currentThread().getName()+" has been stopped, not restarting");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IsGrabbingLiveView.set(false);
|
||||||
|
if (frame==null) continue;
|
||||||
|
Mat mat = matconverter.convert(frame); // convert to Mat
|
||||||
|
fps.incrementAndGet();
|
||||||
|
|
||||||
|
UMat originalmat = new UMat();
|
||||||
|
mat.copyTo(originalmat); // copy to originalmat for using OpenCL
|
||||||
|
if (config.isMirrorCamera()){
|
||||||
|
// revisi 18/03/2025
|
||||||
|
UMat flippedmat = new UMat();
|
||||||
|
opencv_core.flip(originalmat, flippedmat, 0); // flip vertical
|
||||||
|
flippedmat.copyTo(originalmat);
|
||||||
|
flippedmat.close();
|
||||||
|
}
|
||||||
|
if (config.isFlipCamera()){
|
||||||
|
// revisi 18/03/2025
|
||||||
|
UMat flippedmat = new UMat();
|
||||||
|
opencv_core.flip(originalmat, flippedmat, 1); // flip horizontal
|
||||||
|
flippedmat.copyTo(originalmat);
|
||||||
|
flippedmat.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// rotate 90 degree counter clockwise karena kamera potrait
|
||||||
|
opencv_core.rotate(originalmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!BestMat.empty()) {
|
||||||
|
|
||||||
|
// LiveMat and GrayMat are synchronized
|
||||||
|
synchronized (lockObject){
|
||||||
|
opencv_imgproc.resize(BestMat, LiveMat, LiveSize); // resize to LiveSize
|
||||||
|
opencv_imgproc.cvtColor(LiveMat,GrayMat, COLOR_BGR2GRAY); // convert to grayscale
|
||||||
|
}
|
||||||
|
|
||||||
|
if (use_qr){
|
||||||
|
qr_semaphore.release();
|
||||||
|
}
|
||||||
|
if (use_face){
|
||||||
|
face_semaphore.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch ( FrameGrabber.Exception fe){
|
||||||
|
System.out.println("FrameGrabber Exception in" + Thread.currentThread().getName() + " : " + fe.getMessage());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
System.out.println(Thread.currentThread().getName()+" interrupted");
|
||||||
|
} catch (Exception e){
|
||||||
|
System.out.println(Thread.currentThread().getName()+" exception : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public boolean StartLiveView(LiveCamEvent event, String cameratitle, boolean use_qr , boolean use_face) {
|
||||||
this.event = event;
|
this.event = event;
|
||||||
if (mGrabber != null) {
|
if (mGrabber != null) {
|
||||||
try {
|
try {
|
||||||
@@ -818,309 +1124,51 @@ public class Cameradetail {
|
|||||||
Capturing.set(true);
|
Capturing.set(true);
|
||||||
if (event!=null) event.onStartCapturing();
|
if (event!=null) event.onStartCapturing();
|
||||||
|
|
||||||
Task<Image> task = new Task<>() {
|
|
||||||
@SuppressWarnings("BusyWait")
|
|
||||||
|
TimerTask fpsTask = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
protected Image call() {
|
public void run() {
|
||||||
// repeat until capturing is false
|
if (Capturing.get()){
|
||||||
AtomicInteger fps = new AtomicInteger(0);
|
int fpsval = fps.getAndSet(0);
|
||||||
// eye state = -1 means unknown, 0 means closed, 1 means open
|
if (fpsval!=LiveFPS){
|
||||||
int eye_state = -1;
|
LiveFPS = fpsval;
|
||||||
boolean waiting_for_second_blink = false;
|
if (event!=null) event.onIntervalUpdate();
|
||||||
long last_blink = 0;
|
AutoCloseAlert.ChangeCamStatus(switch (cameratitle){
|
||||||
|
case "01" -> 1;
|
||||||
TimerTask fpsTask = new TimerTask() {
|
case "02" -> 2;
|
||||||
@Override
|
case "03" -> 3;
|
||||||
public void run() {
|
case "04" -> 4;
|
||||||
int fpsval = fps.getAndSet(0);
|
case "05" -> 5;
|
||||||
if (fpsval!=LiveFPS){
|
default -> 0;
|
||||||
LiveFPS = fpsval;
|
}, LiveFPS>0 );
|
||||||
if (event!=null) event.onIntervalUpdate();
|
|
||||||
AutoCloseAlert.ChangeCamStatus(switch (cameratitle){
|
|
||||||
case "01" -> 1;
|
|
||||||
case "02" -> 2;
|
|
||||||
case "03" -> 3;
|
|
||||||
case "04" -> 4;
|
|
||||||
case "05" -> 5;
|
|
||||||
default -> 0;
|
|
||||||
}, LiveFPS>0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Timer timer = new java.util.Timer();
|
|
||||||
timer.scheduleAtFixedRate(fpsTask, 1000, 1000);
|
|
||||||
|
|
||||||
|
|
||||||
boolean have_frontal_face;
|
|
||||||
boolean have_left_45_face;
|
|
||||||
int _face_width;
|
|
||||||
int _face_height;
|
|
||||||
boolean have_palm = false;
|
|
||||||
boolean have_fist = false;
|
|
||||||
int no_face_counter = 0;
|
|
||||||
int face_counter = 0;
|
|
||||||
int blink_counter = 0;
|
|
||||||
int have_eye_counter = 0;
|
|
||||||
int no_eye_counter = 0;
|
|
||||||
|
|
||||||
while (Capturing.get()) {
|
|
||||||
try {
|
|
||||||
// selama proses pengambilan foto, jangan ambil frame
|
|
||||||
while(TakingPhoto.get() && Capturing.get()){
|
|
||||||
Thread.sleep(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Capturing.get()) return null;
|
|
||||||
IsGrabbingLiveView.set(true);
|
|
||||||
Frame frame;
|
|
||||||
try{
|
|
||||||
frame = mGrabber.grab(); // grab frame
|
|
||||||
} catch (Exception e){
|
|
||||||
frame = null;
|
|
||||||
|
|
||||||
if (e.getMessage()!=null && !e.getMessage().isBlank()){
|
|
||||||
String msg = e.getMessage();
|
|
||||||
if (msg.contains("start() been called")){
|
|
||||||
if (Capturing.get()){
|
|
||||||
System.out.println("Camera "+cameratitle+" has been stopped, restarting");
|
|
||||||
mGrabber.close();
|
|
||||||
Wait(100);
|
|
||||||
mGrabber.start();
|
|
||||||
mGrabber.flush();
|
|
||||||
} else {
|
|
||||||
System.out.println("Camera "+cameratitle+" has been stopped, not restarting");
|
|
||||||
}
|
|
||||||
} else 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();
|
|
||||||
|
|
||||||
UMat originalmat = new UMat();
|
|
||||||
mat.copyTo(originalmat); // copy to originalmat for using OpenCL
|
|
||||||
if (config.isMirrorCamera()){
|
|
||||||
// revisi 18/03/2025
|
|
||||||
UMat flippedmat = new UMat();
|
|
||||||
opencv_core.flip(originalmat, flippedmat, 0); // flip vertical
|
|
||||||
flippedmat.copyTo(originalmat);
|
|
||||||
}
|
|
||||||
if (config.isFlipCamera()){
|
|
||||||
// revisi 18/03/2025
|
|
||||||
UMat flippedmat = new UMat();
|
|
||||||
opencv_core.flip(originalmat, flippedmat, 1); // flip horizontal
|
|
||||||
flippedmat.copyTo(originalmat);
|
|
||||||
}
|
|
||||||
|
|
||||||
// rotate 90 degree counter clockwise karena kamera potrait
|
|
||||||
opencv_core.rotate(originalmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IsGrabbingLiveView.set(false);
|
|
||||||
|
|
||||||
if (!BestMat.empty()) {
|
|
||||||
opencv_imgproc.resize(BestMat, LiveMat, LiveSize); // resize to LiveSize
|
|
||||||
opencv_imgproc.cvtColor(LiveMat,GrayMat, COLOR_BGR2GRAY); // convert to grayscale
|
|
||||||
|
|
||||||
if (use_qr){
|
|
||||||
String qr = DetectQRFromMat(GrayMat);
|
|
||||||
if (ValidBarCode(qr)){
|
|
||||||
qrtext = qr;
|
|
||||||
if (event!=null) event.onDetectedQRCode(qrtext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (use_face){
|
|
||||||
DetectorResult theface = null;
|
|
||||||
have_frontal_face = false;
|
|
||||||
have_left_45_face = false;
|
|
||||||
_face_width = 0;
|
|
||||||
_face_height = 0;
|
|
||||||
|
|
||||||
List<DetectorResult> frontalfaces = HaveFrontalFace(GrayMat);
|
|
||||||
if (!frontalfaces.isEmpty()){
|
|
||||||
|
|
||||||
for(DetectorResult rect : frontalfaces){
|
|
||||||
if (rect.haveFace() ){
|
|
||||||
rect.FaceRectangle(LiveMat);
|
|
||||||
rect.EyesRectangle(LiveMat);
|
|
||||||
if (rect.getFaceWidth()>_face_width) _face_width = rect.getFaceWidth();
|
|
||||||
if (rect.getFaceHeight()>_face_height) _face_height = rect.getFaceHeight();
|
|
||||||
theface = rect;
|
|
||||||
have_frontal_face = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// gak punya frontal face
|
|
||||||
// coba cek punya profile left face 45 gak
|
|
||||||
List<DetectorResult> Left45Faces = HaveLeft45Face(GrayMat);
|
|
||||||
if (!Left45Faces.isEmpty()){
|
|
||||||
for(DetectorResult rect : Left45Faces){
|
|
||||||
if (rect.haveFace()){
|
|
||||||
rect.FaceRectangle(LiveMat);
|
|
||||||
rect.EyesRectangle(LiveMat);
|
|
||||||
if (rect.getFaceWidth()>_face_width) _face_width = rect.getFaceWidth();
|
|
||||||
if (rect.getFaceHeight()>_face_height) _face_height = rect.getFaceHeight();
|
|
||||||
have_left_45_face = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
LabelVisible(face_indicator,true);
|
|
||||||
|
|
||||||
if (theface.getFace()!=null){
|
|
||||||
LiveMatROI = new Rect(theface.getFace().x(), theface.getFace().y(), theface.getFace().width(), theface.getFace().height());
|
|
||||||
//System.out.println("Frontal Face Detected from camera "+cameratitle+" "+RectToString(LiveMatROI));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theface.haveEyes()){
|
|
||||||
// ada mata (buka mata)
|
|
||||||
// if (have_eye_counter<1){
|
|
||||||
// have_eye_counter++;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// no_eye_counter = 0;
|
|
||||||
//System.out.println("Valid Eye Detected from camera "+cameratitle);
|
|
||||||
if (event!=null) event.onEyeDetector(true);
|
|
||||||
LabelVisible(eye_indicator,true);
|
|
||||||
// Valid eye condition
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
blink_counter++;
|
|
||||||
if (event!=null) event.onBlink(blink_counter);
|
|
||||||
SetText(BlinkCounterLabel, String.valueOf(blink_counter));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 3 detik
|
|
||||||
if (diff<=3000){
|
|
||||||
System.out.println("Double Blink Detected from camera "+cameratitle);
|
|
||||||
if (event!=null) event.onDoubleBlink((int)diff);
|
|
||||||
}
|
|
||||||
waiting_for_second_blink = false;
|
|
||||||
} else {
|
|
||||||
waiting_for_second_blink = true;
|
|
||||||
System.out.println("First Blink Detected from camera "+cameratitle);
|
|
||||||
}
|
|
||||||
last_blink = now;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// ada muka, tidak ada mata
|
|
||||||
// transisi dari buka mata ke tutup mata
|
|
||||||
// if (no_eye_counter<1){
|
|
||||||
// no_eye_counter++;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// have_eye_counter = 0;
|
|
||||||
//System.out.println("Valid No Eye Detected from camera "+cameratitle);
|
|
||||||
if (event!=null) event.onEyeDetector(false);
|
|
||||||
LabelVisible(eye_indicator,false);
|
|
||||||
// Valid no eye condition
|
|
||||||
|
|
||||||
if (eye_state!=0){
|
|
||||||
System.out.println("Transition from open to close eyes");
|
|
||||||
eye_state = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (have_left_45_face ){
|
|
||||||
no_face_counter = 0;
|
|
||||||
if (event!=null) event.onProfileFaceDetector(true, _face_width, _face_height);
|
|
||||||
LabelVisible(face_indicator,true);
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// no face detected, but let's not cancel the previous state immediately
|
|
||||||
|
|
||||||
if (no_face_counter<60){
|
|
||||||
// toleransi no face selama 60 frame
|
|
||||||
no_face_counter++;
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
// beneran dianggap no face detected
|
|
||||||
eye_state = -1;
|
|
||||||
last_blink = 0;
|
|
||||||
waiting_for_second_blink = false;
|
|
||||||
face_counter = 0;
|
|
||||||
blink_counter = 0;
|
|
||||||
no_eye_counter=0;
|
|
||||||
have_eye_counter=0;
|
|
||||||
|
|
||||||
|
|
||||||
if (event!=null) {
|
|
||||||
event.onFrontalFaceDetector(false, _face_width, _face_height);
|
|
||||||
event.onProfileFaceDetector(false, _face_width, _face_height);
|
|
||||||
event.onEyeDetector(false);
|
|
||||||
event.onBlink(blink_counter);
|
|
||||||
SetText(BlinkCounterLabel, "");
|
|
||||||
LabelVisible(face_indicator,false);
|
|
||||||
LabelVisible(eye_indicator,false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
UMat rgbmat = new UMat(LiveMat.size(), CV_8UC3);
|
|
||||||
cvtColor(LiveMat, rgbmat, COLOR_BGR2RGB);
|
|
||||||
|
|
||||||
Mat imgmat = new Mat();
|
|
||||||
rgbmat.copyTo(imgmat); // copy back to CPU
|
|
||||||
// Update Task Value usign matToWritableImage
|
|
||||||
updateValue(matToWritableImage(imgmat, imgmat.cols(), imgmat.rows()));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (ValidString(e.getMessage())){
|
|
||||||
raise_log("Unable to Grab Frame, Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
//if (!Capturing.get()) Platform.runLater(this::StopLiveView);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fps.set(0);
|
||||||
|
this.cancel();
|
||||||
}
|
}
|
||||||
timer.cancel();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// value dari task, yaitu image, akan diupdate ke camerastream
|
timer.scheduleAtFixedRate(fpsTask, 1000, 1000);
|
||||||
task.valueProperty().addListener((obs, oldVal, newVal) -> {
|
|
||||||
if (newVal != null) {
|
|
||||||
setCameraStream(newVal);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// start task
|
|
||||||
new Thread(task).start();
|
this.use_qr = use_qr;
|
||||||
|
this.use_face = use_face;
|
||||||
|
cam_capture.setName("cam_capture "+cameratitle);
|
||||||
|
cam_capture.setDaemon(true);
|
||||||
|
cam_capture.start();
|
||||||
|
System.out.println("Starting cam_capture thread");
|
||||||
|
|
||||||
|
qr_detect.setName("qr_detect "+cameratitle);
|
||||||
|
qr_detect.setDaemon(true);
|
||||||
|
qr_detect.start();
|
||||||
|
System.out.println("Starting qr_detect thread");
|
||||||
|
|
||||||
|
face_detect.setName("face_detect "+cameratitle);
|
||||||
|
face_detect.setDaemon(true);
|
||||||
|
face_detect.start();
|
||||||
|
System.out.println("Starting face_detect thread");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1221,19 +1269,13 @@ public class Cameradetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private WritableImage matToWritableImage(Mat mat){
|
||||||
|
int cols = mat.cols();
|
||||||
|
int rows = mat.rows();
|
||||||
private double getBrightnessFromGrayMat(Mat graymat){
|
|
||||||
Scalar mean = mean(graymat);
|
|
||||||
return mean.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private WritableImage matToWritableImage(Mat mat, int cols, int rows){
|
|
||||||
WritableImage writableImage = new WritableImage(cols, rows);
|
WritableImage writableImage = new WritableImage(cols, rows);
|
||||||
ByteBuffer buffer = mat.createBuffer();
|
ByteBuffer buffer = mat.createBuffer();
|
||||||
PixelFormat<ByteBuffer> pixelFormat = PixelFormat.getByteRgbInstance();
|
PixelFormat<ByteBuffer> pixelFormat = PixelFormat.getByteRgbInstance();
|
||||||
writableImage.getPixelWriter().setPixels(0, 0, mat.cols(), mat.rows(), pixelFormat, buffer, mat.cols() * 3);
|
writableImage.getPixelWriter().setPixels(0, 0, cols, rows, pixelFormat, buffer, cols * 3);
|
||||||
return writableImage;
|
return writableImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,21 +114,21 @@ public class CaptureView {
|
|||||||
config.Save();
|
config.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trigger_autofocus(Cameradetail image) throws InterruptedException {
|
private void trigger_autofocus(Cameradetail image) {
|
||||||
if (image!=null){
|
if (image!=null){
|
||||||
if (image.isCapturing()){
|
if (image.isCapturing()){
|
||||||
image.setAutoFocus(false);
|
image.setAutoFocus(false);
|
||||||
Thread.sleep(5);
|
Wait(5);
|
||||||
image.setFocus(0.7);
|
image.setFocus(0.7);
|
||||||
Thread.sleep(5);
|
Wait(5);
|
||||||
image.setAutoFocus(true);
|
image.setAutoFocus(true);
|
||||||
Thread.sleep(5);
|
Wait(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void AutoFocus() throws InterruptedException {
|
private void AutoFocus() {
|
||||||
trigger_autofocus(image1);
|
trigger_autofocus(image1);
|
||||||
trigger_autofocus(image2);
|
trigger_autofocus(image2);
|
||||||
trigger_autofocus(image3);
|
trigger_autofocus(image3);
|
||||||
@@ -227,6 +227,35 @@ public class CaptureView {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class CallablePhotoResult implements Callable<PhotoResult> {
|
||||||
|
private final String directory;
|
||||||
|
private final String prefix;
|
||||||
|
private final Cameradetail image;
|
||||||
|
|
||||||
|
public CallablePhotoResult(String directory, String prefix, Cameradetail image) {
|
||||||
|
this.directory = directory;
|
||||||
|
this.prefix = prefix;
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PhotoResult call() {
|
||||||
|
if (image!=null){
|
||||||
|
image.RemapROI(0.1, 0.3, false);
|
||||||
|
double sharpness = CalculateSharpness(image.getGrayMat());
|
||||||
|
image.setSharpness_indicator(sharpness);
|
||||||
|
PhotoResult p = image.TakePhoto(directory, prefix);
|
||||||
|
p.setSharpscore(sharpness);
|
||||||
|
if (ValidFile(p.getFullres())){
|
||||||
|
if (ValidFile(p.getCompressedfile())){
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void take_photo_lanjutan(String directory, String prefix){
|
private void take_photo_lanjutan(String directory, String prefix){
|
||||||
audioPlayer.PlayFile(audio_camera_shutter, null);
|
audioPlayer.PlayFile(audio_camera_shutter, null);
|
||||||
Size thumbsize = new Size(160,120);
|
Size thumbsize = new Size(160,120);
|
||||||
@@ -238,91 +267,11 @@ public class CaptureView {
|
|||||||
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(5);
|
ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||||
|
|
||||||
Callable<PhotoResult> task1 = ()->{
|
CallablePhotoResult task1 = new CallablePhotoResult(directory, prefix, image1);
|
||||||
if (image1!=null) {
|
CallablePhotoResult task2 = new CallablePhotoResult(directory, prefix, image2);
|
||||||
image1.RemapROI(0.1,0.3, false);
|
CallablePhotoResult task3 = new CallablePhotoResult(directory, prefix, image3);
|
||||||
|
CallablePhotoResult task4 = new CallablePhotoResult(directory, prefix, image4);
|
||||||
double sharpness = CalculateSharpness(image1.getGrayMat());
|
CallablePhotoResult task5 = new CallablePhotoResult(directory, prefix, image5);
|
||||||
image1.setSharpness_indicator(sharpness);
|
|
||||||
PhotoResult p1 = image1.TakePhoto(directory,prefix);
|
|
||||||
p1.setSharpscore(sharpness);
|
|
||||||
if (ValidFile(p1.getFullres())){
|
|
||||||
if (ValidFile(p1.getCompressedfile())){
|
|
||||||
return p1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else System.out.println("Image1 is null");
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
Callable<PhotoResult> task2 = ()->{
|
|
||||||
if (image2!=null) {
|
|
||||||
image2.RemapROI(0.1,0.3, false);
|
|
||||||
double sharpness = CalculateSharpness(image2.getGrayMat());
|
|
||||||
image2.setSharpness_indicator(sharpness);
|
|
||||||
PhotoResult p2 = image2.TakePhoto(directory,prefix);
|
|
||||||
p2.setSharpscore(sharpness);
|
|
||||||
if (ValidFile(p2.getFullres())){
|
|
||||||
if (ValidFile(p2.getCompressedfile())){
|
|
||||||
return p2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else System.out.println("Image2 is null");
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
Callable<PhotoResult> task3 = ()->{
|
|
||||||
if (image3!=null) {
|
|
||||||
image3.RemapROI(0.1,0.3, false);
|
|
||||||
double sharpness = CalculateSharpness(image3.getGrayMat());
|
|
||||||
image3.setSharpness_indicator(sharpness);
|
|
||||||
PhotoResult p3 = image3.TakePhoto(directory,prefix);
|
|
||||||
p3.setSharpscore(sharpness);
|
|
||||||
|
|
||||||
if (ValidFile(p3.getFullres())){
|
|
||||||
if (ValidFile(p3.getCompressedfile())){
|
|
||||||
return p3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else System.out.println("Image3 is null");
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
Callable<PhotoResult> task4 = ()->{
|
|
||||||
if (image4!=null) {
|
|
||||||
image4.RemapROI(0.1,0.3, false);
|
|
||||||
double sharpness = CalculateSharpness(image4.getGrayMat());
|
|
||||||
image4.setSharpness_indicator(sharpness);
|
|
||||||
PhotoResult p4 = image4.TakePhoto(directory,prefix);
|
|
||||||
p4.setSharpscore(sharpness);
|
|
||||||
|
|
||||||
if (ValidFile(p4.getFullres())){
|
|
||||||
if (ValidFile(p4.getCompressedfile())){
|
|
||||||
return p4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else System.out.println("Image4 is null");
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
Callable<PhotoResult> task5 = ()->{
|
|
||||||
if (image5!=null) {
|
|
||||||
image5.RemapROI(0.1,0.3, false);
|
|
||||||
double sharpness = CalculateSharpness(image5.getGrayMat());
|
|
||||||
image5.setSharpness_indicator(sharpness);
|
|
||||||
PhotoResult p5 = image5.TakePhoto(directory,prefix);
|
|
||||||
p5.setSharpscore(sharpness);
|
|
||||||
|
|
||||||
if (ValidFile(p5.getFullres())){
|
|
||||||
if (ValidFile(p5.getCompressedfile())){
|
|
||||||
return p5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else System.out.println("Image5 is null");
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
PhotoResult p1 = null;
|
PhotoResult p1 = null;
|
||||||
PhotoResult p2 = null;
|
PhotoResult p2 = null;
|
||||||
@@ -533,12 +482,8 @@ 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, null);
|
|
||||||
if (AutoCloseAlert.banner_02!=null) {
|
|
||||||
System.out.println("Showing banner 02 after photo taken");
|
|
||||||
AutoCloseAlert.showbanner(AutoCloseAlert.banner_02, 0, null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] files = prc.compressed();
|
String[] files = prc.compressed();
|
||||||
if (files.length>0){
|
if (files.length>0){
|
||||||
@@ -553,8 +498,17 @@ public class CaptureView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaybackFinished(String filename) {
|
public void onPlaybackFinished(String filename) {
|
||||||
UploadFiles(prc, prefix);
|
AutoCloseAlert.showpictures(prc.compressed(),2, (s)->{
|
||||||
if (runningTask!=null) runningTask.cancel(false);
|
if (AutoCloseAlert.banner_02!=null) {
|
||||||
|
System.out.println("Showing banner 02 after photo taken");
|
||||||
|
AutoCloseAlert.showbanner(AutoCloseAlert.banner_02, 0, null);
|
||||||
|
|
||||||
|
UploadFiles(prc, prefix);
|
||||||
|
if (runningTask!=null) runningTask.cancel(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -615,7 +569,6 @@ public class CaptureView {
|
|||||||
uploadtask.setOnSucceeded(e-> {
|
uploadtask.setOnSucceeded(e-> {
|
||||||
System.out.println("UploadTask succeeded");
|
System.out.println("UploadTask succeeded");
|
||||||
clear();
|
clear();
|
||||||
AutoCloseAlert.close();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadtask.setOnFailed(e-> {
|
uploadtask.setOnFailed(e-> {
|
||||||
@@ -626,12 +579,12 @@ public class CaptureView {
|
|||||||
audioPlayer.PlayFile(audio_upload_gagal, null);
|
audioPlayer.PlayFile(audio_upload_gagal, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AutoCloseAlert.show("Upload Failed", "Upload Failed", "Upload Failed", 5, s -> {
|
AutoCloseAlert.show("Upload Failed", "Upload Failed", "Upload Failed", 5, s -> clear());
|
||||||
clear();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
new Thread(uploadtask).start();
|
Thread uploadThread = new Thread(uploadtask);
|
||||||
|
uploadThread.setDaemon(true);
|
||||||
|
uploadThread.start();
|
||||||
|
|
||||||
} else ShowAlert(AlertType.ERROR, "Error", "No Photos Taken", "No Photos Taken, please check camera");
|
} else ShowAlert(AlertType.ERROR, "Error", "No Photos Taken", "No Photos Taken, please check camera");
|
||||||
}
|
}
|
||||||
@@ -713,7 +666,9 @@ public class CaptureView {
|
|||||||
Logger.info("Left90 Index: "+indexleft90);
|
Logger.info("Left90 Index: "+indexleft90);
|
||||||
if (indexleft90!=-1){
|
if (indexleft90!=-1){
|
||||||
final int finalindex = indexleft90;
|
final int finalindex = indexleft90;
|
||||||
new Thread(()-> SetupCameraWithController(image1, camleft90, finalindex)).start();
|
Thread c1 = new Thread(()-> SetupCameraWithController(image1, camleft90, finalindex));
|
||||||
|
c1.setDaemon(true);
|
||||||
|
c1.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -725,7 +680,9 @@ public class CaptureView {
|
|||||||
Logger.info("Left45 Index: "+indexleft45);
|
Logger.info("Left45 Index: "+indexleft45);
|
||||||
if (indexleft45!=-1) {
|
if (indexleft45!=-1) {
|
||||||
final int finalindex = indexleft45;
|
final int finalindex = indexleft45;
|
||||||
new Thread(()-> SetupCameraWithController(image2, camleft45, finalindex)).start();
|
Thread c2 = new Thread(()-> SetupCameraWithController(image2, camleft45, finalindex));
|
||||||
|
c2.setDaemon(true);
|
||||||
|
c2.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -737,7 +694,9 @@ public class CaptureView {
|
|||||||
Logger.info("Center Index: "+indexcenter);
|
Logger.info("Center Index: "+indexcenter);
|
||||||
if (indexcenter!=-1) {
|
if (indexcenter!=-1) {
|
||||||
final int finalindex = indexcenter;
|
final int finalindex = indexcenter;
|
||||||
new Thread(()-> SetupCameraWithController(image3, camcenter, finalindex)).start();
|
Thread c3 = new Thread(()-> SetupCameraWithController(image3, camcenter, finalindex));
|
||||||
|
c3.setDaemon(true);
|
||||||
|
c3.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -749,7 +708,9 @@ public class CaptureView {
|
|||||||
Logger.info("Right45 Index: "+indexright45);
|
Logger.info("Right45 Index: "+indexright45);
|
||||||
if (indexright45!=-1) {
|
if (indexright45!=-1) {
|
||||||
final int finalindex = indexright45;
|
final int finalindex = indexright45;
|
||||||
new Thread(()-> SetupCameraWithController(image4, camright45, finalindex)).start();
|
Thread c4 = new Thread(()-> SetupCameraWithController(image4, camright45, finalindex));
|
||||||
|
c4.setDaemon(true);
|
||||||
|
c4.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,7 +723,9 @@ public class CaptureView {
|
|||||||
Logger.info("Right90 Index: "+indexright90);
|
Logger.info("Right90 Index: "+indexright90);
|
||||||
if (indexright90!=-1) {
|
if (indexright90!=-1) {
|
||||||
final int finalindex = indexright90;
|
final int finalindex = indexright90;
|
||||||
new Thread(()-> SetupCameraWithController(image5, camright90, finalindex)).start();
|
Thread c5 = new Thread(()-> SetupCameraWithController(image5, camright90, finalindex));
|
||||||
|
c5.setDaemon(true);
|
||||||
|
c5.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -776,11 +739,9 @@ public class CaptureView {
|
|||||||
|
|
||||||
private void clear(){
|
private void clear(){
|
||||||
isTakingPhoto.set(false);
|
isTakingPhoto.set(false);
|
||||||
Platform.runLater(()->{
|
TextAreaSetText(medicalRecordID,"");
|
||||||
medicalRecordID.setText("");
|
TextAreaSetText(PatientName,"");
|
||||||
PatientName.setText("");
|
TextAreaSetText(barcodeData,"");
|
||||||
barcodeData.setText("");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unload(){
|
public void Unload(){
|
||||||
@@ -891,9 +852,7 @@ public class CaptureView {
|
|||||||
String prefix = barcodeData.getText();
|
String prefix = barcodeData.getText();
|
||||||
if (!barCode.equals(prefix)){
|
if (!barCode.equals(prefix)){
|
||||||
final String finalbarCode = barCode;
|
final String finalbarCode = barCode;
|
||||||
Platform.runLater(()->{
|
TextAreaSetText(barcodeData, finalbarCode);
|
||||||
barcodeData.setText(finalbarCode);
|
|
||||||
});
|
|
||||||
Task<PatientRecord> checkpatientID = new Task<>() {
|
Task<PatientRecord> checkpatientID = new Task<>() {
|
||||||
@Override
|
@Override
|
||||||
protected PatientRecord call() throws Exception {
|
protected PatientRecord call() throws Exception {
|
||||||
@@ -916,17 +875,14 @@ public class CaptureView {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.error("Record associated with barcode ",finalbarCode," is empty");
|
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");
|
throw new Exception("Data dengan barcode "+finalbarCode+" ditemukan di server, tetapi kosong");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.error("Record associated with barcode ",finalbarCode," is not found");
|
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");
|
throw new Exception("Data dengan barcode "+finalbarCode+" tidak ditemukan di server");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.error("BarcodeResullt with barcode ",finalbarCode," is null");
|
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");
|
throw new Exception("BarcodeResult dengan barcode "+finalbarCode+" menghasilkan null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -936,14 +892,13 @@ public class CaptureView {
|
|||||||
PatientRecord pr = checkpatientID.getValue();
|
PatientRecord pr = checkpatientID.getValue();
|
||||||
if (pr!=null){
|
if (pr!=null){
|
||||||
int medrecid = toInt(pr.medical_record_detail_id);
|
int medrecid = toInt(pr.medical_record_detail_id);
|
||||||
System.out.println("checkpatientID.setOnSucceeded medrecid : "+medrecid);
|
TextAreaSetText(medicalRecordID,""+medrecid);
|
||||||
Platform.runLater(()->{
|
TextAreaSetText(PatientName, pr.name);
|
||||||
medicalRecordID.setText(""+medrecid);
|
|
||||||
PatientName.setText(pr.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
runningTask = timeoutExecutor.schedule(()->{
|
runningTask = timeoutExecutor.schedule(()->{
|
||||||
// timeout
|
// timeout
|
||||||
|
System.out.println("runningTask timeout after "+timeout+" seconds");
|
||||||
clear();
|
clear();
|
||||||
}, timeout, TimeUnit.SECONDS);
|
}, timeout, TimeUnit.SECONDS);
|
||||||
|
|
||||||
@@ -970,16 +925,13 @@ public class CaptureView {
|
|||||||
System.out.println("checkpatientID.setOnFailed message : "+message);
|
System.out.println("checkpatientID.setOnFailed message : "+message);
|
||||||
|
|
||||||
|
|
||||||
AutoCloseAlert.show("Data Tidak Ditemukan", message, "Pastikan data barcode anda benar", 5, s -> {
|
AutoCloseAlert.show("Data Tidak Ditemukan", "Pastikan data barcode anda benar", message , 5, s -> clear());
|
||||||
clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
new Thread(checkpatientID).start();
|
Thread checkpatientIDThread = new Thread(checkpatientID);
|
||||||
|
checkpatientIDThread.setDaemon(true);
|
||||||
|
checkpatientIDThread.start();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -994,8 +946,19 @@ public class CaptureView {
|
|||||||
}
|
}
|
||||||
//update_status(image);
|
//update_status(image);
|
||||||
|
|
||||||
|
// instruksi scan barcode ketika welcomeUI masih muncul dan ada muka terdeteksi
|
||||||
|
if (hasface && Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
|
||||||
|
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||||
|
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
|
||||||
|
audioPlayer.StopCurrentPlayback();
|
||||||
|
audioPlayer.PlayFile(audio_scan_barcode, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1047,25 +1010,22 @@ public class CaptureView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update_status(Cameradetail image){
|
private void update_status(Cameradetail image){
|
||||||
Platform.runLater(()-> {
|
String sb = "Camera Started, " +
|
||||||
String sb = "Camera Started, " +
|
image.getBestWidth() +
|
||||||
image.getBestWidth() +
|
"x" +
|
||||||
"x" +
|
image.getBestHeight() +
|
||||||
image.getBestHeight() +
|
"@" +
|
||||||
"@" +
|
image.getLiveFPS();
|
||||||
image.getLiveFPS();
|
|
||||||
|
|
||||||
image.setCameraStatus(sb);
|
image.setCameraStatus(sb);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
image.setCameraStatus("Camera Starting");
|
||||||
Platform.runLater(()-> image.setCameraStatus("Camera Starting"));
|
|
||||||
if (image.StartLiveView(lce, title, use_qr_detector, use_face_detector)){
|
if (image.StartLiveView(lce, title, use_qr_detector, use_face_detector)){
|
||||||
//TODO Start Live View berhasil, apa lagi yang mau dikerjakan ?
|
//TODO Start Live View berhasil, apa lagi yang mau dikerjakan ?
|
||||||
|
|
||||||
} else Platform.runLater(()->image.setCameraStatus("Unable to Set Grabber"));
|
} else image.setCameraStatus("Unable to Set Grabber");
|
||||||
} else Platform.runLater(()->image.setCameraStatus("Camera not found, please check setting"));
|
} else image.setCameraStatus("Camera not found, please check setting");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,4 +61,5 @@ public class DetectorResult {
|
|||||||
if (!haveEyes()) return 0;
|
if (!haveEyes()) return 0;
|
||||||
return Eyes.size();
|
return Eyes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,10 @@ import org.tinylog.Logger;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static Config.SomeCodes.IsInsideRect;
|
|
||||||
|
|
||||||
public class Detectors {
|
public class Detectors {
|
||||||
public static CascadeClassifier frontalfaceDetector;
|
public static CascadeClassifier frontalfaceDetector;
|
||||||
private static CascadeClassifier eyeDetector;
|
private static CascadeClassifier eyeDetector;
|
||||||
private static CascadeClassifier profilefaceDetector;
|
private static CascadeClassifier profilefaceDetector;
|
||||||
//private static CascadeClassifier palmDetector;
|
|
||||||
//private static CascadeClassifier fistDetector;
|
|
||||||
|
|
||||||
private static double scaleFactor = 1.1;
|
private static double scaleFactor = 1.1;
|
||||||
private final static int minNeighbors = 3;
|
private final static int minNeighbors = 3;
|
||||||
@@ -24,10 +20,6 @@ public class Detectors {
|
|||||||
private static Size FaceminSize;
|
private static Size FaceminSize;
|
||||||
private static Size FacemaxSize;
|
private static Size FacemaxSize;
|
||||||
|
|
||||||
private static final int EyetoFaceRatio = 6;
|
|
||||||
private static Size EyeminSize;
|
|
||||||
private static Size EyemaxSize;
|
|
||||||
|
|
||||||
public static void LoadAllDetectors(){
|
public static void LoadAllDetectors(){
|
||||||
|
|
||||||
LoadFrontalFaceDetector();
|
LoadFrontalFaceDetector();
|
||||||
@@ -35,47 +27,10 @@ public class Detectors {
|
|||||||
|
|
||||||
LoadProfileFaceDetector();
|
LoadProfileFaceDetector();
|
||||||
|
|
||||||
|
|
||||||
//LoadFistDetector();
|
|
||||||
//LoadRightPalmDetector();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static void LoadFistDetector(){
|
|
||||||
// String filename = SomeCodes.ExtractResource("/fist.xml");
|
|
||||||
// if (filename!=null) {
|
|
||||||
// Logger.info("Fist Detector file : " + filename);
|
|
||||||
// if (fistDetector ==null) {
|
|
||||||
// try{
|
|
||||||
//
|
|
||||||
// fistDetector = new CascadeClassifier(filename);
|
|
||||||
// Logger.info("FistDetector loaded");
|
|
||||||
// } catch (Exception e){
|
|
||||||
// Logger.error("Exception on loading FistDetector : " + e.getMessage());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } else Logger.info("FistDetector already loaded");
|
|
||||||
// } else Logger.error("Unable to extract fist detector file");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static void LoadRightPalmDetector(){
|
|
||||||
// String filename = SomeCodes.ExtractResource("/rpalm.xml");
|
|
||||||
// if (filename!=null) {
|
|
||||||
// Logger.info("Right Palm Detector file : " + filename);
|
|
||||||
// if (palmDetector ==null) {
|
|
||||||
// try{
|
|
||||||
//
|
|
||||||
// palmDetector = new CascadeClassifier(filename);
|
|
||||||
// Logger.info("RightPalmDetector loaded");
|
|
||||||
// } catch (Exception e){
|
|
||||||
// Logger.error("Exception on loading RightPalmDetector : " + e.getMessage());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } else Logger.info("RightPalmDetector already loaded");
|
|
||||||
// } else Logger.error("Unable to extract right palm detector file");
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static void LoadFrontalFaceDetector(){
|
private static void LoadFrontalFaceDetector(){
|
||||||
String filename = SomeCodes.ExtractResource("/haarcascade_frontalface_alt.xml");
|
String filename = SomeCodes.ExtractResource("/haarcascade_frontalface_default.xml");
|
||||||
if (filename!=null) {
|
if (filename!=null) {
|
||||||
Logger.info("Face Detector file : " + filename);
|
Logger.info("Face Detector file : " + filename);
|
||||||
if (frontalfaceDetector==null) {
|
if (frontalfaceDetector==null) {
|
||||||
@@ -123,22 +78,6 @@ public class Detectors {
|
|||||||
} else Logger.error("Unable to extract eye detector file");
|
} else Logger.error("Unable to extract eye detector file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public static boolean HavePalm(UMat graymat){
|
|
||||||
// RectVector palms = Detect(graymat, palmDetector);
|
|
||||||
// return palms!=null && palms.size()>0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static boolean HaveFist(UMat graymat){
|
|
||||||
// RectVector fists = Detect(graymat, fistDetector);
|
|
||||||
// return fists!=null && fists.size()>0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect if there is a frontal face, containing 2 eyes
|
* Detect if there is a frontal face, containing 2 eyes
|
||||||
* @param graymat Mat in Gray Scale
|
* @param graymat Mat in Gray Scale
|
||||||
@@ -150,12 +89,12 @@ public class Detectors {
|
|||||||
if (faces!=null && faces.size()>0){
|
if (faces!=null && faces.size()>0){
|
||||||
|
|
||||||
for(Rect face : faces.get()){
|
for(Rect face : faces.get()){
|
||||||
RectVector eyes = DetectEye(graymat);
|
RectVector eyes = DetectEye(graymat, face.width());
|
||||||
DetectorResult dr = new DetectorResult();
|
DetectorResult dr = new DetectorResult();
|
||||||
dr.setFace(face);
|
dr.setFace(face);
|
||||||
if (eyes!=null && eyes.size()>=2){
|
if (eyes!=null && eyes.size()>=2){
|
||||||
for(Rect eye : eyes.get()){
|
for(Rect eye : eyes.get()){
|
||||||
if (IsInsideRect(eye, face)) dr.AddEye(eye);
|
if (SomeCodes.IsInsideRect(eye, face)) dr.AddEye(eye);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.add(dr);
|
result.add(dr);
|
||||||
@@ -170,12 +109,12 @@ public class Detectors {
|
|||||||
if (faces!=null && faces.size()>0){
|
if (faces!=null && faces.size()>0){
|
||||||
|
|
||||||
for(Rect face : faces.get()){
|
for(Rect face : faces.get()){
|
||||||
RectVector eyes = DetectEye(graymat);
|
RectVector eyes = DetectEye(graymat, face.width());
|
||||||
DetectorResult dr = new DetectorResult();
|
DetectorResult dr = new DetectorResult();
|
||||||
dr.setFace(face);
|
dr.setFace(face);
|
||||||
if (eyes!=null && eyes.size()>0){
|
if (eyes!=null && eyes.size()>0){
|
||||||
for(Rect eye : eyes.get()){
|
for(Rect eye : eyes.get()){
|
||||||
if (IsInsideRect(eye, face)) dr.AddEye(eye);
|
if (SomeCodes.IsInsideRect(eye, face)) dr.AddEye(eye);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.add(dr);
|
result.add(dr);
|
||||||
@@ -195,34 +134,28 @@ public class Detectors {
|
|||||||
if (FaceminSize!=null){
|
if (FaceminSize!=null){
|
||||||
if (FaceminSize.width()!=value || FaceminSize.height()!=value) {
|
if (FaceminSize.width()!=value || FaceminSize.height()!=value) {
|
||||||
FaceminSize = new Size(value, value);
|
FaceminSize = new Size(value, value);
|
||||||
EyeminSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
//Logger.info("FaceMinSize changed to : " + FaceminSize.width());
|
||||||
Logger.info("FaceMinSize changed to : " + FaceminSize.width());
|
|
||||||
Logger.info("EyeMinSize changed to : " + EyeminSize.width());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FaceminSize = new Size(value, value);
|
FaceminSize = new Size(value, value);
|
||||||
EyeminSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
//Logger.info("FaceMinSize created with value : " + FaceminSize.width());
|
||||||
Logger.info("FaceMinSize created with value : " + FaceminSize.width());
|
|
||||||
Logger.info("EyeMinSize created with value : " + EyeminSize.width());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Face Min Size : " + FaceminSize.width());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFaceMaxSize(int value){
|
public static void setFaceMaxSize(int value){
|
||||||
if (FacemaxSize!=null){
|
if (FacemaxSize!=null){
|
||||||
if (FacemaxSize.width()!=value || FacemaxSize.height()!=value) {
|
if (FacemaxSize.width()!=value || FacemaxSize.height()!=value) {
|
||||||
FacemaxSize = new Size(value, value);
|
FacemaxSize = new Size(value, value);
|
||||||
EyemaxSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
//Logger.info("FaceMaxSize changed to : " + FacemaxSize.width());
|
||||||
Logger.info("FaceMaxSize changed to : " + FacemaxSize.width());
|
|
||||||
Logger.info("EyeMaxSize changed to : " + EyemaxSize.width());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FacemaxSize = new Size(value, value);
|
FacemaxSize = new Size(value, value);
|
||||||
EyemaxSize = new Size(value/EyetoFaceRatio, value/EyetoFaceRatio);
|
//Logger.info("FaceMaxSize created with value : " + FacemaxSize.width());
|
||||||
Logger.info("FaceMaxSize created with value : " + FacemaxSize.width());
|
|
||||||
Logger.info("EyeMaxSize created with value : " + EyemaxSize.width());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Face Max Size : " + FacemaxSize.width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -230,23 +163,6 @@ public class Detectors {
|
|||||||
return Detect(graymat, profilefaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
return Detect(graymat, profilefaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RectVector DetectFrontalFace(Mat graymat, int minsize, int maxsize){
|
|
||||||
Size min = new Size(minsize, minsize);
|
|
||||||
Size max = new Size(maxsize, maxsize);
|
|
||||||
RectVector rect = new RectVector();
|
|
||||||
frontalfaceDetector.detectMultiScale(graymat, rect,scaleFactor, minNeighbors, flags, min, max);
|
|
||||||
return rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RectVector DetectProfileFace(Mat graymat, int minsize, int maxsize){
|
|
||||||
Size min = new Size(minsize, minsize);
|
|
||||||
Size max = new Size(maxsize, maxsize);
|
|
||||||
RectVector rect = new RectVector();
|
|
||||||
profilefaceDetector.detectMultiScale(graymat, rect,scaleFactor, minNeighbors, flags, min, max);
|
|
||||||
return rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect Face from Mat
|
* Detect Face from Mat
|
||||||
* @param graymat Mat in Gray Scale
|
* @param graymat Mat in Gray Scale
|
||||||
@@ -256,18 +172,19 @@ public class Detectors {
|
|||||||
return Detect(graymat, frontalfaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
return Detect(graymat, frontalfaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect Eye from Mat
|
* Detect Eye from Mat
|
||||||
* If Eye detected, it will return RectVector with size is number of eyes detected
|
* If Eye detected, it will return RectVector with size is number of eyes detected
|
||||||
* @param graymat Mat in Gray Scale
|
* @param graymat Mat in Gray Scale
|
||||||
* @return RectVector if eye detected, otherwise null
|
* @return RectVector if eye detected, otherwise null
|
||||||
*/
|
*/
|
||||||
public static RectVector DetectEye(UMat graymat){
|
public static RectVector DetectEye(UMat graymat, int facewidth){
|
||||||
//return Detect(graymat, eyeDetector, scaleFactor, minNeighbors, flags, EyeminSize, EyemaxSize);
|
//return Detect(graymat, eyeDetector);
|
||||||
return Detect(graymat, eyeDetector);
|
int minwidth = (int)(facewidth*0.2);
|
||||||
|
int maxwidth = (int)(facewidth*0.4);
|
||||||
|
Size minsize = new Size(minwidth, minwidth);
|
||||||
|
Size maxsize = new Size(maxwidth, maxwidth);
|
||||||
|
return Detect(graymat, eyeDetector, scaleFactor, minNeighbors, flags, minsize, maxsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ import static Config.SomeCodes.config;
|
|||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SecureDongle sd = new SecureDongle((short)0x4B30, (short)0xA66C, (short)0x3109, (short)0x37B1);
|
SecureDongle sd = new SecureDongle((short)0x4B30, (short)0xA66C, (short)0x3109, (short)0x37B1);
|
||||||
if (sd.Find()){
|
if (sd.Find()){
|
||||||
if (sd.Open()){
|
if (sd.Open()){
|
||||||
@@ -34,7 +37,7 @@ public class MainApplication extends Application {
|
|||||||
Screen screen = Screen.getPrimary();
|
Screen screen = Screen.getPrimary();
|
||||||
Rectangle2D screenbound = screen.getBounds();
|
Rectangle2D screenbound = screen.getBounds();
|
||||||
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
|
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
|
||||||
stage.setTitle("MultiCam Capture App for ERHA 09042025-002");
|
stage.setTitle("MultiCam Capture App for ERHA 11042025-004");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setResizable(true);
|
stage.setResizable(true);
|
||||||
stage.setMaximized(true);
|
stage.setMaximized(true);
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ import org.tinylog.Logger;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import static Config.SomeCodes.ShowAlert;
|
import static Config.SomeCodes.*;
|
||||||
import static Config.SomeCodes.config;
|
|
||||||
|
|
||||||
public class PhotoRow {
|
public class PhotoRow {
|
||||||
@FXML
|
@FXML
|
||||||
@@ -29,13 +28,11 @@ public class PhotoRow {
|
|||||||
private final String borderstyle = "-fx-border-color: black; -fx-border-width: 1px;";
|
private final String borderstyle = "-fx-border-color: black; -fx-border-width: 1px;";
|
||||||
|
|
||||||
public void setDatetime(String datetime){
|
public void setDatetime(String datetime){
|
||||||
this.datetime.setText(datetime);
|
LabelSetText(this.datetime, datetime, borderstyle);
|
||||||
this.datetime.setStyle(borderstyle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrefix(String prefix){
|
public void setPrefix(String prefix){
|
||||||
this.prefix.setText(prefix);
|
LabelSetText(this.prefix,prefix,borderstyle);
|
||||||
this.prefix.setStyle(borderstyle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhotos(int width, int height, String... thumbnails){
|
public void setPhotos(int width, int height, String... thumbnails){
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package id.co.gtc.erhacam;
|
|||||||
|
|
||||||
import FTP.FTPCheck;
|
import FTP.FTPCheck;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
@@ -11,13 +9,9 @@ import javafx.scene.control.ComboBox;
|
|||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.stage.DirectoryChooser;
|
import javafx.stage.DirectoryChooser;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import lombok.val;
|
|
||||||
import org.bytedeco.javacv.VideoInputFrameGrabber;
|
import org.bytedeco.javacv.VideoInputFrameGrabber;
|
||||||
import org.tinylog.Logger;
|
import org.tinylog.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static Config.SomeCodes.*;
|
import static Config.SomeCodes.*;
|
||||||
|
|
||||||
public class SettingView {
|
public class SettingView {
|
||||||
@@ -78,7 +72,7 @@ public class SettingView {
|
|||||||
|
|
||||||
config.SetPhotoDirectory(path);
|
config.SetPhotoDirectory(path);
|
||||||
config.Save();
|
config.Save();
|
||||||
PhotoDirectoryPath.setText(path);
|
TextFieldSetText(PhotoDirectoryPath,path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@@ -191,23 +185,23 @@ public class SettingView {
|
|||||||
CameraRight45.setValue(config.getCameraRight45());
|
CameraRight45.setValue(config.getCameraRight45());
|
||||||
CameraRight90.setValue(config.getCameraRight90());
|
CameraRight90.setValue(config.getCameraRight90());
|
||||||
|
|
||||||
FTPHost.setText(config.getFTPHost());
|
TextFieldSetText(FTPHost,config.getFTPHost());
|
||||||
FTPPort.setText(config.getFTPPort());
|
TextFieldSetText(FTPPort,config.getFTPPort());
|
||||||
FTPUser.setText(config.getFTPUser());
|
TextFieldSetText(FTPUser,config.getFTPUser());
|
||||||
FTPPass.setText(config.getFTPPass());
|
TextFieldSetText(FTPPass,config.getFTPPass());
|
||||||
FTPPath.setText(config.getFTPPath());
|
TextFieldSetText(FTPPath,config.getFTPPath());
|
||||||
|
|
||||||
PhotoDirectoryPath.setText(config.getPhotoDirectory());
|
TextFieldSetText(PhotoDirectoryPath,config.getPhotoDirectory());
|
||||||
|
|
||||||
|
TextFieldSetText(cascadeScaleFactor,String.valueOf(config.getCascadeScaleFactor()));
|
||||||
|
TextFieldSetText(cascadeMinSize,String.valueOf(config.getCascadeMinSize()));
|
||||||
|
TextFieldSetText(cascadeMaxSize,String.valueOf(config.getCascadeMaxSize()));
|
||||||
|
|
||||||
cascadeScaleFactor.setText(String.valueOf(config.getCascadeScaleFactor()));
|
|
||||||
cascadeMinSize.setText(String.valueOf(config.getCascadeMinSize()));
|
|
||||||
cascadeMaxSize.setText(String.valueOf(config.getCascadeMaxSize()));
|
|
||||||
|
|
||||||
MirrorCamera.setSelected(config.isMirrorCamera());
|
MirrorCamera.setSelected(config.isMirrorCamera());
|
||||||
FlipCamera.setSelected(config.isFlipCamera());
|
FlipCamera.setSelected(config.isFlipCamera());
|
||||||
|
|
||||||
Sharpness.setText(String.valueOf(config.getSharpnessThreshold()));
|
TextFieldSetText(Sharpness,String.valueOf(config.getSharpnessThreshold()));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ProgressBar;
|
import javafx.scene.control.ProgressBar;
|
||||||
|
|
||||||
|
import static Config.SomeCodes.LabelSetText;
|
||||||
import static Config.SomeCodes.ValidString;
|
import static Config.SomeCodes.ValidString;
|
||||||
|
|
||||||
public class UploadProgress {
|
public class UploadProgress {
|
||||||
@@ -31,9 +32,7 @@ public class UploadProgress {
|
|||||||
* @param filename the filename to be displayed
|
* @param filename the filename to be displayed
|
||||||
*/
|
*/
|
||||||
public void SetFile(String filename){
|
public void SetFile(String filename){
|
||||||
if (ValidString(filename)){
|
LabelSetText(this.labelfile, filename,null);
|
||||||
labelfile.setText(filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,9 +40,7 @@ public class UploadProgress {
|
|||||||
* @param status the status to be displayed
|
* @param status the status to be displayed
|
||||||
*/
|
*/
|
||||||
public void SetStatus(String status){
|
public void SetStatus(String status){
|
||||||
if (ValidString(status)){
|
LabelSetText(this.labelstatus, status,null);
|
||||||
labelstatus.setText(status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -197,11 +197,7 @@ public class Cameradetail_Arducam {
|
|||||||
* @param title Title of the Camera
|
* @param title Title of the Camera
|
||||||
*/
|
*/
|
||||||
public void setCameraTitle(String title){
|
public void setCameraTitle(String title){
|
||||||
if (ValidString(title)){
|
LabelSetText(this.cameratitle, title, null);
|
||||||
if (cameratitle!=null){
|
|
||||||
cameratitle.setText(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSaturation(double value){
|
public void setSaturation(double value){
|
||||||
@@ -259,11 +255,7 @@ public class Cameradetail_Arducam {
|
|||||||
* @param status Status of the Camera
|
* @param status Status of the Camera
|
||||||
*/
|
*/
|
||||||
public void setCameraStatus(String status){
|
public void setCameraStatus(String status){
|
||||||
if (ValidString(status)){
|
LabelSetText(this.camerastatus, status,null);
|
||||||
if (camerastatus!=null){
|
|
||||||
camerastatus.setText(status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -519,13 +511,12 @@ public class Cameradetail_Arducam {
|
|||||||
* @param prefix filename prefix
|
* @param prefix filename prefix
|
||||||
* @return filename path of the saved photo, or null if failed
|
* @return filename path of the saved photo, or null if failed
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("BusyWait")
|
|
||||||
public String TakePhoto(String directory, String prefix){
|
public String TakePhoto(String directory, String prefix){
|
||||||
if (!ValidDirectory(directory)) directory = currentDirectory;
|
if (!ValidDirectory(directory)) directory = currentDirectory;
|
||||||
if (mGrabber!=null){
|
if (mGrabber!=null){
|
||||||
try{
|
try{
|
||||||
long nanos = System.nanoTime();
|
long nanos = System.nanoTime();
|
||||||
while(IsGrabbingLiveView.get()) Thread.sleep(10);
|
while(IsGrabbingLiveView.get()) Wait(10);
|
||||||
long delta = System.nanoTime() - nanos;
|
long delta = System.nanoTime() - nanos;
|
||||||
double ms = delta / 1000000.0;
|
double ms = delta / 1000000.0;
|
||||||
if (event!=null) event.onLog("Waited IsGrabbingLiveView for "+ms+" miliseconds");
|
if (event!=null) event.onLog("Waited IsGrabbingLiveView for "+ms+" miliseconds");
|
||||||
@@ -542,10 +533,10 @@ public class Cameradetail_Arducam {
|
|||||||
|
|
||||||
|
|
||||||
setAutoWB(true);
|
setAutoWB(true);
|
||||||
Thread.sleep(1000);
|
Wait(1000);
|
||||||
|
|
||||||
setAutoExposure(true);
|
setAutoExposure(true);
|
||||||
Thread.sleep(1000);
|
Wait(1000);
|
||||||
|
|
||||||
long delta3 = System.nanoTime() - nanos;
|
long delta3 = System.nanoTime() - nanos;
|
||||||
double ms3 = delta3 / 1000000.0;
|
double ms3 = delta3 / 1000000.0;
|
||||||
@@ -673,14 +664,13 @@ public class Cameradetail_Arducam {
|
|||||||
AutoWhiteBalance.setSelected(true);
|
AutoWhiteBalance.setSelected(true);
|
||||||
|
|
||||||
val task = new Task<Image>() {
|
val task = new Task<Image>() {
|
||||||
@SuppressWarnings("BusyWait")
|
|
||||||
@Override
|
@Override
|
||||||
protected Image call() {
|
protected Image call() {
|
||||||
while (Capturing.get()) {
|
while (Capturing.get()) {
|
||||||
try {
|
try {
|
||||||
// selama proses pengambilan foto, jangan ambil frame
|
// selama proses pengambilan foto, jangan ambil frame
|
||||||
while(TakingPhoto.get() && Capturing.get()){
|
while(TakingPhoto.get() && Capturing.get()){
|
||||||
Thread.sleep(10);
|
Wait(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Capturing.get()) return null;
|
if (!Capturing.get()) return null;
|
||||||
@@ -737,7 +727,10 @@ public class Cameradetail_Arducam {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// start task
|
// start task
|
||||||
new Thread(task).start();
|
Thread taskThread = new Thread(task);
|
||||||
|
taskThread.setDaemon(true);
|
||||||
|
taskThread.start();
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user