Search in sources :

Example 1 with Rect

use of org.opencv.core.Rect in project kifu-recorder by leonardost.

the class CornerDetector method getRegionOfInterestAround.

private Mat getRegionOfInterestAround(Corner corner, Mat image) {
    int x = corner.getX() - RADIUS_OF_REGION_OF_INTEREST > 0 ? corner.getX() - RADIUS_OF_REGION_OF_INTEREST : 0;
    int y = corner.getY() - RADIUS_OF_REGION_OF_INTEREST > 0 ? corner.getY() - RADIUS_OF_REGION_OF_INTEREST : 0;
    int w = x + 2 * RADIUS_OF_REGION_OF_INTEREST < image.cols() ? 2 * RADIUS_OF_REGION_OF_INTEREST : image.cols() - x;
    int h = y + 2 * RADIUS_OF_REGION_OF_INTEREST < image.rows() ? 2 * RADIUS_OF_REGION_OF_INTEREST : image.rows() - y;
    System.out.println("ROI: (x = " + x + ", y = " + y + ", w = " + w + ", h = " + h + ")");
    Rect regionOfInterest = new Rect(x, y, w, h);
    return new Mat(image, regionOfInterest);
}
Also used : Mat(org.opencv.core.Mat) Rect(org.opencv.core.Rect) Point(org.opencv.core.Point)

Example 2 with Rect

use of org.opencv.core.Rect in project Frankenstein by olir.

the class CloneLR method process.

@Override
public Mat process(Mat sourceFrame, int frameId, FilterContext context) {
    // System.out.println("???");
    Rect roi = new Rect(0, 0, sourceFrame.cols(), sourceFrame.rows());
    sourceFrame.copyTo(new Mat(newFrame, roi));
    // System.out.println("???"+newFrame.cols()+" "+sourceFrame.cols());
    roi = new Rect(sourceFrame.cols(), 0, sourceFrame.cols(), sourceFrame.rows());
    sourceFrame.copyTo(new Mat(newFrame, roi));
    return newFrame;
}
Also used : Mat(org.opencv.core.Mat) Rect(org.opencv.core.Rect)

Example 3 with Rect

use of org.opencv.core.Rect in project Frankenstein by olir.

the class StereoDistanceFilter method process.

@Override
public Mat process(Mat sourceFrame, int frameId, FilterContext context) {
    if (newFrame == null || newFrame.cols() != sourceFrame.cols() || newFrame.rows() != sourceFrame.rows()) {
        newFrame = sourceFrame.clone();
        perspectiveMultiplier = sourceFrame.cols() / 320;
        if (perspectiveMultiplier < 1)
            perspectiveMultiplier = 1;
    }
    newFrame.setTo(new Scalar(0, 0, 0));
    Rect roi = new Rect(val(0, perspective(), 0, -1), 0, (sourceFrame.cols() >> 1) - Math.abs(perspective()), sourceFrame.rows());
    sourceFrame.submat(new Rect((Math.abs(perspective()) >> 1), 0, (sourceFrame.cols() >> 1) - Math.abs(perspective()), sourceFrame.rows())).copyTo(new Mat(newFrame, roi));
    roi = new Rect(val(sourceFrame.cols() >> 1, -perspective(), sourceFrame.cols() >> 1, -1), 0, (sourceFrame.cols() >> 1) - Math.abs(perspective()), sourceFrame.rows());
    sourceFrame.submat(new Rect((sourceFrame.cols() >> 1) + (Math.abs(perspective()) >> 1), 0, (sourceFrame.cols() >> 1) - Math.abs(perspective()), sourceFrame.rows())).copyTo(new Mat(newFrame, roi));
    return newFrame;
}
Also used : Mat(org.opencv.core.Mat) Rect(org.opencv.core.Rect) Scalar(org.opencv.core.Scalar)

Example 4 with Rect

use of org.opencv.core.Rect in project Frankenstein by olir.

the class LDelay method configure.

@Override
public Mat configure(Mat sourceFrame) {
    newFrame = sourceFrame.clone();
    frameBuffer = sourceFrame.clone();
    if (delayLeft) {
        // Take over right side to left side in buffer
        Rect roi = new Rect(0, 0, sourceFrame.cols() >> 1, sourceFrame.rows());
        sourceFrame.submat(new Rect(sourceFrame.cols() >> 1, 0, sourceFrame.cols() >> 1, sourceFrame.rows())).copyTo(new Mat(frameBuffer, roi));
    } else {
        // Take over left side to right side in buffer
        Rect roi = new Rect(sourceFrame.cols() >> 1, 0, sourceFrame.cols() >> 1, sourceFrame.rows());
        sourceFrame.submat(new Rect(0, 0, sourceFrame.cols() >> 1, sourceFrame.rows())).copyTo(new Mat(frameBuffer, roi));
    }
    return newFrame;
}
Also used : Mat(org.opencv.core.Mat) Rect(org.opencv.core.Rect)

Example 5 with Rect

use of org.opencv.core.Rect in project Frankenstein by olir.

the class RL2LR method process.

@Override
public Mat process(Mat sourceFrame, int frameId, FilterContext context) {
    Rect roi = new Rect(0, 0, sourceFrame.cols() >> 1, sourceFrame.rows());
    sourceFrame.submat(new Rect(sourceFrame.cols() >> 1, 0, sourceFrame.cols() >> 1, sourceFrame.rows())).copyTo(new Mat(newFrame, roi));
    roi = new Rect(sourceFrame.cols() >> 1, 0, sourceFrame.cols() >> 1, sourceFrame.rows());
    sourceFrame.submat(new Rect(0, 0, sourceFrame.cols() >> 1, sourceFrame.rows())).copyTo(new Mat(newFrame, roi));
    return newFrame;
}
Also used : Mat(org.opencv.core.Mat) Rect(org.opencv.core.Rect)

Aggregations

Rect (org.opencv.core.Rect)20 Mat (org.opencv.core.Mat)16 Point (org.opencv.core.Point)10 Scalar (org.opencv.core.Scalar)7 Size (org.opencv.core.Size)7 MatOfPoint (org.opencv.core.MatOfPoint)6 ArrayList (java.util.ArrayList)4 KeyPoint (org.opencv.core.KeyPoint)2 MatOfKeyPoint (org.opencv.core.MatOfKeyPoint)2 MatOfPoint2f (org.opencv.core.MatOfPoint2f)2 TimingLogger (android.util.TimingLogger)1 File (java.io.File)1 RotatedRect (org.opencv.core.RotatedRect)1