Class ImageConverter


  • public final class ImageConverter
    extends java.lang.Object
    Utility class for creating a JavaFX image from an OpenCV image. This used by the preview views to render an image in the GUI.
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageConverter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.scene.image.Image convert​(MatWrapper wrapper)  
      javafx.scene.image.Image convert​(org.bytedeco.javacpp.opencv_core.Mat mat)
      Convert a BGR-formatted OpenCV opencv_core.Mat into a JavaFX Image.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageConverter

        public ImageConverter()
    • Method Detail

      • convert

        public javafx.scene.image.Image convert​(MatWrapper wrapper)
      • convert

        public javafx.scene.image.Image convert​(org.bytedeco.javacpp.opencv_core.Mat mat)
        Convert a BGR-formatted OpenCV opencv_core.Mat into a JavaFX Image. JavaFX understands ARGB pixel data, so one way to turn a Mat into a JavaFX image is to shift around the bytes from the Mat into an int array of pixels. This is also possible to do by using JavaCV, but the JavaCV method involves several intermediate conversions (Mat -> Frame -> BufferedImage -> JavaFX Image) and is way too slow to use for a real-time video.
        Parameters:
        mat - An 8-bit OpenCV Mat containing an image with either 1 or 3 channels
        Returns:
        A JavaFX image, or null for empty