Search in sources :

Example 6 with Mat

use of org.opencv.core.Mat 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 7 with Mat

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

the class VideoInput method open.

@Override
public void open(ProcessingListener l) {
    movie = new VideoCapture(videofile);
    if (!movie.isOpened()) {
        String path = System.getProperty("OPENH264_LIBRARY_PATH");
        if (path == null)
            System.out.println("Warning: OPENH264_LIBRARY_PATH not set. Input Movie Opening Error for " + videofile);
        throw new RuntimeException("Input Movie Opening Error for " + videofile + ". Current path=" + new File(".").getAbsolutePath());
    }
    currentFrame = new Mat();
    currentPos = 0;
    grab();
    currentFrame = retrieve(currentFrame, l);
    frames = (int) movie.get(Videoio.CAP_PROP_FRAME_COUNT);
    fps = movie.get(Videoio.CAP_PROP_FPS);
    width = (int) movie.get(Videoio.CAP_PROP_FRAME_WIDTH);
    height = (int) movie.get(Videoio.CAP_PROP_FRAME_HEIGHT);
}
Also used : Mat(org.opencv.core.Mat) File(java.io.File) VideoCapture(org.opencv.videoio.VideoCapture)

Example 8 with Mat

use of org.opencv.core.Mat 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 9 with Mat

use of org.opencv.core.Mat 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 10 with Mat

use of org.opencv.core.Mat 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

Mat (org.opencv.core.Mat)285 Point (org.opencv.core.Point)50 ArrayList (java.util.ArrayList)45 MatOfPoint (org.opencv.core.MatOfPoint)43 MatOfKeyPoint (org.opencv.core.MatOfKeyPoint)20 Size (org.opencv.core.Size)20 KeyPoint (org.opencv.core.KeyPoint)18 Scalar (org.opencv.core.Scalar)17 Rect (org.opencv.core.Rect)16 File (java.io.File)8 RotatedRect (org.opencv.core.RotatedRect)6 BufferedImage (java.awt.image.BufferedImage)5 FilterContext (de.serviceflow.frankenstein.plugin.api.FilterContext)4 SegmentVideoFilter (de.serviceflow.frankenstein.plugin.api.SegmentVideoFilter)4 DefaultFilterContext (de.serviceflow.frankenstein.vf.DefaultFilterContext)4 VideoFilter (de.serviceflow.frankenstein.vf.VideoFilter)4 DataBufferByte (java.awt.image.DataBufferByte)4 IOException (java.io.IOException)4 FilterElement (de.serviceflow.frankenstein.vf.FilterElement)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3