List of usage examples for org.opencv.core Point Point
public Point()
From source file:karthik.Barcode.ImageInfo.java
License:Open Source License
ImageInfo(Mat src) { src_original = src;//from w w w . j av a 2s . com gradient_direction = new Mat(); gradient_magnitude = new Mat(); scharr_x = new Mat(); scharr_y = new Mat(); mask = new Mat(); // create List of Point's for CandidateMatrixBarcode for (int r = 0; r < 4; r++) { newCornerPoints.add(new Point()); transformedPoints.add(new Point()); } }
From source file:org.openpnp.vision.FluentCv.java
License:Open Source License
/** * Draw the infinite line defined by the two points to the extents of the image instead of just * between the two points. From://from www .ja v a 2s. c o m * http://stackoverflow.com/questions/13160722/how-to-draw-line-not-line-segment-opencv-2-4-2 * * @param img * @param p1 * @param p2 * @param color */ public static void infiniteLine(Mat img, Point p1, Point p2, Color color) { Point p = new Point(), q = new Point(); // Check if the line is a vertical line because vertical lines don't // have slope if (p1.x != p2.x) { p.x = 0; q.x = img.cols(); // Slope equation (y1 - y2) / (x1 - x2) float m = (float) ((p1.y - p2.y) / (p1.x - p2.x)); // Line equation: y = mx + b float b = (float) (p1.y - (m * p1.x)); p.y = m * p.x + b; q.y = m * q.x + b; } else { p.x = q.x = p2.x; p.y = 0; q.y = img.rows(); } Core.line(img, p, q, colorToScalar(color)); }
From source file:org.pattern.detection.contour.ContourDetectionAlgorithm.java
/** Calculates center of particle. */ private Point calcCog(MatOfPoint contour) { Moments moments = Imgproc.moments(contour); Point cog = new Point(); cog.x = moments.get_m10() / moments.get_m00(); cog.y = moments.get_m01() / moments.get_m00(); return cog;/*from w w w . ja v a2 s . c o m*/ }
From source file:simeav.filtros.instanciaciones.SeparadorTextoEstandar.java
@Override public void separarTexto(Mat origin, int umbral_radio) { Mat original = origin.clone();//from ww w. j av a 2s .c o m imagenSinTexto = original.clone(); imagenTexto = Mat.zeros(original.size(), CvType.CV_8U); imagenTexto = imagenTexto.setTo(new Scalar(255, 255, 255)); Mat imGrises = new Mat(); Mat bw = new Mat(); Imgproc.cvtColor(original, imGrises, Imgproc.COLOR_BGR2GRAY); Imgproc.GaussianBlur(imGrises, bw, new Size(1, 1), 0); Imgproc.threshold(bw, bw, 200, 250, Imgproc.THRESH_BINARY_INV); ArrayList<MatOfPoint> contornos = Utils.detectarContornos(bw); for (int i = 0; i < contornos.size(); i++) { MatOfPoint2f contorno2f = new MatOfPoint2f(); contorno2f.fromList(contornos.get(i).toList()); float[] radius = new float[1]; Point centro = new Point(); Imgproc.minEnclosingCircle(contorno2f, centro, radius); double a = Imgproc.contourArea(contornos.get(i)); if (radius[0] <= umbral_radio) { Imgproc.drawContours(imagenSinTexto, contornos, i, new Scalar(255, 255, 255), -1); Imgproc.drawContours(imagenTexto, contornos, i, new Scalar(0, 0, 0), -1); } } }