Package edu.wpi.grip.ui.util
Class ImageConverter
- java.lang.Object
-
- edu.wpi.grip.ui.util.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 OpenCVopencv_core.Mat
into a JavaFXImage
.
-
-
-
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 OpenCVopencv_core.Mat
into a JavaFXImage
. 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
-
-