Commit 25042025

This commit is contained in:
2025-05-05 15:46:15 +07:00
parent 257eb50640
commit 2cf206b306
7 changed files with 143 additions and 29 deletions

View File

@@ -27,6 +27,7 @@ import javafx.stage.DirectoryChooser;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javafx.scene.control.Alert.AlertType;
import org.bytedeco.javacv.OpenCVFrameGrabber;
@@ -151,6 +152,7 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_tahan_posisi)){
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_tahan_posisi, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
@@ -160,7 +162,7 @@ public class CaptureView {
@Override
public void onPlaybackFinished(String filename) {
Wait(500);
audioPlayer.PlayFile(audio_countdown, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
@@ -196,6 +198,7 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_posisikan_muka)) {
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_posisikan_muka, null);
}
}
@@ -214,7 +217,9 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_scan_barcode, null);
}
}
}
@@ -256,6 +261,8 @@ public class CaptureView {
}
}
AtomicInteger takephoto_failure_counter = new AtomicInteger(0);
private void take_photo_lanjutan(String directory, String prefix){
audioPlayer.PlayFile(audio_camera_shutter, null);
Size thumbsize = new Size(160,120);
@@ -322,6 +329,7 @@ public class CaptureView {
System.out.println("Sharpness score: "+score1+", "+score2+", "+score3+", "+score4+", "+score5);
double lowest = FindLowestValue(score1,score2,score3,score4,score5);
if (lowest<=config.getSharpnessThreshold()){
// jelek
String culprit = "";
if (lowest==score1) culprit = "camera 1";
else if (lowest==score2) culprit = "camera 2";
@@ -329,9 +337,29 @@ public class CaptureView {
else if (lowest==score4) culprit = "camera 4";
else if (lowest==score5) culprit = "camera 5";
String lowest_string = String.format("%.2f", lowest);
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at "+culprit+" with sharpness score "+lowest_string, 5, null);
isTakingPhoto.set(false);
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at "+culprit+" with sharpness score "+lowest_string, 5, s -> isTakingPhoto.set(false));
takephoto_failure_counter.incrementAndGet();
if (audioPlayer!=null && audioPlayer.isInited()){
if (takephoto_failure_counter.get() < 2){
if (!Objects.equals(audio_pengambilan_gagal, audioPlayer.getCurrentFile())){
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_pengambilan_gagal, null);
}
} else {
if (!Objects.equals(audio_hubungi_staf_kami, audioPlayer.getCurrentFile())){
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_hubungi_staf_kami, null);
}
}
}
return;
} else {
// bagus
takephoto_failure_counter.set(0);
}
@@ -490,6 +518,7 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_pengambilan_berhasil)){
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_pengambilan_berhasil, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
@@ -498,7 +527,7 @@ public class CaptureView {
@Override
public void onPlaybackFinished(String filename) {
AutoCloseAlert.showpictures(prc.compressed(),2, (s)->{
AutoCloseAlert.showpictures(prc.compressed(),3, (s)->{
if (AutoCloseAlert.banner_02!=null) {
System.out.println("Showing banner 02 after photo taken");
AutoCloseAlert.showbanner(AutoCloseAlert.banner_02, 0, null);
@@ -523,6 +552,7 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_pengambilan_gagal)){
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_pengambilan_gagal, null);
}
}
@@ -576,6 +606,7 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_upload_gagal)){
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_upload_gagal, null);
}
}
@@ -764,6 +795,7 @@ public class CaptureView {
config.Save();
}
AtomicBoolean anti_bawel = new AtomicBoolean(false);
private void SetupCameraWithController(Cameradetail image, String cameraname, int devicenumber){
if (image!=null){
@@ -904,8 +936,37 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_posisikan_muka)) {
audioPlayer.StopCurrentPlayback();
audioPlayer.PlayFile(audio_posisikan_muka, null);
if (!anti_bawel.get()){
audioPlayer.StopCurrentPlayback();
Wait(500);
audioPlayer.PlayFile(audio_posisikan_muka, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
anti_bawel.set(true);
}
@Override
public void onPlaybackFinished(String filename) {
anti_bawel.set(false);
Thread antibawel = new Thread(()->{
try {
Thread.sleep(15*1000);
} catch (InterruptedException ignored) {
}
anti_bawel.set(false);
});
antibawel.setName("anti bawel");
antibawel.setDaemon(true);
antibawel.start();
}
@Override
public void onPlaybackFailure(String filename) {
anti_bawel.set(false);
}
});
}
}
}
@@ -937,6 +998,8 @@ public class CaptureView {
}
}
@Override
public void onFrontalFaceDetector(boolean hasface, int width, int height) {
if (hasface!= _have_face.get()){
@@ -951,7 +1014,34 @@ public class CaptureView {
if (audioPlayer!=null && audioPlayer.isInited()){
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
audioPlayer.StopCurrentPlayback();
audioPlayer.PlayFile(audio_scan_barcode, null);
if (anti_bawel.get()) return;
audioPlayer.PlayFile(audio_scan_barcode, new PlaybackStatus() {
@Override
public void onPlaybackStarted(String filename) {
anti_bawel.set(true);
}
@Override
public void onPlaybackFinished(String filename) {
Thread antibawel = new Thread(()->{
try {
Thread.sleep(15*1000);
} catch (InterruptedException ignored) {
}
anti_bawel.set(false);
});
antibawel.setName("anti bawel");
antibawel.setDaemon(true);
antibawel.start();
}
@Override
public void onPlaybackFailure(String filename) {
anti_bawel.set(false);
}
});
}
}
}