use of org.opencv.core.Size in project Relic_Main by TeamOverdrive.
the class LeviColorFilter method process.
@Override
public void process(Mat input, Mat mask) {
channels = new ArrayList<>();
switch(color) {
case RED:
if (threshold == -1) {
threshold = 164;
}
Imgproc.cvtColor(input, input, Imgproc.COLOR_RGB2Lab);
Imgproc.GaussianBlur(input, input, new Size(3, 3), 0);
Core.split(input, channels);
Imgproc.threshold(channels.get(1), mask, threshold, 255, Imgproc.THRESH_BINARY);
break;
case BLUE:
if (threshold == -1) {
threshold = 145;
}
Imgproc.cvtColor(input, input, Imgproc.COLOR_RGB2YUV);
Imgproc.GaussianBlur(input, input, new Size(3, 3), 0);
Core.split(input, channels);
Imgproc.threshold(channels.get(1), mask, threshold, 255, Imgproc.THRESH_BINARY);
break;
case YELLOW:
if (threshold == -1) {
threshold = 95;
}
Imgproc.cvtColor(input, input, Imgproc.COLOR_RGB2YUV);
Imgproc.GaussianBlur(input, input, new Size(3, 3), 0);
Core.split(input, channels);
Imgproc.threshold(channels.get(1), mask, threshold, 255, Imgproc.THRESH_BINARY_INV);
break;
}
for (int i = 0; i < channels.size(); i++) {
channels.get(i).release();
}
input.release();
}
use of org.opencv.core.Size in project Relic_Main by TeamOverdrive.
the class Lines method getOpenCvLines.
public static List<Line> getOpenCvLines(Mat original, int scale, double minLength) {
Mat raw = new Mat();
Imgproc.resize(original.clone(), raw, new Size((int) (original.size().width / scale), (int) (original.size().height / scale)));
if (raw.channels() > 1) {
Imgproc.cvtColor(raw, raw, Imgproc.COLOR_RGB2GRAY);
}
Imgproc.equalizeHist(raw, raw);
Imgproc.blur(raw, raw, new Size(3, 3));
// Line Segment Detection 2
Mat linesM1 = new Mat();
// LineSegmentDetector detector = Imgproc.createLineSegmentDetector(Imgproc.LSD_REFINE_ADV, 0.6, 0.3, 2.6, 22.5, 0, 0.3,256);
// LineSegmentDetector detector = Imgproc.createLineSegmentDetector(Imgproc.LSD_REFINE_STD, 0.5, 0.4,2.0, 19.5, 0, 0.6, 32);
// Reference for final glyph detection
detector.detect(raw, linesM1);
ArrayList<Line> lines = new ArrayList<Line>();
for (int x = 0; x < linesM1.rows(); x++) {
double[] vec = linesM1.get(x, 0);
Point start = new Point(vec[0], vec[1]);
Point end = new Point(vec[2], vec[3]);
Line line = new Line(start, end);
line = new Line(new Point((int) line.x1 * scale, (int) line.y1 * scale), new Point((int) line.x2 * scale, (int) line.y2 * scale));
if (line.length() > minLength)
lines.add(line);
}
raw.release();
linesM1.release();
return lines;
}
use of org.opencv.core.Size in project java-client by appium.
the class ScreenshotState method resizeFirstMatrixToSecondMatrixResolution.
private static Mat resizeFirstMatrixToSecondMatrixResolution(Mat first, Mat second) {
if (first.width() != second.width() || first.height() != second.height()) {
final Mat result = new Mat();
final Size sz = new Size(second.width(), second.height());
Imgproc.resize(first, result, sz);
return result;
}
return first;
}
use of org.opencv.core.Size in project Auto.js by hyb1996.
the class TemplateMatching method getPyramidDownAtLevel.
private static Mat getPyramidDownAtLevel(Mat m, int level) {
if (level == 0) {
return m;
}
int cols = m.cols();
int rows = m.rows();
for (int i = 0; i < level; i++) {
cols = (cols + 1) / 2;
rows = (rows + 1) / 2;
}
Mat r = new Mat(rows, cols, m.type());
Imgproc.resize(m, r, new Size(cols, rows));
return r;
}
use of org.opencv.core.Size in project Frankenstein by olir.
the class MovieProcessor method configureOutput.
// fourcc = 0x00000021; // openh264 - problem with ffmpeg
// fourcc = VideoWriter.fourcc('X','2','6','4'); // -- MP4
// fourcc = VideoWriter.fourcc('M','R','L','E'); // -- Motion JPEG
// (nativ)
// fourcc = VideoWriter.fourcc('P','I','M','1'); // - MPEG-1 based
// codec - bad audio
// fourcc = VideoWriter.fourcc('M','S','V','C'); // + Video For
// Windows - bad Video quality
public boolean configureOutput(ProcessingListener l) {
if (configuration.doOutput) {
outputVideo.open(tempVideoFile.getAbsolutePath(), fourcc, movie_fps, new Size(movie_w, movie_h), true);
System.out.println("ConfigureOutput size=" + new Size(movie_w, movie_h) + " fps=" + movie_fps);
if (!outputVideo.isOpened()) {
System.err.println("Warning: VideoWriter - Could not open the output video for write. (MovieProcessor)");
// return false;
}
}
return true;
}
Aggregations