Java Code Examples for org.opencv.core.Point

The following are top voted examples for showing how to use org.opencv.core.Point. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Auto.js   File: ColorFinder.java   View source code 6 votes vote down vote up
public static Point[] findAllColors(ImageWrapper image, int color, int threshold, Rect rect) {
    Mat bi = new Mat();
    Scalar lowerBound = new Scalar(Color.red(color) - threshold, Color.green(color) - threshold,
            Color.blue(color) - threshold, 255);
    Scalar upperBound = new Scalar(Color.red(color) + threshold, Color.green(color) + threshold,
            Color.blue(color) + threshold, 255);
    if (rect != null) {
        Core.inRange(new Mat(image.getMat(), rect), lowerBound, upperBound, bi);
    } else {
        Core.inRange(image.getMat(), lowerBound, upperBound, bi);
    }
    Mat nonZeroPos = new Mat();
    Core.findNonZero(bi, nonZeroPos);
    if (nonZeroPos.rows() == 0 || nonZeroPos.cols() == 0) {
        return new Point[0];
    }
    Point[] points = new MatOfPoint(nonZeroPos).toArray();
    if (rect != null) {
        for (int i = 0; i < points.length; i++) {
            points[i].x += rect.x;
            points[i].y += rect.y;
        }
    }
    return points;
}
 
Example 2
Project: DNNLibrary   File: Imgproc.java   View source code 5 votes vote down vote up
public static Point phaseCorrelate(Mat src1, Mat src2, Mat window, double[] response)
{
    double[] response_out = new double[1];
    Point retVal = new Point(phaseCorrelate_0(src1.nativeObj, src2.nativeObj, window.nativeObj, response_out));
    if(response!=null) response[0] = (double)response_out[0];
    return retVal;
}
 
Example 3
Project: mao-android   File: Imgproc.java   View source code 5 votes vote down vote up
public static void findContours(Mat image, List<MatOfPoint> contours, Mat hierarchy, int mode, int method, Point offset)
{
    Mat contours_mat = new Mat();
    findContours_0(image.nativeObj, contours_mat.nativeObj, hierarchy.nativeObj, mode, method, offset.x, offset.y);
    Converters.Mat_to_vector_vector_Point(contours_mat, contours);
    contours_mat.release();
    return;
}
 
Example 4
Project: react-native-scan-doc   File: Imgproc.java   View source code 5 votes vote down vote up
public static Point phaseCorrelate(Mat src1, Mat src2, Mat window, double[] response)
{
    double[] response_out = new double[1];
    Point retVal = new Point(phaseCorrelate_0(src1.nativeObj, src2.nativeObj, window.nativeObj, response_out));
    if(response!=null) response[0] = (double)response_out[0];
    return retVal;
}
 
Example 5
Project: FTC2016   File: Drawing.java   View source code 5 votes vote down vote up
public static void drawText(Mat img, String text, Point origin, float scale, Color color, Anchor locationOnImage) {
    if (locationOnImage == Anchor.BOTTOMLEFT)
        Transform.flip(img, Transform.FlipType.FLIP_ACROSS_Y);
    Imgproc.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, scale, color.getScalarRGBA(), 2, Core.LINE_8,
            (locationOnImage == Anchor.BOTTOMLEFT || locationOnImage == Anchor.BOTTOMLEFT_UNFLIPPED_Y));
    if (locationOnImage == Anchor.BOTTOMLEFT)
        Transform.flip(img, Transform.FlipType.FLIP_ACROSS_Y);
}
 
Example 6
Project: FTC2016   File: Ellipse.java   View source code 5 votes vote down vote up
/**
 * Transpose this rectangle so that x becomes y and vice versa
 *
 * @return Transposed rectangle instance
 */
@SuppressWarnings("SuspiciousNameCombination")
public Ellipse transpose() {
    return new Ellipse(new RotatedRect(
            new Point(rect.center.y, rect.center.x),
            new Size(rect.size.height, rect.size.width), rect.angle));
}
 
