commit 27/2025
Tambah Crop Setting
This commit is contained in:
@@ -84,7 +84,7 @@ public class Detectors {
|
||||
* @param graymat Mat in Gray Scale
|
||||
* @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<>();
|
||||
RectVector faces = DetectFrontalFace(graymat);
|
||||
if (faces!=null && faces.size()>0){
|
||||
@@ -106,7 +106,7 @@ public class Detectors {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static @NonNull List<DetectorResult> HaveLeft45Face(UMat graymat){
|
||||
public static @NonNull List<DetectorResult> HaveLeft45Face(Mat graymat){
|
||||
List<DetectorResult> result = new ArrayList<>();
|
||||
RectVector faces = DetectProfileFace(graymat);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class Detectors {
|
||||
* @param graymat Mat in Gray Scale
|
||||
* @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);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public class Detectors {
|
||||
* @param graymat Mat in Gray Scale
|
||||
* @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);
|
||||
int minwidth = (int)(facewidth*0.2);
|
||||
int maxwidth = (int)(facewidth*0.4);
|
||||
@@ -189,24 +189,24 @@ public class Detectors {
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static RectVector Detect(UMat graymat, CascadeClassifier detector, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize){
|
||||
if (detector!=null){
|
||||
if (graymat!=null && graymat.channels()==1){
|
||||
if (!graymat.empty()){
|
||||
if (minSize!=null){
|
||||
if (maxSize!=null){
|
||||
try{
|
||||
private static RectVector Detect(Mat graymat, CascadeClassifier detector, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize){
|
||||
if (detector!=null && !detector.empty()){
|
||||
if (graymat!=null && graymat.channels()==1 && !graymat.empty()){
|
||||
if (minSize!=null && maxSize!=null){
|
||||
if (minSize.width()<= maxSize.width() && minSize.height() <= maxSize.height()){
|
||||
if (graymat.cols()> minSize.width() && graymat.rows() > minSize.height()) {
|
||||
try {
|
||||
RectVector detected = new RectVector();
|
||||
// try defaulting minSize and maxSize
|
||||
detector.detectMultiScale(graymat, detected, scaleFactor, minNeighbors, flags, minSize, maxSize);
|
||||
|
||||
return detected;
|
||||
} catch (Exception e){
|
||||
System.out.println("Detectors Detect Error, Message : "+e.getMessage());
|
||||
} catch (Exception e) {
|
||||
System.out.println("Detectors Detect Error, Message : " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user