revisi 16/12/2024
This commit is contained in:
@@ -10,14 +10,19 @@ import Database.Sqlite;
|
||||
import FTP.FTPUpload;
|
||||
import FTP.FTPUploadEvent;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import lombok.val;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -26,7 +31,6 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import org.bytedeco.javacv.OpenCVFrameConverter;
|
||||
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
||||
import org.bytedeco.javacv.VideoInputFrameGrabber;
|
||||
import org.bytedeco.opencv.opencv_core.Size;
|
||||
@@ -36,6 +40,9 @@ import static Config.SomeCodes.*;
|
||||
|
||||
public class CaptureView {
|
||||
|
||||
@FXML
|
||||
private AnchorPane CaptureViewAnchor;
|
||||
|
||||
@FXML
|
||||
private AnchorPane cam1, cam2, cam3, cam4, cam5, controlpane;
|
||||
|
||||
@@ -44,6 +51,8 @@ public class CaptureView {
|
||||
|
||||
@FXML
|
||||
private TextArea directorypath, prefixfile;
|
||||
@FXML
|
||||
private Button btnTakePhoto;
|
||||
|
||||
@FXML
|
||||
private AnchorPane progressanchor;
|
||||
@@ -56,6 +65,7 @@ public class CaptureView {
|
||||
|
||||
private List<String> cams;
|
||||
|
||||
|
||||
@FXML
|
||||
private void ChangeDirectory(){
|
||||
DirectoryChooser dc = new DirectoryChooser();
|
||||
@@ -224,6 +234,11 @@ public class CaptureView {
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBtnTakePhoto(){
|
||||
boolean valid = ValidDirectory(directorypath.getText()) && ValidString(prefixfile.getText());
|
||||
btnTakePhoto.setDisable(!valid);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize(){
|
||||
audio_posisikan_muka = ExtractResource("/satu.wav");
|
||||
@@ -234,6 +249,11 @@ public class CaptureView {
|
||||
audioPlayer = new AudioPlayer(1,48000);
|
||||
Logger.info("Audio Player : "+(audioPlayer.isInited()? "Inited" : "Not Inited"));
|
||||
|
||||
btnTakePhoto.setDisable(true);
|
||||
|
||||
directorypath.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
prefixfile.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
|
||||
cams = null;
|
||||
try{
|
||||
String[] xxx = VideoInputFrameGrabber.getDeviceDescriptions();
|
||||
@@ -244,6 +264,8 @@ public class CaptureView {
|
||||
Logger.error("Error getting camera list: "+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
LoadCameraDetail(cam1, 1, CameraConfigEnum.CameraConfigLeft90);
|
||||
LoadCameraDetail(cam2, 2, CameraConfigEnum.CameraConfigLeft45);
|
||||
LoadCameraDetail(cam3, 3, CameraConfigEnum.CameraConfigCenter);
|
||||
@@ -261,8 +283,9 @@ public class CaptureView {
|
||||
if (ValidString(camleft90)){
|
||||
int[] indexes = FindIndexes(cams, camleft90);
|
||||
if (indexes.length>0){
|
||||
indexleft90 = indexes[0];
|
||||
if (indexleft90!=1){
|
||||
indexleft90 = FindFirstIndex(cams, camleft90);
|
||||
Logger.info("Left90 Index: "+indexleft90);
|
||||
if (indexleft90!=-1){
|
||||
final int finalindex = indexleft90;
|
||||
new Thread(()-> SetupCameraWithController(image1, camleft90, finalindex)).start();
|
||||
}
|
||||
@@ -273,6 +296,7 @@ public class CaptureView {
|
||||
int[] indexes = FindIndexes(cams, camleft45);
|
||||
if (indexes.length>0){
|
||||
indexleft45 = FindFirstIndex(cams, camleft45, indexleft90);
|
||||
Logger.info("Left45 Index: "+indexleft45);
|
||||
if (indexleft45!=-1) {
|
||||
final int finalindex = indexleft45;
|
||||
new Thread(()-> SetupCameraWithController(image2, camleft45, finalindex)).start();
|
||||
@@ -284,6 +308,7 @@ public class CaptureView {
|
||||
int[] indexes = FindIndexes(cams, camcenter);
|
||||
if (indexes.length>0){
|
||||
indexcenter = FindFirstIndex(cams, camcenter, indexleft90, indexleft45);
|
||||
Logger.info("Center Index: "+indexcenter);
|
||||
if (indexcenter!=-1) {
|
||||
final int finalindex = indexcenter;
|
||||
new Thread(()-> SetupCameraWithController(image3, camcenter, finalindex)).start();
|
||||
@@ -295,6 +320,7 @@ public class CaptureView {
|
||||
int[] indexes = FindIndexes(cams, camright45);
|
||||
if (indexes.length>0){
|
||||
indexright45 = FindFirstIndex(cams, camright45, indexleft90, indexleft45, indexcenter);
|
||||
Logger.info("Right45 Index: "+indexright45);
|
||||
if (indexright45!=-1) {
|
||||
final int finalindex = indexright45;
|
||||
new Thread(()-> SetupCameraWithController(image4, camright45, finalindex)).start();
|
||||
@@ -307,6 +333,7 @@ public class CaptureView {
|
||||
int[] indexes = FindIndexes(cams, camright90);
|
||||
if (indexes.length>0){
|
||||
indexright90 = FindFirstIndex(cams, camright90, indexleft90, indexleft45, indexcenter, indexright45);
|
||||
Logger.info("Right90 Index: "+indexright90);
|
||||
if (indexright90!=-1) {
|
||||
final int finalindex = indexright90;
|
||||
new Thread(()-> SetupCameraWithController(image5, camright90, finalindex)).start();
|
||||
@@ -386,11 +413,11 @@ public class CaptureView {
|
||||
private void SetupCameraWithController(Cameradetail image, String cameraname, int devicenumber){
|
||||
if (image!=null){
|
||||
String title = switch(image.getCameraConfigEnum()){
|
||||
case CameraConfigCenter -> "Camera Center";
|
||||
case CameraConfigLeft45 -> "Camera Left 45";
|
||||
case CameraConfigLeft90 -> "Camera Left 90";
|
||||
case CameraConfigRight45 -> "Camera Right 45";
|
||||
case CameraConfigRight90 -> "Camera Right 90";
|
||||
case CameraConfigCenter -> "03";
|
||||
case CameraConfigLeft45 -> "02";
|
||||
case CameraConfigLeft90 -> "01";
|
||||
case CameraConfigRight45 -> "04";
|
||||
case CameraConfigRight90 -> "05";
|
||||
};
|
||||
Platform.runLater(()-> image.setCameraTitle(title));
|
||||
if (devicenumber!=-1){
|
||||
@@ -468,17 +495,38 @@ public class CaptureView {
|
||||
|
||||
private void LoadCameraDetail(AnchorPane cam, int camid, CameraConfigEnum cc){
|
||||
try{
|
||||
|
||||
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("cameradetail.fxml"));
|
||||
AnchorPane child = loader.load();
|
||||
|
||||
AnchorPane.setTopAnchor(child, 0.0);
|
||||
AnchorPane.setBottomAnchor(child, 0.0);
|
||||
AnchorPane.setLeftAnchor(child, 0.0);
|
||||
AnchorPane.setRightAnchor(child, 0.0);
|
||||
|
||||
|
||||
cam.getChildren().clear();
|
||||
cam.getChildren().add(child);
|
||||
|
||||
cam.widthProperty().addListener(observable ->{
|
||||
//System.out.println("Width property, cam "+camid+" width="+cam.getWidth()+" height="+cam.getHeight());
|
||||
if (cam.getWidth()!=0) {
|
||||
if (cam.getHeight()!=0){
|
||||
AnchorPane.setTopAnchor(child, 0.0);
|
||||
AnchorPane.setBottomAnchor(child, 0.0);
|
||||
AnchorPane.setLeftAnchor(child, 0.0);
|
||||
AnchorPane.setRightAnchor(child, 0.0);
|
||||
}
|
||||
}
|
||||
});
|
||||
cam.heightProperty().addListener(observable -> {
|
||||
//System.out.println("Height property, cam "+camid+" width="+cam.getWidth()+" height="+cam.getHeight());
|
||||
if (cam.getWidth()!=0) {
|
||||
if (cam.getHeight()!=0){
|
||||
AnchorPane.setTopAnchor(child, 0.0);
|
||||
AnchorPane.setBottomAnchor(child, 0.0);
|
||||
AnchorPane.setLeftAnchor(child, 0.0);
|
||||
AnchorPane.setRightAnchor(child, 0.0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
switch(camid){
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user