Example 7
Project: MOAAP   File: Subdiv2D.java   View source code 5 votes vote down vote up
public  int edgeDst(int edge, Point dstpt)
{
    double[] dstpt_out = new double[2];
    int retVal = edgeDst_0(nativeObj, edge, dstpt_out);
    if(dstpt!=null){ dstpt.x = dstpt_out[0]; dstpt.y = dstpt_out[1]; } 
    return retVal;
}
 
Example 8
Project: OpenCV_Android_Plus   File: Subdiv2D.java   View source code 5 votes vote down vote up
public  int edgeOrg(int edge, Point orgpt)
{
    double[] orgpt_out = new double[2];
    int retVal = edgeOrg_0(nativeObj, edge, orgpt_out);
    if(orgpt!=null){ orgpt.x = orgpt_out[0]; orgpt.y = orgpt_out[1]; }
    return retVal;
}
 
Example 9
Project: Android-Code-Demos   File: Imgproc.java   View source code 5 votes vote down vote up
public static Point phaseCorrelate(Mat src1, Mat src2, Mat window, double[] response)
{
    double[] response_out = new double[1];
    Point retVal = new Point(phaseCorrelate_0(src1.nativeObj, src2.nativeObj, window.nativeObj, response_out));
    if(response!=null) response[0] = (double)response_out[0];
    return retVal;
}
 
Example 10
Project: DogeCV   File: Points.java   View source code 5 votes vote down vote up
public static Point getMeanPoint(List<Point> points) {
    if (points.size() == 0) return null;
    double x = 0;
    double y = 0;
    for(Point point : points) {
        x += Math.pow(point.x, 2);
        y += Math.pow(point.y, 2);
    }
    return new Point(Math.sqrt(x/points.size()), Math.sqrt(y/points.size()));
}
 
Example 11
Project: DNNLibrary   File: Subdiv2D.java   View source code 5 votes vote down vote up
public  int locate(Point pt, int[] edge, int[] vertex)
{
    double[] edge_out = new double[1];
    double[] vertex_out = new double[1];
    int retVal = locate_0(nativeObj, pt.x, pt.y, edge_out, vertex_out);
    if(edge!=null) edge[0] = (int)edge_out[0];
    if(vertex!=null) vertex[0] = (int)vertex_out[0];
    return retVal;
}
 
Example 12
Project: renderscript_examples   File: Subdiv2D.java   View source code 5 votes vote down vote up
public  Point getVertex(int vertex, int[] firstEdge)
{
    double[] firstEdge_out = new double[1];
    Point retVal = new Point(getVertex_0(nativeObj, vertex, firstEdge_out));
    if(firstEdge!=null) firstEdge[0] = (int)firstEdge_out[0];
    return retVal;
}
 
Example 13
Project: MOAAP   File: Imgproc.java   View source code 5 votes vote down vote up
public static void minEnclosingCircle(MatOfPoint2f points, Point center, float[] radius)
{
    Mat points_mat = points;
    double[] center_out = new double[2];
    double[] radius_out = new double[1];
    minEnclosingCircle_0(points_mat.nativeObj, center_out, radius_out);
    if(center!=null){ center.x = center_out[0]; center.y = center_out[1]; } 
    if(radius!=null) radius[0] = (float)radius_out[0];
    return;
}
 
Example 14
Project: TinyPlanetMaker   File: Subdiv2D.java   View source code 5 votes vote down vote up
public  int edgeOrg(int edge, Point orgpt)
{
    double[] orgpt_out = new double[2];
    int retVal = edgeOrg_0(nativeObj, edge, orgpt_out);
    if(orgpt!=null){ orgpt.x = orgpt_out[0]; orgpt.y = orgpt_out[1]; }
    return retVal;
}
 
Example 15
Project: mao-android   File: KeyPoint.java   View source code 5 votes vote down vote up
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id)
{
    pt = new Point(x, y);
    size = _size;
    angle = _angle;
    response = _response;
    octave = _octave;
    class_id = _class_id;
}
 
