Commit 21032025

This commit is contained in:
2025-03-27 08:32:38 +07:00
parent 2da4c3621e
commit 71ecbe0c3e
5 changed files with 37 additions and 31 deletions

View File

@@ -244,6 +244,30 @@ public class Cameradetail {
}
}
public void setSharpness_indicator(double value){
if (value >= config.getSharpnessThreshold()){
if (Platform.isFxApplicationThread()){
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 {
if (Platform.isFxApplicationThread()) {
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");
});
}
}
}
public void setSaturation(double value){
if (mGrabber!=null){
mGrabber.setOption(Videoio.CAP_PROP_SATURATION, value);
@@ -909,16 +933,17 @@ public class Cameradetail {
}
// rotate 90 degree counter clockwise karena kamera potrait
opencv_core.rotate(originalmat, originalmat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
opencv_core.rotate(originalmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
IsGrabbingLiveView.set(false);
if (!originalmat.empty()) {
opencv_imgproc.resize(originalmat, LiveMat, LiveSize); // resize to LiveSize
if (!BestMat.empty()) {
opencv_imgproc.resize(BestMat, LiveMat, LiveSize); // resize to LiveSize
UMat graymat = new UMat(); // use OpenCL for grayscale
opencv_imgproc.cvtColor(LiveMat,graymat, COLOR_BGR2GRAY); // convert to grayscale
if (use_qr){
String qr = DetectQRFromMat(graymat);
if (ValidBarCode(qr)){
@@ -976,13 +1001,6 @@ public class Cameradetail {
if (event!=null) event.onFrontalFaceDetector(true, _face_width, _face_height);
face_indicator.setVisible(true);
double sharpness = CalculateSharpness(originalmat);
if (sharpness>=config.getSharpnessThreshold()){
sharpness_value = sharpness;
originalmat.copyTo(BestMat);
Platform.runLater(()->sharpness_indicator.setText(String.format("%.2f", sharpness_value)));
}
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));
@@ -1043,17 +1061,10 @@ public class Cameradetail {
if (event!=null) event.onProfileFaceDetector(true, _face_width, _face_height);
face_indicator.setVisible(true);
double sharpness = CalculateSharpness(originalmat);
if (sharpness>=config.getSharpnessThreshold()){
sharpness_value = sharpness;
originalmat.copyTo(BestMat);
Platform.runLater(()->sharpness_indicator.setText(String.format("%.2f", sharpness_value)));
}
} else {
// no face detected, but let's not cancel the previous state immediately
if (no_face_counter>30){
if (no_face_counter>90){
// kalau tidak ada face selama 30 frame, reset state
// 30 frame approximately 2 second
eye_state = -1;

View File

@@ -160,8 +160,7 @@ public class CaptureView {
image1.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image1.getLiveMat());
System.out.println("Image1 sharpness: "+sharpness);
image1.setSharpness_indicator(sharpness);
PhotoResult p1 = image1.TakePhoto(directory,prefix);
p1.setSharpscore(sharpness);
if (ValidFile(p1.getFullres())){
@@ -176,8 +175,7 @@ public class CaptureView {
if (image2!=null) {
image2.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image2.getLiveMat());
System.out.println("Image2 sharpness: "+sharpness);
image2.setSharpness_indicator(sharpness);
PhotoResult p2 = image2.TakePhoto(directory,prefix);
p2.setSharpscore(sharpness);
if (ValidFile(p2.getFullres())){
@@ -193,8 +191,7 @@ public class CaptureView {
if (image3!=null) {
image3.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image3.getLiveMat());
System.out.println("Image3 sharpness: "+sharpness);
image3.setSharpness_indicator(sharpness);
PhotoResult p3 = image3.TakePhoto(directory,prefix);
p3.setSharpscore(sharpness);
@@ -212,8 +209,7 @@ public class CaptureView {
if (image4!=null) {
image4.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image4.getLiveMat());
System.out.println("Image4 sharpness: "+sharpness);
image4.setSharpness_indicator(sharpness);
PhotoResult p4 = image4.TakePhoto(directory,prefix);
p4.setSharpscore(sharpness);
@@ -231,8 +227,7 @@ public class CaptureView {
if (image5!=null) {
image5.RemapROI(0.1,0.3, false);
double sharpness = CalculateSharpness(image5.getLiveMat());
System.out.println("Image5 sharpness: "+sharpness);
image5.setSharpness_indicator(sharpness);
PhotoResult p5 = image5.TakePhoto(directory,prefix);
p5.setSharpscore(sharpness);
@@ -294,7 +289,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()){
if (lowest<=config.getSharpnessThreshold()){
String culprit = "";
if (lowest==score1) culprit = "camera 1";
else if (lowest==score2) culprit = "camera 2";

View File

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