Java Code Examples for org.opencv.core.Rect#tl()

The following examples show how to use org.opencv.core.Rect#tl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FaceDrawerOpenCV.java    From Image-Detection-Samples with Apache License 2.0 5 votes vote down vote up
public static void drawFaceShapes(Rect face, Mat matrixRGBA) {
    Point start = face.tl();
    int h = (int) start.y + (face.height / 2);
    int w = (int) start.x + (face.width / 2);
    Imgproc.rectangle(matrixRGBA, start, face.br(),
            FACE_RECT_COLOR, 3);
    Point center = new Point(w, h);
    Imgproc.circle(matrixRGBA, center, 10, new Scalar(255, 0, 0, 255), 3);
}
 
Example 2
Source File: DetectionHelper.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static boolean isFaceInsideFrame(AnimalOverlay animalOverlay, Mat img, Rect face){
    if (animalOverlay != null){
        Point frameTopLeft = new Point(animalOverlay.getFrameStartX(), animalOverlay.getFrameStartY());
        Point frameBottomRight = new Point(animalOverlay.getFrameEndX(), animalOverlay.getFrameEndY());
        Rect frame = new Rect(frameTopLeft, frameBottomRight);
        if ((face.tl().x >= frame.tl().x) && (face.tl().y >= frame.tl().y) && (face.br().x <= frame.br().x) && (face.br().y <= frame.br().y)){
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
Example 3
Source File: MatOperation.java    From Android-Face-Recognition-with-Deep-Learning-Library with Apache License 2.0 5 votes vote down vote up
public static Point drawRectangleOnPreview(Mat img, Rect face, boolean front_camera){
    if(front_camera){
        Rect mirroredFace = getMirroredFaceForFrontCamera(img, face);
        Imgproc.rectangle(img, mirroredFace.tl(), mirroredFace.br(), FACE_RECT_COLOR, THICKNESS);
        return mirroredFace.tl();
    } else {
        Imgproc.rectangle(img, face.tl(), face.br(), FACE_RECT_COLOR, THICKNESS);
        return face.tl();
    }
}
 
Example 4
Source File: DetectionHelper.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static boolean isFaceInsideFrame(AnimalOverlay animalOverlay, Mat img, Rect face){
    if (animalOverlay != null){
        Point frameTopLeft = new Point(animalOverlay.getFrameStartX(), animalOverlay.getFrameStartY());
        Point frameBottomRight = new Point(animalOverlay.getFrameEndX(), animalOverlay.getFrameEndY());
        Rect frame = new Rect(frameTopLeft, frameBottomRight);
        if ((face.tl().x >= frame.tl().x) && (face.tl().y >= frame.tl().y) && (face.br().x <= frame.br().x) && (face.br().y <= frame.br().y)){
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
Example 5
Source File: DetectionHelper.java    From ml-authentication with Apache License 2.0 4 votes vote down vote up
public static void drawArrowFromFaceToFrame(AnimalOverlay animalOverlay, Mat img, Rect face){
    Rect mirroredFace = MatOperation.getMirroredFaceForFrontCamera(img, face);
    Point pointFace = new Point(mirroredFace.tl().x + mirroredFace.width / 2, mirroredFace.tl().y + mirroredFace.height / 2);
    Point pointFrame = new Point(animalOverlay.getFrameStartX() + (animalOverlay.getFrameEndX() - animalOverlay.getFrameStartX()) / 2, animalOverlay.getFrameStartY() + (animalOverlay.getFrameEndY() - animalOverlay.getFrameStartY()) / 2);
    Imgproc.arrowedLine(img, pointFace, pointFrame, RED_COLOR, 20, Imgproc.LINE_8, 0, 0.2);
}
 
Example 6
Source File: Rectangle.java    From FTCVision with MIT License 4 votes vote down vote up
private void setRect(Rect rect) {
    this.rect = new RotatedRect(new Point(rect.tl().x + rect.size().width / 2,
            rect.tl().y + rect.size().height / 2), rect.size(), 0.0);
}
 
Example 7
Source File: DetectionHelper.java    From ml-authentication with Apache License 2.0 4 votes vote down vote up
public static void drawArrowFromFaceToFrame(AnimalOverlay animalOverlay, Mat img, Rect face){
    Rect mirroredFace = MatOperation.getMirroredFaceForFrontCamera(img, face);
    Point pointFace = new Point(mirroredFace.tl().x + mirroredFace.width / 2, mirroredFace.tl().y + mirroredFace.height / 2);
    Point pointFrame = new Point(animalOverlay.getFrameStartX() + (animalOverlay.getFrameEndX() - animalOverlay.getFrameStartX()) / 2, animalOverlay.getFrameStartY() + (animalOverlay.getFrameEndY() - animalOverlay.getFrameStartY()) / 2);
    Imgproc.arrowedLine(img, pointFace, pointFrame, RED_COLOR, 20, Imgproc.LINE_8, 0, 0.2);
}