Example 16
Project: renderscript_examples   File: Subdiv2D.java   View source code 5 votes vote down vote up
public  int findNearest(Point pt, Point nearestPt)
{
    double[] nearestPt_out = new double[2];
    int retVal = findNearest_0(nativeObj, pt.x, pt.y, nearestPt_out);
    if(nearestPt!=null){ nearestPt.x = nearestPt_out[0]; nearestPt.y = nearestPt_out[1]; } 
    return retVal;
}
 
Example 17
Project: Team9261-2017-2018   File: Imgproc.java   View source code 5 votes vote down vote up
public static Point phaseCorrelate(Mat src1, Mat src2, Mat window, double[] response)
{
    double[] response_out = new double[1];
    Point retVal = new Point(phaseCorrelate_0(src1.nativeObj, src2.nativeObj, window.nativeObj, response_out));
    if(response!=null) response[0] = (double)response_out[0];
    return retVal;
}
 
Example 18
Project: AndroidCameraSudokuSolver   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point2f_to_Mat(List<Point> pts) {
    return vector_Point_to_Mat(pts, CvType.CV_32F);
}
 
Example 19
Project: TinyPlanetMaker   File: Converters.java   View source code 4 votes vote down vote up
public static void Mat_to_vector_Point2f(Mat m, List<Point> pts) {
    Mat_to_vector_Point(m, pts);
}
 
Example 20
Project: Checkerboard-IMU-Comparator   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point_to_Mat(List<Point> pts) {
    return vector_Point_to_Mat(pts, CvType.CV_32S);
}
 
Example 21
Project: DogeCV   File: Line.java   View source code 4 votes vote down vote up
public Point center() {
    return new Point((int) (0.5*(x1 + x2)),(int) (0.5*(y1 + y2)));
}
 
Example 22
Project: android-imaging-utils   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point2d_to_Mat(List<Point> pts) {
    return vector_Point_to_Mat(pts, CvType.CV_64F);
}
 
Example 23
Project: MOAAP   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point2f_to_Mat(List<Point> pts) {
    return vector_Point_to_Mat(pts, CvType.CV_32F);
}
 
Example 24
Project: Team9261-2017-2018   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point2f_to_Mat(List<Point> pts) {
    return vector_Point_to_Mat(pts, CvType.CV_32F);
}
 
Example 25
Project: android-things-drawbot   File: Line.java   View source code 4 votes vote down vote up
public Point getPoint1() {
    return mPoint1;
}
 
Example 26
Project: Android-Crop-Receipt   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point2f_to_Mat(List<Point> pts) {
    return vector_Point_to_Mat(pts, CvType.CV_32F);
}
 
Example 27
Project: RobotIGS   File: MathUtil.java   View source code 3 votes vote down vote up
/**
 * Calculate the angle between three points
 *
 * @param pt1 Vector 1
 * @param pt2 Vector 2
 * @param pt0 Vector 0
 * @return The angle (cosine) between the points
 */
public static double angle(Point pt1, Point pt2, Point pt0) {
    double dx1 = pt1.x - pt0.x;
    double dy1 = pt1.y - pt0.y;
    double dx2 = pt2.x - pt0.x;
    double dy2 = pt2.y - pt0.y;
    return (dx1 * dx2 + dy1 * dy2) / Math.sqrt((dx1 * dx1 + dy1 * dy1) * (dx2 * dx2 + dy2 * dy2) + 1e-10);
}
 
Example 28
Project: renderscript_examples   File: Subdiv2D.java   View source code 3 votes vote down vote up
public  int insert(Point pt)
{
    
    int retVal = insert_0(nativeObj, pt.x, pt.y);
    
    return retVal;
}
 
Example 29
Project: android-imaging-utils   File: Imgproc.java   View source code 3 votes vote down vote up
public static void erode(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue)
{
    
    erode_0(src.nativeObj, dst.nativeObj, kernel.nativeObj, anchor.x, anchor.y, iterations, borderType, borderValue.val[0], borderValue.val[1], borderValue.val[2], borderValue.val[3]);
    
    return;
}
 
