org.opencv.core.MatOfPoint Java Examples

The following examples show how to use org.opencv.core.MatOfPoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RatioScorer.java    From DogeCV with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param input - Input mat (Can be MatOfPoint for contours)
 * @return - Difference from perfect score
 */
@Override
public double calculateScore(Mat input) {
    if(!(input instanceof MatOfPoint)) return Double.MAX_VALUE;
    MatOfPoint contour = (MatOfPoint) input;
    double score = Double.MAX_VALUE;

    // Get bounding rect of contour
    Rect rect = Imgproc.boundingRect(contour);
    double x = rect.x;
    double y = rect.y;
    double w = rect.width;
    double h = rect.height;

    double cubeRatio = Math.max(Math.abs(h/w), Math.abs(w/h)); // Get the ratio. We use max in case h and w get swapped??? it happens when u account for rotation
    double ratioDiffrence = Math.abs(cubeRatio - perfectRatio);
    return ratioDiffrence * weight;
}
 
Example #2
Source File: Converters.java    From OpenCV-AndroidSamples with MIT License 6 votes vote down vote up
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) {
    if (pts == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");

    if (m == null)
        throw new java.lang.IllegalArgumentException("Input Mat can't be null");

    List<Mat> mats = new ArrayList<Mat>(m.rows());
    Mat_to_vector_Mat(m, mats);
    for (Mat mi : mats) {
        MatOfPoint pt = new MatOfPoint(mi);
        pts.add(pt);
        mi.release();
    }
    mats.clear();
}
 
Example #3
Source File: Converters.java    From MOAAP with MIT License 6 votes vote down vote up
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) {
    if (pts == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");

    if (m == null)
        throw new java.lang.IllegalArgumentException("Input Mat can't be null");

    List<Mat> mats = new ArrayList<Mat>(m.rows());
    Mat_to_vector_Mat(m, mats);
    for (Mat mi : mats) {
        MatOfPoint pt = new MatOfPoint(mi);
        pts.add(pt);
        mi.release();
    }
    mats.clear();
}
 
Example #4
Source File: HOGDescriptor.java    From MOAAP with MIT License 5 votes vote down vote up
public  void detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride, Size padding, MatOfPoint searchLocations)
{
    Mat foundLocations_mat = foundLocations;
    Mat weights_mat = weights;
    Mat searchLocations_mat = searchLocations;
    detect_0(nativeObj, img.nativeObj, foundLocations_mat.nativeObj, weights_mat.nativeObj, hitThreshold, winStride.width, winStride.height, padding.width, padding.height, searchLocations_mat.nativeObj);
    
    return;
}
 
Example #5
Source File: Imgproc.java    From faceswap with Apache License 2.0 5 votes vote down vote up
public static void ellipse2Poly(Point center, Size axes, int angle, int arcStart, int arcEnd, int delta, MatOfPoint pts)
{
    Mat pts_mat = pts;
    ellipse2Poly_0(center.x, center.y, axes.width, axes.height, angle, arcStart, arcEnd, delta, pts_mat.nativeObj);
    
    return;
}
 
Example #6
Source File: Imgproc.java    From LicensePlateDiscern with MIT License 5 votes vote down vote up
public static void drawContours(Mat image, List<MatOfPoint> contours, int contourIdx, Scalar color, int thickness, int lineType, Mat hierarchy, int maxLevel, Point offset)
{
    List<Mat> contours_tmplm = new ArrayList<Mat>((contours != null) ? contours.size() : 0);
    Mat contours_mat = Converters.vector_vector_Point_to_Mat(contours, contours_tmplm);
    drawContours_0(image.nativeObj, contours_mat.nativeObj, contourIdx, color.val[0], color.val[1], color.val[2], color.val[3], thickness, lineType, hierarchy.nativeObj, maxLevel, offset.x, offset.y);
    
    return;
}
 
Example #7
Source File: Imgproc.java    From OpenCV-Android-Object-Detection with MIT License 5 votes vote down vote up
public static void convexHull(MatOfPoint points, MatOfInt hull)
{
    Mat points_mat = points;
    Mat hull_mat = hull;
    convexHull_1(points_mat.nativeObj, hull_mat.nativeObj);
    
    return;
}
 
Example #8
Source File: Imgproc.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static void drawContours(Mat image, List<MatOfPoint> contours, int contourIdx, Scalar color, int thickness, int lineType, Mat hierarchy, int maxLevel, Point offset)
{
    List<Mat> contours_tmplm = new ArrayList<Mat>((contours != null) ? contours.size() : 0);
    Mat contours_mat = Converters.vector_vector_Point_to_Mat(contours, contours_tmplm);
    drawContours_0(image.nativeObj, contours_mat.nativeObj, contourIdx, color.val[0], color.val[1], color.val[2], color.val[3], thickness, lineType, hierarchy.nativeObj, maxLevel, offset.x, offset.y);
    
    return;
}
 
