org.opencv.core.Point Java Examples
The following examples show how to use
org.opencv.core.Point.
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: Imgproc.java From LicensePlateDiscern with MIT License | 5 votes |
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 #2
Source File: PerspectiveTransformation.java From AndroidDocumentScanner with MIT License | 5 votes |
private Size getRectangleSize(MatOfPoint2f rectangle) { Point[] corners = rectangle.toArray(); double top = getDistance(corners[0], corners[1]); double right = getDistance(corners[1], corners[2]); double bottom = getDistance(corners[2], corners[3]); double left = getDistance(corners[3], corners[0]); double averageWidth = (top + bottom) / 2f; double averageHeight = (right + left) / 2f; return new Size(new Point(averageWidth, averageHeight)); }
Example #3
Source File: Subdiv2D.java From LPR with Apache License 2.0 | 5 votes |
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 #4
Source File: NativeClass.java From AndroidDocumentScanner with MIT License | 5 votes |
private boolean isRectangle(MatOfPoint2f polygon, int srcArea) { MatOfPoint polygonInt = MathUtils.toMatOfPointInt(polygon); if (polygon.rows() != 4) { return false; } double area = Math.abs(Imgproc.contourArea(polygon)); if (area < srcArea * AREA_LOWER_THRESHOLD || area > srcArea * AREA_UPPER_THRESHOLD) { return false; } if (!Imgproc.isContourConvex(polygonInt)) { return false; } // Check if the all angles are more than 72.54 degrees (cos 0.3). double maxCosine = 0; Point[] approxPoints = polygon.toArray(); for (int i = 2; i < 5; i++) { double cosine = Math.abs(MathUtils.angle(approxPoints[i % 4], approxPoints[i - 2], approxPoints[i - 1])); maxCosine = Math.max(cosine, maxCosine); } return !(maxCosine >= 0.3); }
Example #5
Source File: KeyPoint.java From VIA-AI with MIT License | 5 votes |
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 #6
Source File: PerspectiveTransformation.java From AndroidDocumentScanner with MIT License | 5 votes |
private Point getMassCenter(MatOfPoint2f points) { double xSum = 0; double ySum = 0; List<Point> pointList = points.toList(); int len = pointList.size(); for (Point point : pointList) { xSum += point.x; ySum += point.y; } return new Point(xSum / len, ySum / len); }
Example #7
Source File: Converters.java From VIA-AI with MIT License | 5 votes |
public static void Mat_to_vector_RotatedRect(Mat m, List<RotatedRect> rs) { if (rs == null) throw new java.lang.IllegalArgumentException("rs == null"); int count = m.rows(); if (CvType.CV_32FC(5) != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_32FC5 != m.type() || m.rows()!=1\n" + m); rs.clear(); float[] buff = new float[5 * count]; m.get(0, 0, buff); for (int i = 0; i < count; i++) { rs.add(new RotatedRect(new Point(buff[5 * i], buff[5 * i + 1]), new Size(buff[5 * i + 2], buff[5 * i + 3]), buff[5 * i + 4])); } }
Example #8
Source File: Imgproc.java From pasm-yolov3-Android with GNU General Public License v3.0 | 5 votes |
public static int floodFill(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff, Scalar upDiff, int flags) { double[] rect_out = new double[4]; int retVal = floodFill_0(image.nativeObj, mask.nativeObj, seedPoint.x, seedPoint.y, newVal.val[0], newVal.val[1], newVal.val[2], newVal.val[3], rect_out, loDiff.val[0], loDiff.val[1], loDiff.val[2], loDiff.val[3], upDiff.val[0], upDiff.val[1], upDiff.val[2], upDiff.val[3], flags); if(rect!=null){ rect.x = (int)rect_out[0]; rect.y = (int)rect_out[1]; rect.width = (int)rect_out[2]; rect.height = (int)rect_out[3]; } return retVal; }
Example #9
Source File: Converters.java From LPR with Apache License 2.0 | 5 votes |
public static void Mat_to_vector_RotatedRect(Mat m, List<RotatedRect> rs) { if (rs == null) throw new java.lang.IllegalArgumentException("rs == null"); int count = m.rows(); if (CvType.CV_32FC(5) != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_32FC5 != m.type() || m.rows()!=1\n" + m); rs.clear(); float[] buff = new float[5 * count]; m.get(0, 0, buff); for (int i = 0; i < count; i++) { rs.add(new RotatedRect(new Point(buff[5 * i], buff[5 * i + 1]), new Size(buff[5 * i + 2], buff[5 * i + 3]), buff[5 * i + 4])); } }
Example #10
Source File: Subdiv2D.java From LPR with Apache License 2.0 | 5 votes |
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 #11
Source File: Subdiv2D.java From VIA-AI with MIT License | 5 votes |
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 #12
Source File: Converters.java From VIA-AI with MIT License | 4 votes |
public static void Mat_to_vector_Point2f(Mat m, List<Point> pts) { Mat_to_vector_Point(m, pts); }
Example #13
Source File: Converters.java From pasm-yolov3-Android with GNU General Public License v3.0 | 4 votes |
public static void Mat_to_vector_Point2f(Mat m, List<Point> pts) { Mat_to_vector_Point(m, pts); }
Example #14
Source File: PerspectiveTransformation.java From AndroidDocumentScanner with MIT License | 4 votes |
private double getDistance(Point p1, Point p2) { double dx = p2.x - p1.x; double dy = p2.y - p1.y; return Math.sqrt(dx * dx + dy * dy); }
Example #15
Source File: CameraActivity.java From AndroidObjectDetection-OpenCV with MIT License | 4 votes |
@Override public Mat onCameraFrame(CvCameraViewFrame inputFrame) { Mat frame = inputFrame.rgba(); Imgproc.cvtColor(frame, frame, Imgproc.COLOR_RGBA2RGB); Size frame_size = new Size(416, 416); Scalar mean = new Scalar(127.5); Mat blob = Dnn.blobFromImage(frame, 1.0 / 255.0, frame_size, mean, true, false); //save_mat(blob); net.setInput(blob); List<Mat> result = new ArrayList<>(); List<String> outBlobNames = net.getUnconnectedOutLayersNames(); net.forward(result, outBlobNames); float confThreshold = 0.5f; for (int i = 0; i < result.size(); ++i) { // each row is a candidate detection, the 1st 4 numbers are // [center_x, center_y, width, height], followed by (N-4) class probabilities Mat level = result.get(i); for (int j = 0; j < level.rows(); ++j) { Mat row = level.row(j); Mat scores = row.colRange(5, level.cols()); Core.MinMaxLocResult mm = Core.minMaxLoc(scores); float confidence = (float) mm.maxVal; Point classIdPoint = mm.maxLoc; if (confidence > confThreshold) { int centerX = (int) (row.get(0, 0)[0] * frame.cols()); int centerY = (int) (row.get(0, 1)[0] * frame.rows()); int width = (int) (row.get(0, 2)[0] * frame.cols()); int height = (int) (row.get(0, 3)[0] * frame.rows()); int left = (int) (centerX - width * 0.5); int top =(int)(centerY - height * 0.5); int right =(int)(centerX + width * 0.5); int bottom =(int)(centerY + height * 0.5); Point left_top = new Point(left, top); Point right_bottom=new Point(right, bottom); Point label_left_top = new Point(left, top-5); DecimalFormat df = new DecimalFormat("#.##"); int class_id = (int) classIdPoint.x; String label= classNames.get(class_id) + ": " + df.format(confidence); Scalar color= colors.get(class_id); Imgproc.rectangle(frame, left_top,right_bottom , color, 3, 2); Imgproc.putText(frame, label, label_left_top, Imgproc.FONT_HERSHEY_SIMPLEX, 1, new Scalar(0, 0, 0), 4); Imgproc.putText(frame, label, label_left_top, Imgproc.FONT_HERSHEY_SIMPLEX, 1, new Scalar(255, 255, 255), 2); } } } return frame; }
Example #16
Source File: Converters.java From LicensePlateDiscern with MIT License | 4 votes |
public static void Mat_to_vector_Point2d(Mat m, List<Point> pts) { Mat_to_vector_Point(m, pts); }
Example #17
Source File: Converters.java From SoftwarePilot with MIT License | 4 votes |
public static Mat vector_Point2f_to_Mat(List<Point> pts) { return vector_Point_to_Mat(pts, CvType.CV_32F); }
Example #18
Source File: Converters.java From SoftwarePilot with MIT License | 4 votes |
public static Mat vector_Point2d_to_Mat(List<Point> pts) { return vector_Point_to_Mat(pts, CvType.CV_64F); }
Example #19
Source File: Converters.java From LicensePlateDiscern with MIT License | 4 votes |
public static Mat vector_Point2f_to_Mat(List<Point> pts) { return vector_Point_to_Mat(pts, CvType.CV_32F); }
Example #20
Source File: Converters.java From LicensePlateDiscern with MIT License | 4 votes |
public static Mat vector_Point_to_Mat(List<Point> pts) { return vector_Point_to_Mat(pts, CvType.CV_32S); }
Example #21
Source File: Imgproc.java From pasm-yolov3-Android with GNU General Public License v3.0 | 3 votes |
public static void dilate(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue) { dilate_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 #22
Source File: Imgproc.java From pasm-yolov3-Android with GNU General Public License v3.0 | 3 votes |
public static void line(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int lineType) { line_1(img.nativeObj, pt1.x, pt1.y, pt2.x, pt2.y, color.val[0], color.val[1], color.val[2], color.val[3], thickness, lineType); return; }
Example #23
Source File: AlignMTB.java From LicensePlateDiscern with MIT License | 3 votes |
public void shiftMat(Mat src, Mat dst, Point shift) { shiftMat_0(nativeObj, src.nativeObj, dst.nativeObj, shift.x, shift.y); return; }
Example #24
Source File: Imgproc.java From LicensePlateDiscern with MIT License | 3 votes |
public static void arrowedLine(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int line_type, int shift) { arrowedLine_1(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); return; }
Example #25
Source File: Imgproc.java From pasm-yolov3-Android with GNU General Public License v3.0 | 3 votes |
public static void circle(Mat img, Point center, int radius, Scalar color, int thickness, int lineType) { circle_1(img.nativeObj, center.x, center.y, radius, color.val[0], color.val[1], color.val[2], color.val[3], thickness, lineType); return; }
Example #26
Source File: Imgproc.java From LPR with Apache License 2.0 | 3 votes |
public static void putText(Mat img, String text, Point org, int fontFace, double fontScale, Scalar color, int thickness) { putText_2(img.nativeObj, text, org.x, org.y, fontFace, fontScale, color.val[0], color.val[1], color.val[2], color.val[3], thickness); return; }
Example #27
Source File: Imgproc.java From LPR with Apache License 2.0 | 3 votes |
public static void putText(Mat img, String text, Point org, int fontFace, double fontScale, Scalar color, int thickness, int lineType, boolean bottomLeftOrigin) { putText_0(img.nativeObj, text, org.x, org.y, fontFace, fontScale, color.val[0], color.val[1], color.val[2], color.val[3], thickness, lineType, bottomLeftOrigin); return; }
Example #28
Source File: Imgproc.java From LPR with Apache License 2.0 | 3 votes |
public static void arrowedLine(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int line_type, int shift) { arrowedLine_1(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); return; }
Example #29
Source File: Calib3d.java From LicensePlateDiscern with MIT License | 3 votes |
public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method) { Mat retVal = new Mat(findEssentialMat_8(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method)); return retVal; }
Example #30
Source File: Imgproc.java From LPR with Apache License 2.0 | 3 votes |
public static void arrowedLine(Mat img, Point pt1, Point pt2, Scalar color) { arrowedLine_4(img.nativeObj, pt1.x, pt1.y, pt2.x, pt2.y, color.val[0], color.val[1], color.val[2], color.val[3]); return; }