Example 30
Project: fingerblox   File: Imgproc.java   View source code 3 votes vote down vote up
public static void arrowedLine(Mat img, Point pt1, Point pt2, Scalar color)
{
    
    arrowedLine_1(img.nativeObj, pt1.x, pt1.y, pt2.x, pt2.y, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example 31
Project: Sikulix2opencv   File: Imgproc.java   View source code 3 votes vote down vote up
public static Point phaseCorrelate(Mat src1, Mat src2)
{
    
    Point retVal = new Point(phaseCorrelate_1(src1.nativeObj, src2.nativeObj));
    
    return retVal;
}
 
Example 32
Project: MOAAP   File: Imgproc.java   View source code 3 votes vote down vote up
public static void erode(Mat src, Mat dst, Mat kernel, Point anchor, int iterations)
{
    
    erode_1(src.nativeObj, dst.nativeObj, kernel.nativeObj, anchor.x, anchor.y, iterations);
    
    return;
}
 
Example 33
Project: FTC2016   File: Imgproc.java   View source code 3 votes vote down vote up
public static void line(Mat img, Point pt1, Point pt2, Scalar color)
{
    
    line_2(img.nativeObj, pt1.x, pt1.y, pt2.x, pt2.y, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example 34
Project: Microsphere   File: Imgproc.java   View source code 3 votes vote down vote up
public static void ellipse(Mat img, Point center, Size axes, double angle, double startAngle, double endAngle, Scalar color)
{
    
    ellipse_2(img.nativeObj, center.x, center.y, axes.width, axes.height, angle, startAngle, endAngle, color.val[0], color.val[1], color.val[2], color.val[3]);
    
    return;
}
 
Example 35
Project: DNNLibrary   File: Imgproc.java   View source code 3 votes vote down vote up
public static void arrowedLine(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int line_type, int shift, double tipLength)
{
    
    arrowedLine_0(img.nativeObj, pt1.x, pt1.y, pt2.x, pt2.y, color.val[0], color.val[1], color.val[2], color.val[3], thickness, line_type, shift, tipLength);
    
    return;
}
 
Example 36
Project: opencv-documentscanner-android   File: Imgproc.java   View source code 3 votes vote down vote up
public static void blur(Mat src, Mat dst, Size ksize, Point anchor)
{
    
    blur_1(src.nativeObj, dst.nativeObj, ksize.width, ksize.height, anchor.x, anchor.y);
    
    return;
}
 
Example 37
Project: FTC2016   File: Imgproc.java   View source code 3 votes vote down vote up
public static void sqrBoxFilter(Mat _src, Mat _dst, int ddepth, Size ksize, Point anchor, boolean normalize)
{
    
    sqrBoxFilter_1(_src.nativeObj, _dst.nativeObj, ddepth, ksize.width, ksize.height, anchor.x, anchor.y, normalize);
    
    return;
}
 
Example 38
Project: NotifyTools   File: Imgproc.java   View source code 3 votes vote down vote up
public static void sepFilter2D(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor, double delta, int borderType)
{
    
    sepFilter2D_0(src.nativeObj, dst.nativeObj, ddepth, kernelX.nativeObj, kernelY.nativeObj, anchor.x, anchor.y, delta, borderType);
    
    return;
}
 
Example 39
Project: FaceDetectDemo   File: Imgproc.java   View source code 3 votes vote down vote up
public static void ellipse(Mat img, Point center, Size axes, double angle, double startAngle, double endAngle, Scalar color, int thickness)
{
    
    ellipse_1(img.nativeObj, center.x, center.y, axes.width, axes.height, angle, startAngle, endAngle, color.val[0], color.val[1], color.val[2], color.val[3], thickness);
    
    return;
}
 
Example 40
Project: renderscript_examples   File: Imgproc.java   View source code 3 votes vote down vote up
public static void erode(Mat src, Mat dst, Mat kernel, Point anchor, int iterations)
{
    
    erode_1(src.nativeObj, dst.nativeObj, kernel.nativeObj, anchor.x, anchor.y, iterations);
    
    return;
}