revisi 16/12/2024
This commit is contained in:
@@ -11,9 +11,10 @@ import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
|
||||
import com.google.zxing.common.HybridBinarizer;
|
||||
import javafx.application.Platform;
|
||||
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
@@ -23,7 +24,6 @@ import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.val;
|
||||
import org.bytedeco.javacv.Frame;
|
||||
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
||||
import org.bytedeco.opencv.global.opencv_imgproc;
|
||||
@@ -86,12 +86,7 @@ public class Cameradetail {
|
||||
private Slider gainSlider;
|
||||
@FXML
|
||||
private Slider exposureSlider;
|
||||
@FXML
|
||||
private CheckBox AutoExposure;
|
||||
@FXML
|
||||
private CheckBox AutoWhiteBalance;
|
||||
@FXML
|
||||
private CheckBox AutoFocus;
|
||||
|
||||
|
||||
private final UMat BestMat = new UMat();
|
||||
private final UMat LiveMat = new UMat();
|
||||
@@ -99,17 +94,31 @@ public class Cameradetail {
|
||||
private Size PhotoSize = new Size(1920, 1080);
|
||||
|
||||
private void setSliderValue(Slider sld, CameraProperty prop, double value){
|
||||
sld.setMin(prop.Min);
|
||||
sld.setMax(prop.Max);
|
||||
sld.setValue(value);
|
||||
if (sld!=null){
|
||||
sld.setMin(prop.Min);
|
||||
sld.setMax(prop.Max);
|
||||
sld.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void resize_streamanchor(){
|
||||
if (streamanchor!=null){
|
||||
if (streamanchor.getHeight()!=0){
|
||||
if (streamanchor.getWidth()!=0){
|
||||
camerastream.setFitHeight(streamanchor.getHeight()-10);
|
||||
//camerastream.setFitWidth(streamanchor.getWidth());
|
||||
camerastream.setPreserveRatio(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize(){
|
||||
|
||||
camerastream.fitHeightProperty().bind(streamanchor.heightProperty());
|
||||
//camerastream.fitWidthProperty().bind(streamanchor.widthProperty());
|
||||
camerastream.setPreserveRatio(true);
|
||||
streamanchor.heightProperty().addListener(obs -> resize_streamanchor());
|
||||
streamanchor.widthProperty().addListener(obs -> resize_streamanchor());
|
||||
|
||||
Platform.runLater(()->{
|
||||
setSliderValue(brightnessSlider, ArducamIMX477Preset.Brightness, config.getBrightness(cameraConfigEnum));
|
||||
@@ -118,27 +127,10 @@ public class Cameradetail {
|
||||
setSliderValue(hueSlider, ArducamIMX477Preset.Hue, config.getHue(cameraConfigEnum));
|
||||
setSliderValue(gainSlider, ArducamIMX477Preset.Gain, config.getGain(cameraConfigEnum));
|
||||
setSliderValue(exposureSlider, ArducamIMX477Preset.ExposureTime, config.getExposure(cameraConfigEnum));
|
||||
AutoExposure.setSelected(config.getAutoExposure(cameraConfigEnum));
|
||||
AutoWhiteBalance.setSelected(config.getAutoWhiteBalance(cameraConfigEnum));
|
||||
AutoFocus.setSelected(config.getAutoFocus(cameraConfigEnum));
|
||||
|
||||
});
|
||||
|
||||
AutoExposure.selectedProperty().addListener((obs, oldVal, newVal) -> {
|
||||
setAutoExposure(newVal);
|
||||
config.setAutoExposure(cameraConfigEnum, newVal);
|
||||
raise_log("AutoExposure for "+getCameraTitle()+" changed to " + newVal);
|
||||
});
|
||||
|
||||
AutoWhiteBalance.selectedProperty().addListener((obs, oldVal, newVal) -> {
|
||||
setAutoWB(newVal);
|
||||
config.setAutoWhiteBalance(cameraConfigEnum, newVal);
|
||||
raise_log("AutoWhiteBalance for "+getCameraTitle()+" changed to "+newVal);
|
||||
});
|
||||
AutoFocus.selectedProperty().addListener((obs, oldVal, newVal) -> {
|
||||
setAutoFocus(newVal);
|
||||
config.setAutoFocus(cameraConfigEnum, newVal);
|
||||
raise_log("AutoFocus for "+getCameraTitle()+" changed to "+newVal);
|
||||
});
|
||||
|
||||
brightnessSlider.valueProperty().addListener((obs, oldVal, newVal) -> {
|
||||
setBrightness(newVal.doubleValue());
|
||||
@@ -181,9 +173,7 @@ public class Cameradetail {
|
||||
hueSlider.adjustValue(ArducamIMX477Preset.Hue.Default);
|
||||
gainSlider.adjustValue(ArducamIMX477Preset.Gain.Default);
|
||||
exposureSlider.adjustValue(ArducamIMX477Preset.ExposureTime.Default);
|
||||
AutoExposure.setSelected(true);
|
||||
AutoFocus.setSelected(true);
|
||||
AutoWhiteBalance.setSelected(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -541,22 +531,13 @@ public class Cameradetail {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO Revisi nama file
|
||||
private String makeFileName(String prefix){
|
||||
//make filename with prefix_POSITION_YYYY-MM-DD_HH-MM-SS
|
||||
|
||||
LocalDateTime ldt = LocalDateTime.now();
|
||||
String timetag = ldt.getYear() + "-" + ldt.getMonthValue() + "-" + ldt.getDayOfMonth() + "_" + ldt.getHour() + "-" + ldt.getMinute() + "-" + ldt.getSecond();
|
||||
return prefix+"_"
|
||||
+ switch(cameratitle.getText()){
|
||||
case "Camera Left 90" -> "LEFT90";
|
||||
case "Camera Left 45" -> "LEFT45";
|
||||
case "Camera Center" -> "CENTER";
|
||||
case "Camera Right 45" -> "RIGHT45";
|
||||
case "Camera Right 90" -> "RIGHT90";
|
||||
default -> "UNKNOWN";
|
||||
}
|
||||
+ "_" + timetag + ".jpg";
|
||||
return prefix+" "+timetag+" "+cameratitle.getText() + ".jpg";
|
||||
|
||||
}
|
||||
|
||||
@@ -596,9 +577,7 @@ public class Cameradetail {
|
||||
Platform.runLater(()->setCameraStatus(ss));
|
||||
raise_log(ss);
|
||||
|
||||
AutoExposure.setSelected(true);
|
||||
AutoFocus.setSelected(true);
|
||||
AutoWhiteBalance.setSelected(true);
|
||||
|
||||
|
||||
Task<Image> task = new Task<>() {
|
||||
@SuppressWarnings("BusyWait")
|
||||
@@ -625,8 +604,11 @@ public class Cameradetail {
|
||||
IsGrabbingLiveView.set(true);
|
||||
Frame frame = mGrabber.grab(); // grab frame
|
||||
Mat mat = matconverter.convert(frame); // convert to Mat
|
||||
if (mat.empty()) continue; // kalau gak ada data, continue
|
||||
int counter = fps.incrementAndGet();
|
||||
if (counter % 5 != 0) continue; // frame skip to 6 fps
|
||||
|
||||
mat.copyTo(BestMat); // copy to BestMat for using OpenCL
|
||||
fps.addAndGet(1);
|
||||
IsGrabbingLiveView.set(false);
|
||||
|
||||
if (frame != null) {
|
||||
|
||||
Reference in New Issue
Block a user