Java Code Examples for org.bytedeco.javacv.Java2DFrameConverter#convert()

The following examples show how to use org.bytedeco.javacv.Java2DFrameConverter#convert() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConverterService.java    From Spring with Apache License 2.0 6 votes vote down vote up
public void toAnimatedGif(FFmpegFrameGrabber frameGrabber, AnimatedGifEncoder
        gifEncoder, int start, int end, int speed) throws FrameGrabber.Exception {

    final long startFrame = Math.round(start * frameGrabber.getFrameRate());
    final long endFrame = Math.round(end * frameGrabber.getFrameRate());

    final Java2DFrameConverter frameConverter = new Java2DFrameConverter();

    for (long i = startFrame; i < endFrame; i++) {

        if (i % speed == 0) {

            // Bug if frameNumber is set to 0
            if (i > 0) {
                frameGrabber.setFrameNumber((int) i);
            }

            final BufferedImage bufferedImage = frameConverter.convert(frameGrabber.grabImage());
            gifEncoder.addFrame(bufferedImage);
        }

    }

    frameGrabber.stop();
    gifEncoder.finish();
}
 
Example 2
Source File: TestNativeImageLoader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
BufferedImage makeRandomBufferedImage(int height, int width, int channels) {
    Mat img = makeRandomImage(height, width, channels);

    OpenCVFrameConverter.ToMat c = new OpenCVFrameConverter.ToMat();
    Java2DFrameConverter c2 = new Java2DFrameConverter();

    return c2.convert(c.convert(img));
}
 
Example 3
Source File: TestNativeImageLoader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
BufferedImage makeRandomBufferedImage(int height, int width, int channels) {
    Mat img = makeRandomImage(height, width, channels);

    OpenCVFrameConverter.ToMat c = new OpenCVFrameConverter.ToMat();
    Java2DFrameConverter c2 = new Java2DFrameConverter();

    return c2.convert(c.convert(img));
}
 
Example 4
Source File: ImageConversionUtils.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
public static BufferedImage makeRandomBufferedImage(int height, int width, int channels) {
    Mat img = makeRandomImage(height, width, channels);

    OpenCVFrameConverter.ToMat c = new OpenCVFrameConverter.ToMat();
    Java2DFrameConverter c2 = new Java2DFrameConverter();

    return c2.convert(c.convert(img));
}
 
Example 5
Source File: RobotUtils.java    From karate with MIT License 4 votes vote down vote up
public static BufferedImage toBufferedImage(Mat mat) {
    OpenCVFrameConverter.ToMat openCVConverter = new OpenCVFrameConverter.ToMat();
    Java2DFrameConverter java2DConverter = new Java2DFrameConverter();
    return java2DConverter.convert(openCVConverter.convert(mat));
}