All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flash3388.flashlib.vision.cv.processing.RectProcessor Maven / Gradle / Ivy

package com.flash3388.flashlib.vision.cv.processing;

import com.flash3388.flashlib.vision.cv.CvHelper;
import com.flash3388.flashlib.vision.cv.CvImage;
import com.flash3388.flashlib.vision.processing.Processor;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Rect;
import org.opencv.imgproc.Imgproc;

import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;

public class RectProcessor implements Processor> {

    private final Predicate mRectFilter;

    public RectProcessor(Predicate rectFilter) {
        mRectFilter = rectFilter;
    }

    @Override
    public Stream process(CvImage image) {
        List contours = CvHelper.detectContours(image);
        return contours.stream()
                .map(Imgproc::boundingRect)
                .filter(mRectFilter);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy