Class OpenCVGridbasedPositionEvaluator

  • All Implemented Interfaces:
    GridbasedPositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>, PositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>

    public class OpenCVGridbasedPositionEvaluator
    extends Object
    implements GridbasedPositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>

    OpenCV Implementation of the GridbasedPositionEvaluator Interface which provides functionality to evaluate e.g. the position of an object in the image based on a given grid for calibration

    Since:
    1.0
    Author:
    Christoph Praschl
    • Constructor Detail

      • OpenCVGridbasedPositionEvaluator

        public OpenCVGridbasedPositionEvaluator()
    • Method Detail

      • setReferenceImage

        public void setReferenceImage​(ImageWrapper<org.opencv.core.Mat> referenceImage)
        Specified by:
        setReferenceImage in interface GridbasedPositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>
        Parameters:
        referenceImage - Reference image which is used to determine the position of an object
      • getAffectedTile

        public JavaPolygon2D getAffectedTile​(Point2Wrapper<org.opencv.core.Point> position)
        Gets the tile which contains the given position.
        Specified by:
        getAffectedTile in interface GridbasedPositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>
        Parameters:
        position - The position for which the tile should be returned
        Returns:
        The tile containing the position; Or null if position is not on a tile.
      • getTileIndex

        public Point2Wrapper<org.opencv.core.Point> getTileIndex​(JavaPolygon2D tile)
        Gets the x and y index of the given tile
        Specified by:
        getTileIndex in interface GridbasedPositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>
        Parameters:
        tile - Tile for which index should be returned
        Returns:
        The index of the tile or an index -1/-1 if tile was not found
      • calibrate

        public void calibrate​(ImageWrapper<org.opencv.core.Mat> imageForCalibration)
        Method for calibrating the PositionEvaluator
        Specified by:
        calibrate in interface PositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>
        Parameters:
        imageForCalibration - Image used for calibration containing the grid.
      • getPosition

        public Point2Wrapper<org.opencv.core.Point> getPosition​(ImageWrapper<org.opencv.core.Mat> image)
        Method for evaluating e.g. the position of an object in the image
        Specified by:
        getPosition in interface PositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>
        Parameters:
        image - Image where Object should be found.
        Returns:
        Position of the Object in the image (Position -1/-1 -> no position found)
      • getOffset

        public TranslationOffsetInMM getOffset​(ImageWrapper<org.opencv.core.Mat> ref,
                                               ImageWrapper<org.opencv.core.Mat> current)
        Method for evaluating the offset of an object between two images
        Specified by:
        getOffset in interface PositionEvaluator<org.opencv.core.Mat,​org.opencv.core.Point>
        Parameters:
        ref - The reference image containing the object
        current - The current image containing the object
        Returns:
        The offset between the object´s position in ref and the object´s position in current