Search in sources :

Example 6 with Java2DFrameConverter

use of org.bytedeco.javacv.Java2DFrameConverter in project javacv by bytedeco.

the class RetinaExample method execute.

private void execute(String[] args) throws Exception {
    BufferedImage bufferedImage = args.length >= 1 ? ImageIO.read(new File(args[0])) : ImageIO.read(this.getClass().getResourceAsStream("BlackBalls.jpg"));
    System.out.println("Image type: " + bufferedImage.getType());
    Mat matrix = new OpenCVFrameConverter.ToMat().convert(new Java2DFrameConverter().convert(bufferedImage));
    normalize(matrix, matrix, 0, 255, NORM_MINMAX, -1, noArray());
    showImage(matrix);
    matrix.convertTo(matrix, CV_32F);
    Mat gammaTransformedImage = new Mat(matrix.size(), CV_32F);
    pow(matrix, 1. / 5, gammaTransformedImage);
    Retina retina = createRetina(gammaTransformedImage.size());
    Mat retinaOutput_parvo = new Mat();
    Mat retinaOutput_magno = new Mat();
    retina.clearBuffers();
    retina.run(gammaTransformedImage);
    retina.getParvo(retinaOutput_parvo);
    retina.getMagno(retinaOutput_magno);
    showImage(retinaOutput_parvo);
    showImage(retinaOutput_magno);
}
Also used : OpenCVFrameConverter(org.bytedeco.javacv.OpenCVFrameConverter) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Java2DFrameConverter(org.bytedeco.javacv.Java2DFrameConverter)

Example 7 with Java2DFrameConverter

use of org.bytedeco.javacv.Java2DFrameConverter in project javacv by bytedeco.

the class BioInspiredRetina method execute.

private void execute(String[] args) throws Exception {
    BufferedImage bufferedImage = args.length >= 1 ? ImageIO.read(new File(args[0])) : ImageIO.read(this.getClass().getResourceAsStream("BlackBalls.jpg"));
    System.out.println("Image type: " + bufferedImage.getType());
    Mat matrix = new OpenCVFrameConverter.ToMat().convert(new Java2DFrameConverter().convert(bufferedImage));
    normalize(matrix, matrix, 0, 255, NORM_MINMAX, -1, noArray());
    showImage(matrix);
    matrix.convertTo(matrix, CV_32F);
    Mat gammaTransformedImage = new Mat(matrix.size(), CV_32F);
    pow(matrix, 1. / 5, gammaTransformedImage);
    Retina retina = Retina.create(gammaTransformedImage.size());
    Mat retinaOutput_parvo = new Mat();
    Mat retinaOutput_magno = new Mat();
    retina.clearBuffers();
    retina.run(gammaTransformedImage);
    retina.getParvo(retinaOutput_parvo);
    retina.getMagno(retinaOutput_magno);
    showImage(retinaOutput_parvo);
    showImage(retinaOutput_magno);
}
Also used : OpenCVFrameConverter(org.bytedeco.javacv.OpenCVFrameConverter) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Java2DFrameConverter(org.bytedeco.javacv.Java2DFrameConverter)

Aggregations

Java2DFrameConverter (org.bytedeco.javacv.Java2DFrameConverter)7 BufferedImage (java.awt.image.BufferedImage)6 OpenCVFrameConverter (org.bytedeco.javacv.OpenCVFrameConverter)6 File (java.io.File)5 StatusResult (org.brunocvcunha.instagram4j.requests.payload.StatusResult)1 CanvasFrame (org.bytedeco.javacv.CanvasFrame)1 FFmpegFrameGrabber (org.bytedeco.javacv.FFmpegFrameGrabber)1