Search in sources :

Example 11 with Size

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();
}
Also used : Size(org.opencv.core.Size)

Example 12 with Size

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;
}
Also used : Line(com.disnodeteam.dogecv.math.Line) Mat(org.opencv.core.Mat) Size(org.opencv.core.Size) ArrayList(java.util.ArrayList) Point(org.opencv.core.Point) Point(org.opencv.core.Point)

Example 13 with Size

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;
}
Also used : Mat(org.opencv.core.Mat) Size(org.opencv.core.Size)

Example 14 with Size

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;
}
Also used : Mat(org.opencv.core.Mat) Size(org.opencv.core.Size) Point(org.opencv.core.Point)

Example 15 with Size

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;
}
Also used : Size(org.opencv.core.Size)

Aggregations

Size (org.opencv.core.Size)28 Mat (org.opencv.core.Mat)17 Scalar (org.opencv.core.Scalar)9 ArrayList (java.util.ArrayList)8 Rect (org.opencv.core.Rect)7 Point (org.opencv.core.Point)6 MatOfPoint (org.opencv.core.MatOfPoint)4 SurfaceTexture (android.graphics.SurfaceTexture)2 Camera (android.hardware.Camera)2 Line (com.disnodeteam.dogecv.math.Line)2 File (java.io.File)2 MatOfPoint2f (org.opencv.core.MatOfPoint2f)2 DrawerLayout (android.support.v4.widget.DrawerLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 SurfaceView (android.view.SurfaceView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 RadioButton (android.widget.RadioButton)1 TextView (android.widget.TextView)1