Class ComputerVision


  • public class ComputerVision
    extends java.lang.Object
    A set of OpenCV image filters. The parameters of the filter are:
    • MinFaceSize: Minimum face size to be considered ( one side of a bounding square)
    • MaxFaceSize: Maximum face size to be considered ( one side of a bounding square)
    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Elizabeth Osyk, based on FaceRecognizer by Ilga Akkaya
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (cxh)
    • Constructor Detail

      • ComputerVision

        public ComputerVision()
                       throws java.io.IOException
        Construct an instance of ComputerVision and load OpenCV.
        Throws:
        java.io.IOException - If the shared library cannot be loaded.
    • Method Detail

      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage source,
                                                   java.lang.String filterName)
                                            throws IllegalActionException
        Apply the specified filter to the source image.
        Parameters:
        source - The source image to transform.
        filterName - The name of the filter.
        Returns:
        The transformed image.
        Throws:
        IllegalActionException - If no filter is found or there is a problem filtering.
      • bufferedImage2Mat

        public org.opencv.core.Mat bufferedImage2Mat​(java.awt.image.BufferedImage source)
        Convert a BufferedImage object to OpenCV's Mat representation.
        Parameters:
        source - BufferedImage input
        Returns:
        Mat matrix
      • mat2BufferedImage

        public java.awt.image.BufferedImage mat2BufferedImage​(org.opencv.core.Mat matrix)
        Convert a Mat image into a BufferedImage.
        Parameters:
        matrix - Mat input
        Returns:
        BufferedImage output
      • setBlurSize

        public void setBlurSize​(int blurSize)
        Set the blur size. 1 to 25.
        Parameters:
        blurSize - The new blur size.
      • setCannyThreshold

        public void setCannyThreshold​(int threshold)
        Set the canny edge detection threshold. 10 to 150.
        Parameters:
        threshold - The new threshold
      • setErosionSize

        public void setErosionSize​(int erosionSize)
        Set the erosion size. 0 to 21.
        Parameters:
        erosionSize - The new erosion size.
      • toString

        public java.lang.String toString()
        Return a string description of the filter.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string "ComputerVisionFilter".