commit 27/2025
Tambah Crop Setting
This commit is contained in:
4
.idea/inspectionProfiles/Project_Default.xml
generated
4
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,9 +1,10 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="AutoCloseableResource" enabled="false" level="WARNING" enabled_by_default="false">
|
||||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,java.util.concurrent.Executors,newFixedThreadPool" />
|
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,java.util.concurrent.Executors,newFixedThreadPool" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ClassEscapesItsScope" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="CommentedOutCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
<inspection_tool class="CommentedOutCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
<option name="minLines" value="3" />
|
<option name="minLines" value="3" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
@@ -15,5 +16,6 @@
|
|||||||
<option name="processComments" value="true" />
|
<option name="processComments" value="true" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="UnusedReturnValue" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#Mon May 26 14:20:06 WIB 2025
|
#Tue May 27 10:31:40 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
|
||||||
AudioPhase4=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase4.mp3
|
AudioPhase4=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase4.mp3
|
||||||
AudioPhase5=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase5.mp3
|
AudioPhase5=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam\\audio\\phase5.mp3
|
||||||
Cam1BottomCrop=10.0
|
Cam1BottomCrop=20.0
|
||||||
Cam1LeftCrop=10.0
|
Cam1LeftCrop=8.0
|
||||||
Cam1RightCrop=10.0
|
Cam1RightCrop=8.0
|
||||||
Cam1TopCrop=10.0
|
Cam1TopCrop=10.0
|
||||||
Cam2BottomCrop=10.0
|
Cam2BottomCrop=10.0
|
||||||
Cam2LeftCrop=10.0
|
Cam2LeftCrop=10.0
|
||||||
@@ -31,7 +31,7 @@ CameraConfigLeft90={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0
|
|||||||
CameraConfigRight45={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true}
|
CameraConfigRight45={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true}
|
||||||
CameraConfigRight90={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true}
|
CameraConfigRight90={"Brightness"\:0.0,"Contrast"\:0.0,"Saturation"\:0.0,"Hue"\:0.0,"Gain"\:1.0,"Exposure"\:1.0,"Sharpness"\:0.0,"Gamma"\:0.0,"AutoExposure"\:true,"AutoFocus"\:true,"AutoWhiteBalance"\:true}
|
||||||
CameraLeft45=
|
CameraLeft45=
|
||||||
CameraLeft90=
|
CameraLeft90=OBSBOT Meet 2 StreamCamera
|
||||||
CameraRight45=
|
CameraRight45=
|
||||||
CameraRight90=
|
CameraRight90=
|
||||||
FTPHost=192.168.10.2
|
FTPHost=192.168.10.2
|
||||||
@@ -41,9 +41,9 @@ FTPPort=21
|
|||||||
FTPUser=user
|
FTPUser=user
|
||||||
FlipCamera=false
|
FlipCamera=false
|
||||||
MirrorCamera=false
|
MirrorCamera=false
|
||||||
PhotoDirectory=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\ErhaCam
|
PhotoDirectory=C\:\\Users\\rdkar\\OneDrive\\Desktop\\Erha Capture
|
||||||
SharpnessThreshold=300.0
|
SharpnessThreshold=300.0
|
||||||
cascadeMaxSize=500
|
cascadeMaxSize=360
|
||||||
cascadeMinNeighbors=3
|
cascadeMinNeighbors=3
|
||||||
cascadeMinSize=250
|
cascadeMinSize=250
|
||||||
cascadeScaleFactor=1.1
|
cascadeScaleFactor=1.05
|
||||||
|
|||||||
@@ -55,23 +55,23 @@ public class ConfigFile {
|
|||||||
private @Getter final double leftcropmax = 30.0;
|
private @Getter final double leftcropmax = 30.0;
|
||||||
private @Getter final double rightcropmax = 30.0;
|
private @Getter final double rightcropmax = 30.0;
|
||||||
private @Getter double Cam1TopCrop = 10.0;
|
private @Getter double Cam1TopCrop = 10.0;
|
||||||
private @Getter double Cam1BottomCrop = 10.0;
|
private @Getter double Cam1BottomCrop = 20.0;
|
||||||
private @Getter double Cam1LeftCrop = 10.0;
|
private @Getter double Cam1LeftCrop = 8.0;
|
||||||
private @Getter double Cam1RightCrop = 10.0;
|
private @Getter double Cam1RightCrop = 8.0;
|
||||||
private @Getter double Cam2TopCrop = 10.0;
|
private @Getter double Cam2TopCrop = 10.0;
|
||||||
private @Getter double Cam2BottomCrop = 10.0;
|
private @Getter double Cam2BottomCrop = 20.0;
|
||||||
private @Getter double Cam2LeftCrop = 10.0;
|
private @Getter double Cam2LeftCrop = 8.0;
|
||||||
private @Getter double Cam2RightCrop = 10.0;
|
private @Getter double Cam2RightCrop = 8.0;
|
||||||
private @Getter double Cam3TopCrop = 10.0;
|
private @Getter double Cam3TopCrop = 10.0;
|
||||||
private @Getter double Cam3BottomCrop = 10.0;
|
private @Getter double Cam3BottomCrop = 20.0;
|
||||||
private @Getter double Cam3LeftCrop = 10.0;
|
private @Getter double Cam3LeftCrop = 8.0;
|
||||||
private @Getter double Cam3RightCrop = 10.0;
|
private @Getter double Cam3RightCrop = 8.0;
|
||||||
private @Getter double Cam4TopCrop = 10.0;
|
private @Getter double Cam4TopCrop = 10.0;
|
||||||
private @Getter double Cam4BottomCrop = 10.0;
|
private @Getter double Cam4BottomCrop = 20.0;
|
||||||
private @Getter double Cam4LeftCrop = 10.0;
|
private @Getter double Cam4LeftCrop = 8.0;
|
||||||
private @Getter double Cam4RightCrop = 10.0;
|
private @Getter double Cam4RightCrop = 8.0;
|
||||||
private @Getter double Cam5TopCrop = 10.0;
|
private @Getter double Cam5TopCrop = 10.0;
|
||||||
private @Getter double Cam5BottomCrop = 10.0;
|
private @Getter double Cam5BottomCrop = 20.0;
|
||||||
private @Getter double Cam5LeftCrop = 10.0;
|
private @Getter double Cam5LeftCrop = 10.0;
|
||||||
private @Getter double Cam5RightCrop = 10.0;
|
private @Getter double Cam5RightCrop = 10.0;
|
||||||
|
|
||||||
@@ -940,10 +940,10 @@ public class ConfigFile {
|
|||||||
SetDefaultCameraConfig(ConfigCenter);
|
SetDefaultCameraConfig(ConfigCenter);
|
||||||
SetDefaultCameraConfig(ConfigRight45);
|
SetDefaultCameraConfig(ConfigRight45);
|
||||||
SetDefaultCameraConfig(ConfigRight90);
|
SetDefaultCameraConfig(ConfigRight90);
|
||||||
cascadeScaleFactor = 1.1;
|
cascadeScaleFactor = 1.05;
|
||||||
cascadeMinNeighbors = 3;
|
cascadeMinNeighbors = 3;
|
||||||
cascadeMinSize = 250;
|
cascadeMinSize = 250;
|
||||||
cascadeMaxSize = 500;
|
cascadeMaxSize = 360;
|
||||||
Detectors.setFaceMaxSize(cascadeMaxSize);
|
Detectors.setFaceMaxSize(cascadeMaxSize);
|
||||||
Detectors.setFaceMinSize(cascadeMinSize);
|
Detectors.setFaceMinSize(cascadeMinSize);
|
||||||
Detectors.setScaleFactor(cascadeScaleFactor);
|
Detectors.setScaleFactor(cascadeScaleFactor);
|
||||||
@@ -952,29 +952,29 @@ public class ConfigFile {
|
|||||||
SharpnessThreshold = 300.0;
|
SharpnessThreshold = 300.0;
|
||||||
|
|
||||||
Cam1TopCrop = 10.0;
|
Cam1TopCrop = 10.0;
|
||||||
Cam1BottomCrop = 10.0;
|
Cam1BottomCrop = 20.0;
|
||||||
Cam1LeftCrop = 10.0;
|
Cam1LeftCrop = 8.0;
|
||||||
Cam1RightCrop = 10.0;
|
Cam1RightCrop = 8.0;
|
||||||
|
|
||||||
Cam2TopCrop = 10.0;
|
Cam2TopCrop = 10.0;
|
||||||
Cam2BottomCrop = 10.0;
|
Cam2BottomCrop = 20.0;
|
||||||
Cam2LeftCrop = 10.0;
|
Cam2LeftCrop = 8.0;
|
||||||
Cam2RightCrop = 10.0;
|
Cam2RightCrop = 8.0;
|
||||||
|
|
||||||
Cam3TopCrop = 10.0;
|
Cam3TopCrop = 10.0;
|
||||||
Cam3BottomCrop = 10.0;
|
Cam3BottomCrop = 20.0;
|
||||||
Cam3LeftCrop = 10.0;
|
Cam3LeftCrop = 8.0;
|
||||||
Cam3RightCrop = 10.0;
|
Cam3RightCrop = 8.0;
|
||||||
|
|
||||||
Cam4TopCrop = 10.0;
|
Cam4TopCrop = 10.0;
|
||||||
Cam4BottomCrop = 10.0;
|
Cam4BottomCrop = 20.0;
|
||||||
Cam4LeftCrop = 10.0;
|
Cam4LeftCrop = 8.0;
|
||||||
Cam4RightCrop = 10.0;
|
Cam4RightCrop = 8.0;
|
||||||
|
|
||||||
Cam5TopCrop = 10.0;
|
Cam5TopCrop = 10.0;
|
||||||
Cam5BottomCrop = 10.0;
|
Cam5BottomCrop = 20.0;
|
||||||
Cam5LeftCrop = 10.0;
|
Cam5LeftCrop = 8.0;
|
||||||
Cam5RightCrop = 10.0;
|
Cam5RightCrop = 8.0;
|
||||||
|
|
||||||
Logger.info("Default Config Created");
|
Logger.info("Default Config Created");
|
||||||
needsave = true;
|
needsave = true;
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ public class SomeCodes {
|
|||||||
* Check if Region of Interest 1 is same with Region of Interest 2
|
* Check if Region of Interest 1 is same with Region of Interest 2
|
||||||
* @param ROI1 Region of Interest 1
|
* @param ROI1 Region of Interest 1
|
||||||
* @param ROI2 Region of Interest 2
|
* @param ROI2 Region of Interest 2
|
||||||
* @return true if same, false if not same
|
* @return true if same, false if different
|
||||||
*/
|
*/
|
||||||
public static boolean IsSameROI(Rect ROI1, Rect ROI2){
|
public static boolean IsSameROI(Rect ROI1, Rect ROI2){
|
||||||
if (ValidROI(ROI1) && ValidROI(ROI2)){
|
if (ValidROI(ROI1) && ValidROI(ROI2)){
|
||||||
@@ -778,7 +778,7 @@ public class SomeCodes {
|
|||||||
public static double CalculateSharpness(String filename){
|
public static double CalculateSharpness(String filename){
|
||||||
if (ValidFile(filename)){
|
if (ValidFile(filename)){
|
||||||
try(Mat mat = opencv_imgcodecs.imread(filename)){
|
try(Mat mat = opencv_imgcodecs.imread(filename)){
|
||||||
return CalculateSharpness(new UMat(mat));
|
return CalculateSharpness(mat);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
Logger.error("Error calculating sharpness: "+filename+", Msg : "+e.getMessage());
|
Logger.error("Error calculating sharpness: "+filename+", Msg : "+e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -816,23 +816,23 @@ public class SomeCodes {
|
|||||||
* @param mat image in UMat format, expected in gray scale
|
* @param mat image in UMat format, expected in gray scale
|
||||||
* @return sharpness value
|
* @return sharpness value
|
||||||
*/
|
*/
|
||||||
public static double CalculateSharpness(UMat mat){
|
public static double CalculateSharpness(Mat mat){
|
||||||
|
|
||||||
if (mat!=null && !mat.empty()){
|
if (mat!=null && !mat.empty()){
|
||||||
if (mat.channels()!=1){
|
if (mat.channels()!=1){
|
||||||
UMat grey = new UMat();
|
Mat grey = new Mat();
|
||||||
opencv_imgproc.cvtColor(mat, grey, opencv_imgproc.COLOR_BGR2GRAY);
|
opencv_imgproc.cvtColor(mat, grey, opencv_imgproc.COLOR_BGR2GRAY);
|
||||||
mat = grey;
|
mat = grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
opencv_imgproc.equalizeHist(mat, mat);
|
opencv_imgproc.equalizeHist(mat, mat);
|
||||||
|
|
||||||
UMat laplacian = new UMat();
|
Mat laplacian = new Mat();
|
||||||
|
|
||||||
opencv_imgproc.Laplacian(mat, laplacian, CV_64F);
|
opencv_imgproc.Laplacian(mat, laplacian, CV_64F);
|
||||||
|
|
||||||
UMat mean = new UMat(1,1, CV_64F);
|
Mat mean = new Mat(1,1, CV_64F);
|
||||||
UMat stddev = new UMat(1,1, CV_64F);
|
Mat stddev = new Mat(1,1, CV_64F);
|
||||||
|
|
||||||
opencv_core.meanStdDev(laplacian, mean, stddev);
|
opencv_core.meanStdDev(laplacian, mean, stddev);
|
||||||
|
|
||||||
@@ -847,7 +847,7 @@ public class SomeCodes {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean IsBlurred(UMat mat, double threshold){
|
public static boolean IsBlurred(Mat mat, double threshold){
|
||||||
return CalculateSharpness(mat)<threshold;
|
return CalculateSharpness(mat)<threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
@@ -117,11 +116,11 @@ public class Cameradetail {
|
|||||||
private @Getter final UMat BestMat = new UMat();
|
private @Getter final UMat BestMat = new UMat();
|
||||||
private @Getter final UMat LiveMat = new UMat();
|
private @Getter final UMat LiveMat = new UMat();
|
||||||
private @Getter final UMat ReducedMat = new UMat();
|
private @Getter final UMat ReducedMat = new UMat();
|
||||||
private @Getter final UMat GrayMat = new UMat();
|
private @Getter final Mat GrayMat = new Mat();
|
||||||
|
|
||||||
private @Getter Rect BestMatROI;
|
// private @Getter Rect BestMatROI;
|
||||||
private @Getter Rect ReducedMatROI;
|
// private @Getter Rect ReducedMatROI;
|
||||||
private @Getter Rect LiveMatROI;
|
// private @Getter Rect LiveMatROI;
|
||||||
|
|
||||||
private boolean IsPortrait = false;
|
private boolean IsPortrait = false;
|
||||||
|
|
||||||
@@ -157,7 +156,6 @@ public class Cameradetail {
|
|||||||
|
|
||||||
private boolean use_qr = false;
|
private boolean use_qr = false;
|
||||||
private boolean use_face = false;
|
private boolean use_face = false;
|
||||||
private int _hardwareID = -1;
|
|
||||||
|
|
||||||
private void setSliderValue(Slider sld, CameraProperty prop, double value){
|
private void setSliderValue(Slider sld, CameraProperty prop, double value){
|
||||||
|
|
||||||
@@ -267,12 +265,10 @@ public class Cameradetail {
|
|||||||
public void setCameraTitle(String title){
|
public void setCameraTitle(String title){
|
||||||
|
|
||||||
if (ValidString(title)){
|
if (ValidString(title)){
|
||||||
if (!Objects.equals(this.title, title)){
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
LabelSetText(cameratitle, title,null);
|
LabelSetText(cameratitle, title,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setSharpness_indicator(double value){
|
public void setSharpness_indicator(double value){
|
||||||
if (value >= config.getSharpnessThreshold()){
|
if (value >= config.getSharpnessThreshold()){
|
||||||
@@ -422,7 +418,6 @@ public class Cameradetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mGrabber = grabber;
|
mGrabber = grabber;
|
||||||
_hardwareID = hardwareID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Exposure and Focus Tricks :
|
//Exposure and Focus Tricks :
|
||||||
@@ -687,7 +682,7 @@ public class Cameradetail {
|
|||||||
* @return filename path of the saved photo, or null if failed
|
* @return filename path of the saved photo, or null if failed
|
||||||
*/
|
*/
|
||||||
public PhotoResult TakePhoto(String directory, String prefix) {
|
public PhotoResult TakePhoto(String directory, String prefix) {
|
||||||
PhotoResult result = new PhotoResult(cameratitle.getText());
|
PhotoResult result = new PhotoResult(title);
|
||||||
if (!ValidDirectory(directory)) directory = currentDirectory;
|
if (!ValidDirectory(directory)) directory = currentDirectory;
|
||||||
|
|
||||||
if (mGrabber!=null){
|
if (mGrabber!=null){
|
||||||
@@ -699,37 +694,48 @@ public class Cameradetail {
|
|||||||
|
|
||||||
|
|
||||||
if (!BestMat.empty()){
|
if (!BestMat.empty()){
|
||||||
UMat cloned;
|
UMat cloned = new UMat();
|
||||||
synchronized (BestMat){
|
synchronized (BestMat){
|
||||||
cloned = BestMat.clone();
|
BestMat.copyTo(cloned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// save BestMat at quality 9 PNG
|
// save BestMat at quality 9 PNG
|
||||||
String filename = GetFullQualityPhotoPath(directory, prefix);
|
String fullresfile = GetFullQualityPhotoPath(directory, prefix);
|
||||||
if (opencv_imgcodecs.imwrite(filename, cloned, parampng)){
|
if (opencv_imgcodecs.imwrite(fullresfile, cloned, parampng)){
|
||||||
result.setFullres(filename);
|
result.setFullres(fullresfile);
|
||||||
} else System.out.println("TakePhoto failed, Unable to Save FullQUality Photo for camera "+cameratitle.getText());
|
} else System.out.println("TakePhoto failed, Unable to Save FullQUality Photo for camera "+title);
|
||||||
|
|
||||||
String xx = CropBestMat(directory, prefix, BestMatROI);
|
|
||||||
if (ValidFile(xx)) {
|
|
||||||
result.setFullcrop(xx);
|
|
||||||
result.setBestROI(new Rect(BestMatROI.x(), BestMatROI.y(), BestMatROI.width(), BestMatROI.height()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// save ReducedMat at 100% JPEG
|
// save ReducedMat at 100% JPEG
|
||||||
String reducedfilename = GetReducedPhotoPath(directory, prefix);
|
String reducedfile = GetReducedPhotoPath(directory, prefix);
|
||||||
opencv_imgproc.resize(cloned, ReducedMat, ReducedSize);
|
opencv_imgproc.resize(cloned, ReducedMat, ReducedSize);
|
||||||
if (!opencv_imgcodecs.imwrite(reducedfilename, ReducedMat, paramjpeg)){
|
if (opencv_imgcodecs.imwrite(reducedfile, ReducedMat, paramjpeg)){
|
||||||
System.out.println("TakePhoto failed, Unable to Save Reduced Photo for camera "+cameratitle.getText());
|
result.setCompressedfile(reducedfile);
|
||||||
} else result.setCompressedfile(reducedfilename);
|
} else {
|
||||||
|
System.out.println("TakePhoto failed, Unable to Save Reduced Photo for camera "+title);
|
||||||
String xy = CropReducedMat(directory, prefix, ReducedMatROI);
|
|
||||||
if (ValidFile(xy)){
|
|
||||||
result.setCompressedcrop(xy);
|
|
||||||
result.setReducedROI(new Rect(ReducedMatROI.x(), ReducedMatROI.y(), ReducedMatROI.width(), ReducedMatROI.height()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fullcropfile = GetFullQualityCropPhotoPath(directory, prefix);
|
||||||
|
UMat croppedfull = CropMat(cloned);
|
||||||
|
if (croppedfull!=null && !croppedfull.empty()){
|
||||||
|
if (opencv_imgcodecs.imwrite(fullcropfile, croppedfull, parampng)){
|
||||||
|
result.setFullcrop(fullcropfile);
|
||||||
|
} else {
|
||||||
|
System.out.println("TakePhoto failed, Unable to Save FullCrop Photo for camera "+title);
|
||||||
|
}
|
||||||
|
} else System.out.println("TakePhoto failed, Unable to Save FullCrop Photo for camera "+title);
|
||||||
|
|
||||||
|
|
||||||
|
String reducedcropfile = GetReducedCropPhotoPath(directory, prefix);
|
||||||
|
UMat reducedcrop = CropMat(ReducedMat);
|
||||||
|
if (reducedcrop!=null && !reducedcrop.empty()){
|
||||||
|
if (opencv_imgcodecs.imwrite(reducedcropfile, reducedcrop, paramjpeg)){
|
||||||
|
result.setCompressedcrop(reducedcropfile);
|
||||||
|
} else {
|
||||||
|
System.out.println("TakePhoto failed, Unable to Save ReducedCrop Photo for camera "+title);
|
||||||
|
}
|
||||||
|
} else System.out.println("TakePhoto failed, Unable to Save ReducedCrop Photo for camera "+title);
|
||||||
|
|
||||||
cloned.release();
|
cloned.release();
|
||||||
|
|
||||||
} else raise_log("TakePhoto failed, Live View is Empty");
|
} else raise_log("TakePhoto failed, Live View is Empty");
|
||||||
@@ -749,9 +755,9 @@ public class Cameradetail {
|
|||||||
|
|
||||||
|
|
||||||
public String CropBestMat(String directory, String prefix, Rect ROI){
|
public String CropBestMat(String directory, String prefix, Rect ROI){
|
||||||
UMat cloned;
|
UMat cloned = new UMat();
|
||||||
synchronized (BestMat){
|
synchronized (BestMat){
|
||||||
cloned = BestMat.clone();
|
BestMat.copyTo(cloned);
|
||||||
}
|
}
|
||||||
if (!cloned.empty()) {
|
if (!cloned.empty()) {
|
||||||
if (ValidROI(ROI)){
|
if (ValidROI(ROI)){
|
||||||
@@ -796,34 +802,34 @@ public class Cameradetail {
|
|||||||
private String makeFileName(String prefix, String extension){
|
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() + extension;
|
return prefix+" "+timetag+" "+title + extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("SameParameterValue")
|
@SuppressWarnings("SameParameterValue")
|
||||||
private String makeReducedFileName(String prefix, String extension){
|
private String makeReducedFileName(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() + "_reduced" + extension;
|
return prefix+" "+timetag+" "+title + "_reduced" + extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Release(){
|
// public void Release(){
|
||||||
if (mGrabber!=null){
|
// if (mGrabber!=null){
|
||||||
try{
|
// try{
|
||||||
StopLiveView();
|
// StopLiveView();
|
||||||
mGrabber.release();
|
// mGrabber.release();
|
||||||
mGrabber = null;
|
// mGrabber = null;
|
||||||
} catch (Exception e){
|
// } catch (Exception e){
|
||||||
System.out.println("Release failed, Unable to Release Camera, Error: " + e.getMessage());
|
// System.out.println("Release failed, Unable to Release Camera, Error: " + e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void StopLiveView(){
|
public void StopLiveView(){
|
||||||
Capturing.set(false);
|
Capturing.set(false);
|
||||||
if (mGrabber!=null){
|
if (mGrabber!=null){
|
||||||
try{
|
try{
|
||||||
mGrabber.close();
|
mGrabber.close();
|
||||||
System.out.println("Camera "+cameratitle.getText()+" stopped");
|
System.out.println("Camera "+title+" stopped");
|
||||||
setCameraStatus("Camera Stopped");
|
setCameraStatus("Camera Stopped");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
raise_log("StopLiveView failed, Unable to Stop Camera, Error: " + e.getMessage());
|
raise_log("StopLiveView failed, Unable to Stop Camera, Error: " + e.getMessage());
|
||||||
@@ -858,11 +864,8 @@ public class Cameradetail {
|
|||||||
while(Capturing.get()){
|
while(Capturing.get()){
|
||||||
try {
|
try {
|
||||||
qr_semaphore.acquire();
|
qr_semaphore.acquire();
|
||||||
UMat gray;
|
|
||||||
synchronized (lockObject){
|
String qr = DetectQRFromMat(GrayMat.clone());
|
||||||
gray = GrayMat;
|
|
||||||
}
|
|
||||||
String qr = DetectQRFromMat(gray);
|
|
||||||
if (ValidBarCode(qr)){
|
if (ValidBarCode(qr)){
|
||||||
if (event!=null) event.onDetectedQRCode(qr);
|
if (event!=null) event.onDetectedQRCode(qr);
|
||||||
}
|
}
|
||||||
@@ -887,10 +890,7 @@ public class Cameradetail {
|
|||||||
while(Capturing.get()){
|
while(Capturing.get()){
|
||||||
try {
|
try {
|
||||||
face_semaphore.acquire();
|
face_semaphore.acquire();
|
||||||
UMat gray;
|
|
||||||
synchronized (lockObject){
|
|
||||||
gray = GrayMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
DetectorResult theface = null;
|
DetectorResult theface = null;
|
||||||
boolean have_frontal_face = false;
|
boolean have_frontal_face = false;
|
||||||
@@ -898,7 +898,7 @@ public class Cameradetail {
|
|||||||
int _face_width = 0;
|
int _face_width = 0;
|
||||||
int _face_height = 0;
|
int _face_height = 0;
|
||||||
|
|
||||||
List<DetectorResult> frontalfaces = HaveFrontalFace(gray);
|
List<DetectorResult> frontalfaces = HaveFrontalFace(GrayMat.clone());
|
||||||
if (!frontalfaces.isEmpty()){
|
if (!frontalfaces.isEmpty()){
|
||||||
for(DetectorResult rect : frontalfaces){
|
for(DetectorResult rect : frontalfaces){
|
||||||
if (rect.haveFace() ){
|
if (rect.haveFace() ){
|
||||||
@@ -916,7 +916,7 @@ public class Cameradetail {
|
|||||||
} else {
|
} else {
|
||||||
// gak punya frontal face
|
// gak punya frontal face
|
||||||
// coba cek punya profile left face 45 gak
|
// coba cek punya profile left face 45 gak
|
||||||
List<DetectorResult> Left45Faces = HaveLeft45Face(gray);
|
List<DetectorResult> Left45Faces = HaveLeft45Face(GrayMat.clone());
|
||||||
if (!Left45Faces.isEmpty()){
|
if (!Left45Faces.isEmpty()){
|
||||||
for(DetectorResult rect : Left45Faces){
|
for(DetectorResult rect : Left45Faces){
|
||||||
if (rect.haveFace()){
|
if (rect.haveFace()){
|
||||||
@@ -938,9 +938,10 @@ public class Cameradetail {
|
|||||||
if (event!=null) event.onFrontalFaceDetector(true, _face_width, _face_height);
|
if (event!=null) event.onFrontalFaceDetector(true, _face_width, _face_height);
|
||||||
LabelVisible(face_indicator,true);
|
LabelVisible(face_indicator,true);
|
||||||
|
|
||||||
if (theface.getFace()!=null){
|
// Revisi 26/05/2025, LiveMatROI dihitung dari topcrop, bottomcrop, leftcrop dan rightcrop
|
||||||
LiveMatROI = new Rect(theface.getFace().x(), theface.getFace().y(), theface.getFace().width(), theface.getFace().height());
|
// if (theface.getFace()!=null){
|
||||||
}
|
// LiveMatROI = new Rect(theface.getFace().x(), theface.getFace().y(), theface.getFace().width(), theface.getFace().height());
|
||||||
|
// }
|
||||||
|
|
||||||
if (theface.getEyesCount()>=2){
|
if (theface.getEyesCount()>=2){
|
||||||
// ada mata (buka mata)
|
// ada mata (buka mata)
|
||||||
@@ -955,7 +956,7 @@ public class Cameradetail {
|
|||||||
if (eye_state.get()!=1){
|
if (eye_state.get()!=1){
|
||||||
// transisi dari tutup mata ke buka mata
|
// transisi dari tutup mata ke buka mata
|
||||||
if (eye_state.get()==-1) {
|
if (eye_state.get()==-1) {
|
||||||
System.out.println("First Eye Detected from camera "+cameratitle.getText());
|
System.out.println("First Eye Detected from camera "+title);
|
||||||
eye_state.set(1);
|
eye_state.set(1);
|
||||||
} else {
|
} else {
|
||||||
eye_state.set(1);
|
eye_state.set(1);
|
||||||
@@ -969,13 +970,13 @@ public class Cameradetail {
|
|||||||
long diff = now - last_blink.get();
|
long diff = now - last_blink.get();
|
||||||
// kalau beda waktu antara blink 1 dan blink 2 kurang dari 3 detik
|
// kalau beda waktu antara blink 1 dan blink 2 kurang dari 3 detik
|
||||||
if (diff<=3000){
|
if (diff<=3000){
|
||||||
System.out.println("Double Blink Detected from camera "+cameratitle.getText());
|
System.out.println("Double Blink Detected from camera "+title);
|
||||||
if (event!=null) event.onDoubleBlink((int)diff);
|
if (event!=null) event.onDoubleBlink((int)diff);
|
||||||
}
|
}
|
||||||
waiting_for_second_blink.set(false);
|
waiting_for_second_blink.set(false);
|
||||||
} else {
|
} else {
|
||||||
waiting_for_second_blink.set(true);
|
waiting_for_second_blink.set(true);
|
||||||
System.out.println("First Blink Detected from camera "+cameratitle.getText());
|
System.out.println("First Blink Detected from camera "+title);
|
||||||
}
|
}
|
||||||
last_blink.set(now);
|
last_blink.set(now);
|
||||||
}
|
}
|
||||||
@@ -1029,13 +1030,19 @@ public class Cameradetail {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (LiveMat != null && !LiveMat.empty()){
|
||||||
Mat imgmat = new Mat();
|
Mat imgmat = new Mat();
|
||||||
|
|
||||||
LiveMat.copyTo(imgmat);
|
|
||||||
// copy back to CPU
|
// copy back to CPU
|
||||||
|
LiveMat.copyTo(imgmat);
|
||||||
setCameraStream(MatToImage(imgmat));
|
setCameraStream(MatToImage(imgmat));
|
||||||
imgmat.release();
|
imgmat.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//System.out.println(Thread.currentThread().getName()+" interrupted");
|
//System.out.println(Thread.currentThread().getName()+" interrupted");
|
||||||
}
|
}
|
||||||
@@ -1055,7 +1062,7 @@ public class Cameradetail {
|
|||||||
Frame frame = mGrabber.grab(); // grab frame
|
Frame frame = mGrabber.grab(); // grab frame
|
||||||
delta = System.currentTimeMillis() - now;
|
delta = System.currentTimeMillis() - now;
|
||||||
now = System.currentTimeMillis();
|
now = System.currentTimeMillis();
|
||||||
} catch (FrameGrabber.Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1081,11 +1088,9 @@ public class Cameradetail {
|
|||||||
|
|
||||||
if (Capturing.get()) {
|
if (Capturing.get()) {
|
||||||
try{
|
try{
|
||||||
if (mGrabber!=null)
|
if (mGrabber==null) continue;
|
||||||
frame = mGrabber.grab();
|
frame = mGrabber.grab();
|
||||||
else throw new FrameGrabber.Exception("Grabber is null");
|
} catch (Exception e){
|
||||||
|
|
||||||
} catch (FrameGrabber.Exception e){
|
|
||||||
if (Capturing.get()){
|
if (Capturing.get()){
|
||||||
// kalau ada exception padahal masih capturing. Kalau sudah tidak capturing, tidak peduli
|
// kalau ada exception padahal masih capturing. Kalau sudah tidak capturing, tidak peduli
|
||||||
if (ValidString(e.getMessage())){
|
if (ValidString(e.getMessage())){
|
||||||
@@ -1139,15 +1144,29 @@ public class Cameradetail {
|
|||||||
|
|
||||||
// rotate 90 degree counter clockwise karena kamera potrait
|
// rotate 90 degree counter clockwise karena kamera potrait
|
||||||
opencv_core.rotate(originalmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
opencv_core.rotate(originalmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
||||||
|
|
||||||
originalmat.release();
|
originalmat.release();
|
||||||
|
|
||||||
if (!BestMat.empty()) {
|
if (!BestMat.empty()) {
|
||||||
|
|
||||||
// LiveMat and GrayMat are synchronized
|
// LiveMat and GrayMat are synchronized
|
||||||
synchronized (lockObject){
|
synchronized (lockObject){
|
||||||
opencv_imgproc.resize(BestMat, LiveMat, LiveSize); // resize to LiveSize
|
// resize BestMat to LiveSize
|
||||||
opencv_imgproc.cvtColor(LiveMat,GrayMat, COLOR_BGR2GRAY); // convert to grayscale
|
UMat _liveMat = new UMat();
|
||||||
|
opencv_imgproc.resize(BestMat, _liveMat, LiveSize);
|
||||||
|
// crop LiveMat
|
||||||
|
UMat croppedLiveMat = CropMat(_liveMat);
|
||||||
|
if (croppedLiveMat!=null && !croppedLiveMat.empty()){
|
||||||
|
croppedLiveMat.copyTo(LiveMat);
|
||||||
|
croppedLiveMat.release();
|
||||||
|
} else {
|
||||||
|
_liveMat.copyTo(LiveMat);
|
||||||
|
_liveMat.release();
|
||||||
|
}
|
||||||
|
// convert to grayscale
|
||||||
|
|
||||||
|
Mat xx = new Mat();
|
||||||
|
LiveMat.copyTo(xx);
|
||||||
|
opencv_imgproc.cvtColor(xx,GrayMat, COLOR_BGR2GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_qr){
|
if (use_qr){
|
||||||
@@ -1172,6 +1191,29 @@ public class Cameradetail {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private UMat CropMat(UMat mat){
|
||||||
|
if (mat != null && !mat.empty()){
|
||||||
|
int width = mat.cols();
|
||||||
|
int height = mat.rows();
|
||||||
|
|
||||||
|
int x = (int) (width * leftcrop / 100);
|
||||||
|
int y = (int) (height * topcrop / 100);
|
||||||
|
int w = (int) (width * (100 - leftcrop - rightcrop) / 100);
|
||||||
|
int h = (int) (height * (100 - topcrop - bottomcrop) / 100);
|
||||||
|
|
||||||
|
// Ensure the crop dimensions are valid
|
||||||
|
if (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= width && y + h <= height) {
|
||||||
|
Rect roi = new Rect(x, y, w, h);
|
||||||
|
|
||||||
|
UMat crop = new UMat();
|
||||||
|
mat.apply(roi).copyTo(crop);
|
||||||
|
return crop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void ChangeCropValue(){
|
public void ChangeCropValue(){
|
||||||
if ("01".equals(title)){
|
if ("01".equals(title)){
|
||||||
topcrop = config.getCam1TopCrop();
|
topcrop = config.getCam1TopCrop();
|
||||||
@@ -1281,81 +1323,78 @@ public class Cameradetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
/**
|
// * Remap LiveMatROI to BestMatROI and ReducedMatROI Resolution
|
||||||
* Remap LiveMatROI to BestMatROI and ReducedMatROI Resolution
|
// * @param scaleX scale factor for width
|
||||||
* @param scaleX scale factor for width
|
// * @param scaleY scale factor for height
|
||||||
* @param scaleY scale factor for height
|
// */
|
||||||
*/
|
// public void RemapROI(double scaleX, double scaleY, boolean printdebug){
|
||||||
public void RemapROI(double scaleX, double scaleY, boolean printdebug){
|
// BestMatROI = null;
|
||||||
BestMatROI = null;
|
// ReducedMatROI = null;
|
||||||
ReducedMatROI = null;
|
// if (ValidROI(LiveMatROI)){
|
||||||
if (ValidROI(LiveMatROI)){
|
// if (ROIInsideUMat(LiveMatROI, LiveMat)){
|
||||||
if (ROIInsideUMat(LiveMatROI, LiveMat)){
|
// if (printdebug) System.out.println("LiveMatROI camera "+cameratitle.getText()+" = "+RectToString(LiveMatROI));
|
||||||
if (printdebug) System.out.println("LiveMatROI camera "+cameratitle.getText()+" = "+RectToString(LiveMatROI));
|
//
|
||||||
|
// double scaleXBest = 1.0*BestSize.width()/LiveSize.width();
|
||||||
double scaleXBest = 1.0*BestSize.width()/LiveSize.width();
|
// double scaleYBest = 1.0*BestSize.height()/LiveSize.height();
|
||||||
double scaleYBest = 1.0*BestSize.height()/LiveSize.height();
|
// int XBest = (int) (LiveMatROI.x()*scaleXBest);
|
||||||
int XBest = (int) (LiveMatROI.x()*scaleXBest);
|
// int YBest = (int) (LiveMatROI.y()*scaleYBest);
|
||||||
int YBest = (int) (LiveMatROI.y()*scaleYBest);
|
// int WBest = (int) (LiveMatROI.width()*scaleXBest);
|
||||||
int WBest = (int) (LiveMatROI.width()*scaleXBest);
|
// int HBest = (int) (LiveMatROI.height()*scaleYBest);
|
||||||
int HBest = (int) (LiveMatROI.height()*scaleYBest);
|
// int deltaWBest = (int) (BestSize.width() * scaleX);
|
||||||
int deltaWBest = (int) (BestSize.width() * scaleX);
|
// int deltaHBest = (int) (BestSize.height() * scaleY);
|
||||||
int deltaHBest = (int) (BestSize.height() * scaleY);
|
// XBest = XBest - deltaWBest/2;
|
||||||
XBest = XBest - deltaWBest/2;
|
// if (XBest<0) XBest = 0;
|
||||||
if (XBest<0) XBest = 0;
|
// YBest = YBest - deltaHBest/2;
|
||||||
YBest = YBest - deltaHBest/2;
|
// if (YBest<0) YBest = 0;
|
||||||
if (YBest<0) YBest = 0;
|
// WBest = WBest + deltaWBest;
|
||||||
WBest = WBest + deltaWBest;
|
// if (WBest>BestSize.width()) WBest = BestSize.width();
|
||||||
if (WBest>BestSize.width()) WBest = BestSize.width();
|
// HBest = HBest + deltaHBest;
|
||||||
HBest = HBest + deltaHBest;
|
// if (HBest>BestSize.height()) HBest = BestSize.height();
|
||||||
if (HBest>BestSize.height()) HBest = BestSize.height();
|
// BestMatROI = new Rect(XBest, YBest, WBest, HBest);
|
||||||
BestMatROI = new Rect(XBest, YBest, WBest, HBest);
|
//
|
||||||
|
// if (printdebug){
|
||||||
if (printdebug){
|
// System.out.println("scaleXBest = "+scaleXBest+" scaleYBest = "+scaleYBest);
|
||||||
System.out.println("scaleXBest = "+scaleXBest+" scaleYBest = "+scaleYBest);
|
// System.out.println("BestMatROI camera "+cameratitle.getText()+" = "+RectToString(BestMatROI));
|
||||||
System.out.println("BestMatROI camera "+cameratitle.getText()+" = "+RectToString(BestMatROI));
|
// }
|
||||||
}
|
//
|
||||||
|
// double scaleXReduced = 1.0*ReducedSize.width()/LiveSize.width();
|
||||||
double scaleXReduced = 1.0*ReducedSize.width()/LiveSize.width();
|
// double scaleYReduced = 1.0*ReducedSize.height()/LiveSize.height();
|
||||||
double scaleYReduced = 1.0*ReducedSize.height()/LiveSize.height();
|
// int XReduced = (int) (LiveMatROI.x()*scaleXReduced);
|
||||||
int XReduced = (int) (LiveMatROI.x()*scaleXReduced);
|
// int YReduced = (int) (LiveMatROI.y()*scaleYReduced);
|
||||||
int YReduced = (int) (LiveMatROI.y()*scaleYReduced);
|
// int WReduced = (int) (LiveMatROI.width()*scaleXReduced);
|
||||||
int WReduced = (int) (LiveMatROI.width()*scaleXReduced);
|
// int HReduced = (int) (LiveMatROI.height()*scaleYReduced);
|
||||||
int HReduced = (int) (LiveMatROI.height()*scaleYReduced);
|
// int deltaWReduced = (int) (ReducedSize.width() * scaleX);
|
||||||
int deltaWReduced = (int) (ReducedSize.width() * scaleX);
|
// int deltaHReduced = (int) (ReducedSize.height() * scaleY);
|
||||||
int deltaHReduced = (int) (ReducedSize.height() * scaleY);
|
// XReduced = XReduced - deltaWReduced/2;
|
||||||
XReduced = XReduced - deltaWReduced/2;
|
// if (XReduced<0) XReduced = 0;
|
||||||
if (XReduced<0) XReduced = 0;
|
// YReduced = YReduced - deltaHReduced/2;
|
||||||
YReduced = YReduced - deltaHReduced/2;
|
// if (YReduced<0) YReduced = 0;
|
||||||
if (YReduced<0) YReduced = 0;
|
// WReduced = WReduced + deltaWReduced;
|
||||||
WReduced = WReduced + deltaWReduced;
|
// if (WReduced>ReducedSize.width()) WReduced = ReducedSize.width();
|
||||||
if (WReduced>ReducedSize.width()) WReduced = ReducedSize.width();
|
// HReduced = HReduced + deltaHReduced;
|
||||||
HReduced = HReduced + deltaHReduced;
|
// if (HReduced>ReducedSize.height()) HReduced = ReducedSize.height();
|
||||||
if (HReduced>ReducedSize.height()) HReduced = ReducedSize.height();
|
// ReducedMatROI = new Rect(XReduced, YReduced, WReduced, HReduced);
|
||||||
ReducedMatROI = new Rect(XReduced, YReduced, WReduced, HReduced);
|
// if (printdebug){
|
||||||
if (printdebug){
|
// System.out.println("scaleXReduced = "+scaleXReduced+" scaleYReduced = "+scaleYReduced);
|
||||||
System.out.println("scaleXReduced = "+scaleXReduced+" scaleYReduced = "+scaleYReduced);
|
// System.out.println("ReducedMatROI camera "+cameratitle.getText()+" = "+RectToString(ReducedMatROI));
|
||||||
System.out.println("ReducedMatROI camera "+cameratitle.getText()+" = "+RectToString(ReducedMatROI));
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect QR Code from Mat
|
* Detect QR Code from Mat
|
||||||
* @param graymat Mat in Gray Scale
|
* @param mat Mat in Gray Scale
|
||||||
* @return QR Code Text, or null if not detected
|
* @return QR Code Text, or null if not detected
|
||||||
*/
|
*/
|
||||||
private String DetectQRFromMat(UMat graymat){
|
private String DetectQRFromMat(Mat mat){
|
||||||
if (qrreader!=null){
|
if (qrreader!=null){
|
||||||
Mat mat = new Mat();
|
if (mat!=null && !mat.empty()){
|
||||||
graymat.copyTo(mat); // back to CPU, because zxing only accept BufferedImage
|
|
||||||
BufferedImage bufferedImage = matToBufferedImage(mat);
|
BufferedImage bufferedImage = matToBufferedImage(mat);
|
||||||
String title = cameratitle.getText();
|
|
||||||
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(bufferedImage)));
|
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(bufferedImage)));
|
||||||
try{
|
try{
|
||||||
Result result = qrreader.decode(binaryBitmap);
|
Result result = qrreader.decode(binaryBitmap);
|
||||||
@@ -1366,6 +1405,8 @@ public class Cameradetail {
|
|||||||
}
|
}
|
||||||
mat.release();
|
mat.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ public class CaptureView {
|
|||||||
@Override
|
@Override
|
||||||
public PhotoResult call() {
|
public PhotoResult call() {
|
||||||
if (image!=null){
|
if (image!=null){
|
||||||
image.RemapROI(0.1, 0.3, false);
|
//image.RemapROI(0.1, 0.3, false);
|
||||||
double sharpness = CalculateSharpness(image.getGrayMat());
|
double sharpness = CalculateSharpness(image.getGrayMat());
|
||||||
image.setSharpness_indicator(sharpness);
|
image.setSharpness_indicator(sharpness);
|
||||||
PhotoResult p = image.TakePhoto(directory, prefix);
|
PhotoResult p = image.TakePhoto(directory, prefix);
|
||||||
@@ -477,7 +477,7 @@ public class CaptureView {
|
|||||||
|
|
||||||
String[] files = prc.compressed();
|
String[] files = prc.compressed();
|
||||||
if (files.length>0){
|
if (files.length>0){
|
||||||
AutoCloseAlert.showpictures(prc.compressed(),3, (s)->{
|
AutoCloseAlert.showpictures(prc.compressedcrop(),3, (s)->{
|
||||||
if (AutoCloseAlert.banner_02!=null) {
|
if (AutoCloseAlert.banner_02!=null) {
|
||||||
AutoCloseAlert.showbanner(AutoCloseAlert.banner_02, 0, null);
|
AutoCloseAlert.showbanner(AutoCloseAlert.banner_02, 0, null);
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ public class CaptureView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void UploadFiles(PhotoReviewClass prc, String prefix){
|
private void UploadFiles(PhotoReviewClass prc, String prefix){
|
||||||
String[] files = prc.compressed();
|
String[] files = prc.compressedcrop();
|
||||||
if (files.length>0){
|
if (files.length>0){
|
||||||
InsertSQL(prc);
|
InsertSQL(prc);
|
||||||
|
|
||||||
@@ -1096,7 +1096,7 @@ public class CaptureView {
|
|||||||
};
|
};
|
||||||
image.setCameraStatus("Camera Starting");
|
image.setCameraStatus("Camera Starting");
|
||||||
if (image.StartLiveView(lce, title, use_qr_detector, use_face_detector)){
|
if (image.StartLiveView(lce, title, use_qr_detector, use_face_detector)){
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(image::Release));
|
//Runtime.getRuntime().addShutdownHook(new Thread(image::Release));
|
||||||
} else image.setCameraStatus("Unable to Set Grabber");
|
} else image.setCameraStatus("Unable to Set Grabber");
|
||||||
} else image.setCameraStatus("Camera not found, please check setting");
|
} else image.setCameraStatus("Camera not found, please check setting");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,14 @@ public class DetectorResult {
|
|||||||
Eyes.add(eye);
|
Eyes.add(eye);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trouble di sini
|
||||||
public void FaceRectangle(UMat mat){
|
public void FaceRectangle(UMat mat){
|
||||||
|
if (mat == null || mat.empty()) return;
|
||||||
|
if (Face == null || Face.width() <= 0 || Face.height() <= 0) return;
|
||||||
|
if (Face.x() < 0 || Face.y() < 0) return; // ignore negative coordinates
|
||||||
|
if (Face.x() + Face.width() > mat.cols() || Face.y() + Face.height() > mat.rows()) return; // ignore out of bounds
|
||||||
if (haveFace()){
|
if (haveFace()){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
rectangle(mat, Face, Scalar.GREEN, linethickness, linetype, lineshift);
|
rectangle(mat, Face, Scalar.GREEN, linethickness, linetype, lineshift);
|
||||||
|
|
||||||
@@ -33,9 +39,17 @@ public class DetectorResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trouble di sini
|
||||||
public void EyesRectangle(UMat mat){
|
public void EyesRectangle(UMat mat){
|
||||||
|
if (mat == null || mat.empty()) return;
|
||||||
|
|
||||||
if (haveEyes()){
|
if (haveEyes()){
|
||||||
|
|
||||||
for(Rect eye : Eyes){
|
for(Rect eye : Eyes){
|
||||||
|
if (eye == null || eye.width() <= 0 || eye.height() <= 0) continue;
|
||||||
|
if (eye.x() < 0 || eye.y() < 0) continue; // ignore negative coordinates
|
||||||
|
if (eye.x() + eye.width() > mat.cols() || eye.y() + eye.height() > mat.rows()) continue; // ignore out of bounds
|
||||||
|
|
||||||
try{
|
try{
|
||||||
rectangle(mat, eye, Scalar.BLUE);
|
rectangle(mat, eye, Scalar.BLUE);
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class Detectors {
|
|||||||
* @param graymat Mat in Gray Scale
|
* @param graymat Mat in Gray Scale
|
||||||
* @return List of Rect if face detected, otherwise empty list
|
* @return List of Rect if face detected, otherwise empty list
|
||||||
*/
|
*/
|
||||||
public static @NonNull List<DetectorResult> HaveFrontalFace(UMat graymat){
|
public static @NonNull List<DetectorResult> HaveFrontalFace(Mat graymat){
|
||||||
List<DetectorResult> result = new ArrayList<>();
|
List<DetectorResult> result = new ArrayList<>();
|
||||||
RectVector faces = DetectFrontalFace(graymat);
|
RectVector faces = DetectFrontalFace(graymat);
|
||||||
if (faces!=null && faces.size()>0){
|
if (faces!=null && faces.size()>0){
|
||||||
@@ -106,7 +106,7 @@ public class Detectors {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NonNull List<DetectorResult> HaveLeft45Face(UMat graymat){
|
public static @NonNull List<DetectorResult> HaveLeft45Face(Mat graymat){
|
||||||
List<DetectorResult> result = new ArrayList<>();
|
List<DetectorResult> result = new ArrayList<>();
|
||||||
RectVector faces = DetectProfileFace(graymat);
|
RectVector faces = DetectProfileFace(graymat);
|
||||||
if (faces!=null && faces.size()>0){
|
if (faces!=null && faces.size()>0){
|
||||||
@@ -160,7 +160,7 @@ public class Detectors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RectVector DetectProfileFace(UMat graymat){
|
public static RectVector DetectProfileFace(Mat graymat){
|
||||||
return Detect(graymat, profilefaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
return Detect(graymat, profilefaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ public class Detectors {
|
|||||||
* @param graymat Mat in Gray Scale
|
* @param graymat Mat in Gray Scale
|
||||||
* @return RectVector if face detected, otherwise null
|
* @return RectVector if face detected, otherwise null
|
||||||
*/
|
*/
|
||||||
public static RectVector DetectFrontalFace(UMat graymat){
|
public static RectVector DetectFrontalFace(Mat graymat){
|
||||||
return Detect(graymat, frontalfaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
return Detect(graymat, frontalfaceDetector, scaleFactor, minNeighbors, flags, FaceminSize, FacemaxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ public class Detectors {
|
|||||||
* @param graymat Mat in Gray Scale
|
* @param graymat Mat in Gray Scale
|
||||||
* @return RectVector if eye detected, otherwise null
|
* @return RectVector if eye detected, otherwise null
|
||||||
*/
|
*/
|
||||||
public static RectVector DetectEye(UMat graymat, int facewidth){
|
public static RectVector DetectEye(Mat graymat, int facewidth){
|
||||||
//return Detect(graymat, eyeDetector);
|
//return Detect(graymat, eyeDetector);
|
||||||
int minwidth = (int)(facewidth*0.2);
|
int minwidth = (int)(facewidth*0.2);
|
||||||
int maxwidth = (int)(facewidth*0.4);
|
int maxwidth = (int)(facewidth*0.4);
|
||||||
@@ -189,26 +189,26 @@ public class Detectors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("SameParameterValue")
|
@SuppressWarnings("SameParameterValue")
|
||||||
private static RectVector Detect(UMat graymat, CascadeClassifier detector, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize){
|
private static RectVector Detect(Mat graymat, CascadeClassifier detector, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize){
|
||||||
if (detector!=null){
|
if (detector!=null && !detector.empty()){
|
||||||
if (graymat!=null && graymat.channels()==1){
|
if (graymat!=null && graymat.channels()==1 && !graymat.empty()){
|
||||||
if (!graymat.empty()){
|
if (minSize!=null && maxSize!=null){
|
||||||
if (minSize!=null){
|
if (minSize.width()<= maxSize.width() && minSize.height() <= maxSize.height()){
|
||||||
if (maxSize!=null){
|
if (graymat.cols()> minSize.width() && graymat.rows() > minSize.height()) {
|
||||||
try {
|
try {
|
||||||
RectVector detected = new RectVector();
|
RectVector detected = new RectVector();
|
||||||
|
// try defaulting minSize and maxSize
|
||||||
detector.detectMultiScale(graymat, detected, scaleFactor, minNeighbors, flags, minSize, maxSize);
|
detector.detectMultiScale(graymat, detected, scaleFactor, minNeighbors, flags, minSize, maxSize);
|
||||||
|
|
||||||
return detected;
|
return detected;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Detectors Detect Error, Message : " + e.getMessage());
|
System.out.println("Detectors Detect Error, Message : " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import javafx.stage.Stage;
|
|||||||
import org.tinylog.Logger;
|
import org.tinylog.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static Config.SomeCodes.ShowAlert;
|
import static Config.SomeCodes.ShowAlert;
|
||||||
import static Config.SomeCodes.config;
|
import static Config.SomeCodes.config;
|
||||||
@@ -50,7 +49,7 @@ public class MainApplication extends Application {
|
|||||||
Screen screen = Screen.getPrimary();
|
Screen screen = Screen.getPrimary();
|
||||||
Rectangle2D screenbound = screen.getBounds();
|
Rectangle2D screenbound = screen.getBounds();
|
||||||
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
|
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
|
||||||
stage.setTitle("MultiCam Capture App for ERHA 26052025-001");
|
stage.setTitle("MultiCam Capture App for ERHA 27052025-005");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setResizable(true);
|
stage.setResizable(true);
|
||||||
stage.setMaximized(true);
|
stage.setMaximized(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user