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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations