* tambah timestamp
* full resolution ganti ke PNG compression 0 * tambah reduced resolution di 1280x720 JPG quality 100
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#Thu Dec 19 11:49:05 WIB 2024
|
#Wed Jan 15 10:18:31 WIB 2025
|
||||||
AudioPhase1=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase1.mp3
|
AudioPhase1=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase1.mp3
|
||||||
AudioPhase2=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase2.mp3
|
AudioPhase2=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase2.mp3
|
||||||
AudioPhase3=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase3.mp3
|
AudioPhase3=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase3.mp3
|
||||||
|
|||||||
BIN
database.db
BIN
database.db
Binary file not shown.
@@ -5,7 +5,6 @@ import com.google.gson.Gson;
|
|||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import javafx.embed.swing.SwingFXUtils;
|
import javafx.embed.swing.SwingFXUtils;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import lombok.val;
|
|
||||||
import org.bytedeco.javacv.Java2DFrameConverter;
|
import org.bytedeco.javacv.Java2DFrameConverter;
|
||||||
import org.bytedeco.javacv.OpenCVFrameConverter;
|
import org.bytedeco.javacv.OpenCVFrameConverter;
|
||||||
import org.bytedeco.opencv.global.opencv_imgcodecs;
|
import org.bytedeco.opencv.global.opencv_imgcodecs;
|
||||||
@@ -37,6 +36,10 @@ public class SomeCodes {
|
|||||||
public static final Gson gson = new Gson();
|
public static final Gson gson = new Gson();
|
||||||
public static final ConfigFile config = new ConfigFile();
|
public static final ConfigFile config = new ConfigFile();
|
||||||
|
|
||||||
|
public static String GetDateTimeString(){
|
||||||
|
return LocalDateTime.now().format(dtf);
|
||||||
|
}
|
||||||
|
|
||||||
public static Path GetLogsPath(){
|
public static Path GetLogsPath(){
|
||||||
return Path.of(currentDirectory, "logs");
|
return Path.of(currentDirectory, "logs");
|
||||||
}
|
}
|
||||||
@@ -288,7 +291,7 @@ public class SomeCodes {
|
|||||||
|
|
||||||
public static String[] MakeArray(String... args){
|
public static String[] MakeArray(String... args){
|
||||||
if (args!=null && args.length>0){
|
if (args!=null && args.length>0){
|
||||||
List<String> ll = new ArrayList<String>();
|
List<String> ll = new ArrayList<>();
|
||||||
for(String x : args){
|
for(String x : args){
|
||||||
if (ValidString(x)) ll.add(x);
|
if (ValidString(x)) ll.add(x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Camera.ArducamIMX477Preset;
|
|||||||
import Camera.CameraProperty;
|
import Camera.CameraProperty;
|
||||||
import Camera.LiveCamEvent;
|
import Camera.LiveCamEvent;
|
||||||
import Config.CameraConfigEnum;
|
import Config.CameraConfigEnum;
|
||||||
|
import Config.SomeCodes;
|
||||||
import com.google.zxing.BinaryBitmap;
|
import com.google.zxing.BinaryBitmap;
|
||||||
import com.google.zxing.NotFoundException;
|
import com.google.zxing.NotFoundException;
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
@@ -11,8 +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.beans.InvalidationListener;
|
|
||||||
import javafx.beans.Observable;
|
|
||||||
import javafx.concurrent.Task;
|
import javafx.concurrent.Task;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Slider;
|
import javafx.scene.control.Slider;
|
||||||
@@ -26,6 +25,7 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bytedeco.javacv.Frame;
|
import org.bytedeco.javacv.Frame;
|
||||||
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
||||||
|
import org.bytedeco.opencv.global.opencv_imgcodecs;
|
||||||
import org.bytedeco.opencv.global.opencv_imgproc;
|
import org.bytedeco.opencv.global.opencv_imgproc;
|
||||||
import org.bytedeco.opencv.opencv_core.*;
|
import org.bytedeco.opencv.opencv_core.*;
|
||||||
import org.opencv.videoio.Videoio;
|
import org.opencv.videoio.Videoio;
|
||||||
@@ -90,8 +90,10 @@ public class Cameradetail {
|
|||||||
|
|
||||||
private final UMat BestMat = new UMat();
|
private final UMat BestMat = new UMat();
|
||||||
private final UMat LiveMat = new UMat();
|
private final UMat LiveMat = new UMat();
|
||||||
|
private final UMat ReducedMat = new UMat();
|
||||||
private Size LiveSize = new Size(640, 480);
|
private Size LiveSize = new Size(640, 480);
|
||||||
private Size PhotoSize = new Size(1920, 1080);
|
private Size ReducedSize = new Size(1280, 720);
|
||||||
|
private Size BestSize = new Size(1920, 1080);
|
||||||
|
|
||||||
private void setSliderValue(Slider sld, CameraProperty prop, double value){
|
private void setSliderValue(Slider sld, CameraProperty prop, double value){
|
||||||
if (sld!=null){
|
if (sld!=null){
|
||||||
@@ -310,13 +312,16 @@ public class Cameradetail {
|
|||||||
* @param liveheight Height used on live view
|
* @param liveheight Height used on live view
|
||||||
* @param photowidth Width used on photo capture
|
* @param photowidth Width used on photo capture
|
||||||
* @param photoheight Height used on photo capture
|
* @param photoheight Height used on photo capture
|
||||||
|
* @param reducedwidth Width used on reduced resolution
|
||||||
|
* @param reducedheight Height used on reduced resolution
|
||||||
*/
|
*/
|
||||||
public void SetGrabber(OpenCVFrameGrabber grabber, int livewidth, int liveheight, int photowidth, int photoheight){
|
public void SetGrabber(OpenCVFrameGrabber grabber, int livewidth, int liveheight, int photowidth, int photoheight, int reducedwidth, int reducedheight){
|
||||||
if (mGrabber!=null) {
|
if (mGrabber!=null) {
|
||||||
StopLiveView();
|
StopLiveView();
|
||||||
}
|
}
|
||||||
LiveSize = new Size(livewidth, liveheight);
|
LiveSize = new Size(livewidth, liveheight);
|
||||||
PhotoSize = new Size(photowidth, photoheight);
|
BestSize = new Size(photowidth, photoheight);
|
||||||
|
ReducedSize = new Size(reducedwidth, reducedheight);
|
||||||
mGrabber = grabber;
|
mGrabber = grabber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,11 +524,36 @@ public class Cameradetail {
|
|||||||
if (!BestMat.empty()){
|
if (!BestMat.empty()){
|
||||||
Size sz = BestMat.size();
|
Size sz = BestMat.size();
|
||||||
raise_log("TakePhoto got frame with width: " + sz.width() + " and height: " + sz.height());
|
raise_log("TakePhoto got frame with width: " + sz.width() + " and height: " + sz.height());
|
||||||
String filename = Path.of(directory, makeFileName(prefix)).toString();
|
|
||||||
if (imwrite(filename, BestMat)){
|
String timestamp = prefix+" "+SomeCodes.GetDateTimeString();
|
||||||
|
int fontFace = FONT_HERSHEY_SIMPLEX;
|
||||||
|
double fontScale = 4.0;
|
||||||
|
int thickness = 2;
|
||||||
|
Scalar textColor = new Scalar(255, 255, 255, 0); // white color in BGR format
|
||||||
|
int[] baseline = {0};
|
||||||
|
Size textSize = getTextSize(timestamp, fontFace, fontScale, thickness, baseline);
|
||||||
|
// position of the text in the bottom right corner
|
||||||
|
int textX = BestMat.cols() - textSize.width() - 10; // 10 pixels from the right
|
||||||
|
int textY = BestMat.rows() - 10; // 10 pixels from the bottom
|
||||||
|
opencv_imgproc.putText(BestMat, timestamp, new Point(textX, textY), fontFace, fontScale, textColor, thickness, opencv_imgproc.LINE_AA, false);
|
||||||
|
|
||||||
|
int[] paramjpeg = {opencv_imgcodecs.IMWRITE_JPEG_QUALITY, 100};
|
||||||
|
int[] parampng = {opencv_imgcodecs.IMWRITE_PNG_COMPRESSION, 0};
|
||||||
|
|
||||||
|
// save BestMat at quality 9 PNG
|
||||||
|
String filename = Path.of(directory, makeFileName(prefix,".png")).toString();
|
||||||
|
if (imwrite(filename, BestMat, parampng)){
|
||||||
raise_log("TakePhoto success, Photo saved to " + filename);
|
raise_log("TakePhoto success, Photo saved to " + filename);
|
||||||
result = filename;
|
result = filename;
|
||||||
} else raise_log("TakePhoto failed, Unable to Save Photo");
|
} else raise_log("TakePhoto failed, Unable to Save Photo");
|
||||||
|
|
||||||
|
// save ReducedMat at 100% JPEG
|
||||||
|
String reducedfilename = Path.of(directory, makeReducedFileName(prefix,".jpg")).toString();
|
||||||
|
opencv_imgproc.resize(BestMat, ReducedMat, ReducedSize);
|
||||||
|
if (imwrite(reducedfilename, ReducedMat, paramjpeg)){
|
||||||
|
raise_log("TakePhoto success, Reduced Photo saved to " + reducedfilename);
|
||||||
|
} else raise_log("TakePhoto failed, Unable to Save Reduced Photo");
|
||||||
|
|
||||||
} else raise_log("TakePhoto failed, Live View is Empty");
|
} 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);
|
TakingPhoto.set(false);
|
||||||
@@ -531,14 +561,20 @@ public class Cameradetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO Revisi nama file
|
|
||||||
private String makeFileName(String prefix){
|
|
||||||
//make filename with prefix_POSITION_YYYY-MM-DD_HH-MM-SS
|
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private String makeFileName(String prefix, String extension){
|
||||||
LocalDateTime ldt = LocalDateTime.now();
|
LocalDateTime ldt = LocalDateTime.now();
|
||||||
String timetag = ldt.getYear() + "-" + ldt.getMonthValue() + "-" + ldt.getDayOfMonth() + "_" + ldt.getHour() + "-" + ldt.getMinute() + "-" + ldt.getSecond();
|
String timetag = ldt.getYear() + "-" + ldt.getMonthValue() + "-" + ldt.getDayOfMonth() + "_" + ldt.getHour() + "-" + ldt.getMinute() + "-" + ldt.getSecond();
|
||||||
return prefix+" "+timetag+" "+cameratitle.getText() + ".jpg";
|
return prefix+" "+timetag+" "+cameratitle.getText() + extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private String makeReducedFileName(String prefix, String extension){
|
||||||
|
LocalDateTime ldt = LocalDateTime.now();
|
||||||
|
String timetag = ldt.getYear() + "-" + ldt.getMonthValue() + "-" + ldt.getDayOfMonth() + "_" + ldt.getHour() + "-" + ldt.getMinute() + "-" + ldt.getSecond();
|
||||||
|
return prefix+" "+timetag+" "+cameratitle.getText() + "_reduced" + extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopLiveView(){
|
public void StopLiveView(){
|
||||||
@@ -565,15 +601,15 @@ public class Cameradetail {
|
|||||||
if (use_qr) raise_log("QR Reader loaded");
|
if (use_qr) raise_log("QR Reader loaded");
|
||||||
if (use_face) raise_log("Face detector loaded");
|
if (use_face) raise_log("Face detector loaded");
|
||||||
// capture with best resolution
|
// capture with best resolution
|
||||||
setFrameHeight(PhotoSize.height());
|
setFrameHeight(BestSize.height());
|
||||||
setFrameWidth(PhotoSize.width());
|
setFrameWidth(BestSize.width());
|
||||||
|
|
||||||
LiveFPS = 0;
|
LiveFPS = 0;
|
||||||
mGrabber.start();
|
mGrabber.start();
|
||||||
|
|
||||||
Capturing.set(true);
|
Capturing.set(true);
|
||||||
// just information
|
// just information
|
||||||
String ss = String.format("Camera Started with resolution %dx%d@%d", PhotoSize.width(), PhotoSize.height(),LiveFPS);
|
String ss = String.format("Camera Started with resolution %dx%d@%d", BestSize.width(), BestSize.height(),LiveFPS);
|
||||||
Platform.runLater(()->setCameraStatus(ss));
|
Platform.runLater(()->setCameraStatus(ss));
|
||||||
raise_log(ss);
|
raise_log(ss);
|
||||||
|
|
||||||
@@ -628,12 +664,12 @@ public class Cameradetail {
|
|||||||
if (use_face){
|
if (use_face){
|
||||||
RectVector face = DetectFace(graymat);
|
RectVector face = DetectFace(graymat);
|
||||||
if (face!=null && face.size()>0){
|
if (face!=null && face.size()>0){
|
||||||
if (event!=null) event.onFaceDetector(true, PhotoSize.width(), PhotoSize.height());
|
if (event!=null) event.onFaceDetector(true, BestSize.width(), BestSize.height());
|
||||||
for(int i=0; i<face.size(); i++){
|
for(int i=0; i<face.size(); i++){
|
||||||
Rect rect = face.get(i);
|
Rect rect = face.get(i);
|
||||||
rectangle(LiveMat, rect, Scalar.GREEN);
|
rectangle(LiveMat, rect, Scalar.GREEN);
|
||||||
}
|
}
|
||||||
} else if (event!=null) event.onFaceDetector(false, PhotoSize.width(), PhotoSize.height());
|
} else if (event!=null) event.onFaceDetector(false, BestSize.width(), BestSize.height());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -466,6 +466,8 @@ public class CaptureView {
|
|||||||
int liveheight = 480;
|
int liveheight = 480;
|
||||||
int photowidth = 640;
|
int photowidth = 640;
|
||||||
int photoheight = 480;
|
int photoheight = 480;
|
||||||
|
int reducewidth = 640;
|
||||||
|
int reduceheight = 480;
|
||||||
|
|
||||||
// mode1 selalu paling tinggi
|
// mode1 selalu paling tinggi
|
||||||
if (cameraname.contains("ACER QHD")){
|
if (cameraname.contains("ACER QHD")){
|
||||||
@@ -490,8 +492,10 @@ public class CaptureView {
|
|||||||
photoheight = ObsbotMeet2.ModeBest.getHeight();
|
photoheight = ObsbotMeet2.ModeBest.getHeight();
|
||||||
livewidth = ObsbotMeet2.ModeLive.getWidth();
|
livewidth = ObsbotMeet2.ModeLive.getWidth();
|
||||||
liveheight = ObsbotMeet2.ModeLive.getHeight();
|
liveheight = ObsbotMeet2.ModeLive.getHeight();
|
||||||
|
reducewidth = ObsbotMeet2.Mode3.getWidth();
|
||||||
|
reduceheight = ObsbotMeet2.Mode3.getHeight();
|
||||||
}
|
}
|
||||||
image.SetGrabber(grabber, livewidth,liveheight,photowidth,photoheight);
|
image.SetGrabber(grabber, livewidth,liveheight,photowidth,photoheight,reducewidth,reduceheight);
|
||||||
|
|
||||||
//TODO reconfirm requirement again
|
//TODO reconfirm requirement again
|
||||||
boolean use_face_detector = true;
|
boolean use_face_detector = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user