Trial 05022025

This commit is contained in:
2025-02-05 15:20:21 +07:00
parent 29884c03ed
commit 30ef123832
11 changed files with 21247 additions and 299 deletions

View File

@@ -0,0 +1,54 @@
package id.co.gtc.erhacam;
import lombok.Getter;
import lombok.Setter;
import org.bytedeco.opencv.opencv_core.Rect;
import org.bytedeco.opencv.opencv_core.Scalar;
import org.bytedeco.opencv.opencv_core.UMat;
import java.util.List;
import static org.bytedeco.opencv.global.opencv_imgproc.rectangle;
@Getter
public class DetectorResult {
private @Setter Rect Face;
private List<Rect> Eyes;
public void AddEye(Rect eye){
if (Eyes == null) Eyes = new java.util.ArrayList<>();
Eyes.add(eye);
}
public void FaceRectangle(UMat mat){
if (haveFace()){
rectangle(mat, Face, Scalar.GREEN);
}
}
public void EyesRectangle(UMat mat){
if (haveEyes()){
for(Rect eye : Eyes){
rectangle(mat, eye, Scalar.BLUE);
}
}
}
public boolean haveFace(){
return Face != null && Face.width() > 0 && Face.height() > 0;
}
public int getFaceWidth(){
if (!haveFace()) return 0;
return Face.width();
}
public int getFaceHeight(){
if (!haveFace()) return 0;
return Face.height();
}
public boolean haveEyes(){
return Eyes != null && !Eyes.isEmpty();
}
}