Search in sources :

Example 1 with Point2fVector

use of org.bytedeco.opencv.opencv_core.Point2fVector in project qupath by qupath.

the class DnnTools method detectKeypointsROI.

/**
 * TODO: Non-public placeholder until better designed/validated - subject to change
 * @param model
 * @param mat
 * @param request
 * @param mask
 * @param threshold
 * @return
 */
static ROI detectKeypointsROI(KeypointsModel model, Mat mat, RegionRequest request, ROI mask, double threshold) {
    float thresh = (float) threshold;
    Point2fVector output;
    synchronized (model) {
        output = model.estimate(mat, thresh);
    }
    double downsample = request.getDownsample();
    double xOrigin = request.getX();
    double yOrigin = request.getY();
    var pointsArray = output.get();
    var points = new ArrayList<Point2>();
    for (var p : pointsArray) {
        double x = xOrigin + p.x() * downsample;
        double y = yOrigin + p.y() * downsample;
        // TODO: Consider IndexedPointInAreaLocator if needed for performance
        if (mask == null || mask.contains(x, y))
            points.add(new Point2(x, y));
    }
    return ROIs.createPointsROI(points, request.getPlane());
}
Also used : Point2(qupath.lib.geom.Point2) ArrayList(java.util.ArrayList) Point2fVector(org.bytedeco.opencv.opencv_core.Point2fVector)

Aggregations

ArrayList (java.util.ArrayList)1 Point2fVector (org.bytedeco.opencv.opencv_core.Point2fVector)1 Point2 (qupath.lib.geom.Point2)1