Example #9
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static Rect boundingRect(MatOfPoint points)
{
    Mat points_mat = points;
    Rect retVal = new Rect(boundingRect_0(points_mat.nativeObj));
    
    return retVal;
}
 
Example #10
Source File: Imgproc.java    From sudokufx with Apache License 2.0 5 votes vote down vote up
public static void fillConvexPoly(Mat img, MatOfPoint points, Scalar color)
{
    Mat points_mat = points;
    fillConvexPoly_1(img.nativeObj, points_mat.nativeObj, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example #11
Source File: HOGDescriptor.java    From react-native-documentscanner-android with MIT License 5 votes vote down vote up
public  void detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride, Size padding, MatOfPoint searchLocations)
{
    Mat foundLocations_mat = foundLocations;
    Mat weights_mat = weights;
    Mat searchLocations_mat = searchLocations;
    detect_0(nativeObj, img.nativeObj, foundLocations_mat.nativeObj, weights_mat.nativeObj, hitThreshold, winStride.width, winStride.height, padding.width, padding.height, searchLocations_mat.nativeObj);
    
    return;
}
 
Example #12
Source File: Imgproc.java    From Camdroid with Apache License 2.0 5 votes vote down vote up
public static void polylines(Mat img, List<MatOfPoint> pts, boolean isClosed, Scalar color)
{
    List<Mat> pts_tmplm = new ArrayList<Mat>((pts != null) ? pts.size() : 0);
    Mat pts_mat = Converters.vector_vector_Point_to_Mat(pts, pts_tmplm);
    polylines_2(img.nativeObj, pts_mat.nativeObj, isClosed, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example #13
Source File: Converters.java    From ResistorScanner with MIT License 5 votes vote down vote up
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) {
    if (pts == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");

    if (m == null)
        throw new java.lang.IllegalArgumentException("Input Mat can't be null");

    List<Mat> mats = new ArrayList<Mat>(m.rows());
    Mat_to_vector_Mat(m, mats);
    for (Mat mi : mats) {
        MatOfPoint pt = new MatOfPoint(mi);
        pts.add(pt);
    }
}
 
Example #14
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static Rect boundingRect(MatOfPoint points)
{
    Mat points_mat = points;
    Rect retVal = new Rect(boundingRect_0(points_mat.nativeObj));
    
    return retVal;
}
 
Example #15
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static void polylines(Mat img, List<MatOfPoint> pts, boolean isClosed, Scalar color)
{
    List<Mat> pts_tmplm = new ArrayList<Mat>((pts != null) ? pts.size() : 0);
    Mat pts_mat = Converters.vector_vector_Point_to_Mat(pts, pts_tmplm);
    polylines_2(img.nativeObj, pts_mat.nativeObj, isClosed, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example #16
Source File: Imgproc.java    From SimpleDocumentScanner-Android with MIT License 5 votes vote down vote up
public static void fillPoly(Mat img, List<MatOfPoint> pts, Scalar color)
{
    List<Mat> pts_tmplm = new ArrayList<Mat>((pts != null) ? pts.size() : 0);
    Mat pts_mat = Converters.vector_vector_Point_to_Mat(pts, pts_tmplm);
    fillPoly_1(img.nativeObj, pts_mat.nativeObj, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example #17
Source File: HOGDescriptor.java    From SmartPaperScan with Apache License 2.0 5 votes vote down vote up
public  void compute(Mat img, MatOfFloat descriptors, Size winStride, Size padding, MatOfPoint locations)
{
    Mat descriptors_mat = descriptors;
    Mat locations_mat = locations;
    compute_0(nativeObj, img.nativeObj, descriptors_mat.nativeObj, winStride.width, winStride.height, padding.width, padding.height, locations_mat.nativeObj);
    
    return;
}
 
Example #18
Source File: Imgproc.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static void drawContours(Mat image, List<MatOfPoint> contours, int contourIdx, Scalar color)
{
    List<Mat> contours_tmplm = new ArrayList<Mat>((contours != null) ? contours.size() : 0);
    Mat contours_mat = Converters.vector_vector_Point_to_Mat(contours, contours_tmplm);
    drawContours_2(image.nativeObj, contours_mat.nativeObj, contourIdx, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example #19
Source File: Imgproc.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static Rect boundingRect(MatOfPoint points)
{
    Mat points_mat = points;
    Rect retVal = new Rect(boundingRect_0(points_mat.nativeObj));
    
    return retVal;
}
 
Example #20
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static void convexHull(MatOfPoint points, MatOfInt hull)
{
    Mat points_mat = points;
    Mat hull_mat = hull;
    convexHull_1(points_mat.nativeObj, hull_mat.nativeObj);
    
    return;
}
 
Example #21
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static void polylines(Mat img, List<MatOfPoint> pts, boolean isClosed, Scalar color, int thickness)
{
    List<Mat> pts_tmplm = new ArrayList<Mat>((pts != null) ? pts.size() : 0);
    Mat pts_mat = Converters.vector_vector_Point_to_Mat(pts, pts_tmplm);
    polylines_1(img.nativeObj, pts_mat.nativeObj, isClosed, color.val[0], color.val[1], color.val[2], color.val[3], thickness);
    
    return;
}
 
Example #22
Source File: Imgproc.java    From OpenCV-AndroidSamples with MIT License 5 votes vote down vote up
public static void fillPoly(Mat img, List<MatOfPoint> pts, Scalar color)
{
    List<Mat> pts_tmplm = new ArrayList<Mat>((pts != null) ? pts.size() : 0);
    Mat pts_mat = Converters.vector_vector_Point_to_Mat(pts, pts_tmplm);
    fillPoly_1(img.nativeObj, pts_mat.nativeObj, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example #23
Source File: HOGDescriptor.java    From LPR with Apache License 2.0 5 votes vote down vote up
public  void detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride, Size padding, MatOfPoint searchLocations)
{
    Mat foundLocations_mat = foundLocations;
    Mat weights_mat = weights;
    Mat searchLocations_mat = searchLocations;
    detect_0(nativeObj, img.nativeObj, foundLocations_mat.nativeObj, weights_mat.nativeObj, hitThreshold, winStride.width, winStride.height, padding.width, padding.height, searchLocations_mat.nativeObj);
    
    return;
}
 
Example #24
Source File: Imgproc.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static void goodFeaturesToTrack(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize, boolean useHarrisDetector, double k)
{
    Mat corners_mat = corners;
    goodFeaturesToTrack_0(image.nativeObj, corners_mat.nativeObj, maxCorners, qualityLevel, minDistance, mask.nativeObj, blockSize, useHarrisDetector, k);
    
    return;
}
 
Example #25
Source File: Imgproc.java    From Document-Scanner with GNU General Public License v3.0 5 votes vote down vote up
public static void drawContours(Mat image, List<MatOfPoint> contours, int contourIdx, Scalar color, int thickness, int lineType, Mat hierarchy, int maxLevel, Point offset)
{
    List<Mat> contours_tmplm = new ArrayList<Mat>((contours != null) ? contours.size() : 0);
    Mat contours_mat = Converters.vector_vector_Point_to_Mat(contours, contours_tmplm);
    drawContours_0(image.nativeObj, contours_mat.nativeObj, contourIdx, color.val[0], color.val[1], color.val[2], color.val[3], thickness, lineType, hierarchy.nativeObj, maxLevel, offset.x, offset.y);
    
    return;
}
 
Example #26
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static boolean isContourConvex(MatOfPoint contour)
{
    Mat contour_mat = contour;
    boolean retVal = isContourConvex_0(contour_mat.nativeObj);
    
    return retVal;
}
 
Example #27
Source File: Imgproc.java    From LPR with Apache License 2.0 5 votes vote down vote up
public static void polylines(Mat img, List<MatOfPoint> pts, boolean isClosed, Scalar color)
{
    List<Mat> pts_tmplm = new ArrayList<Mat>((pts != null) ? pts.size() : 0);
    Mat pts_mat = Converters.vector_vector_Point_to_Mat(pts, pts_tmplm);
    polylines_3(img.nativeObj, pts_mat.nativeObj, isClosed, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example #28
Source File: Imgproc.java    From FaceDetectDemo with Apache License 2.0 5 votes vote down vote up
public static void fillConvexPoly(Mat img, MatOfPoint points, Scalar color, int lineType, int shift)
{
    Mat points_mat = points;
    fillConvexPoly_0(img.nativeObj, points_mat.nativeObj, color.val[0], color.val[1], color.val[2], color.val[3], lineType, shift);
    
    return;
}
 
Example #29
Source File: MainActivity.java    From MOAAP with MIT License 5 votes vote down vote up
private void resetVars(){
    mPrevGray = new Mat(mGray.rows(), mGray.cols(), CvType.CV_8UC1);
    features = new MatOfPoint();
    prevFeatures = new MatOfPoint2f();
    nextFeatures = new MatOfPoint2f();
    status = new MatOfByte();
    err = new MatOfFloat();
}
 
Example #30
Source File: HOGDescriptor.java    From LicensePlateDiscern with MIT License 5 votes vote down vote up
public  void compute(Mat img, MatOfFloat descriptors, Size winStride, Size padding, MatOfPoint locations)
{
    Mat descriptors_mat = descriptors;
    Mat locations_mat = locations;
    compute_0(nativeObj, img.nativeObj, descriptors_mat.nativeObj, winStride.width, winStride.height, padding.width, padding.height, locations_mat.nativeObj);
    
    return;
}