Trial 05022025
This commit is contained in:
54
src/main/java/id/co/gtc/erhacam/DetectorResult.java
Normal file
54
src/main/java/id/co/gtc/erhacam/DetectorResult.java
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user