List of usage examples for org.opencv.core Point Point
public Point()
From source file:com.shootoff.camera.autocalibration.AutoCalibrationManager.java
License:Open Source License
private Optional<Point> computeIntersect(final double[] a, final double[] b) { final double x1 = a[0], y1 = a[1], x2 = a[2], y2 = a[3]; final double x3 = b[0], y3 = b[1], x4 = b[2], y4 = b[3]; final double d = ((double) (x1 - x2) * (y3 - y4)) - ((y1 - y2) * (x3 - x4)); if (d > 0) { final Point pt = new Point(); pt.x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d; pt.y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d; return Optional.of(pt); }// w w w.j ava2 s . c o m return Optional.empty(); }
From source file:com.shootoff.camera.autocalibration.AutoCalibrationManager.java
License:Open Source License
private Point rotPoint(final Mat rot_mat, final Point point) { final Point rp = new Point(); rp.x = rot_mat.get(0, 0)[0] * point.x + rot_mat.get(0, 1)[0] * point.y + rot_mat.get(0, 2)[0]; rp.y = rot_mat.get(1, 0)[0] * point.x + rot_mat.get(1, 1)[0] * point.y + rot_mat.get(1, 2)[0]; return rp;/*w w w.ja v a2s . c o m*/ }
From source file:com.shootoff.camera.autocalibration.AutoCalibrationManager.java
License:Open Source License
private Point massCenterMatOfPoint2f(final MatOfPoint2f map) { final Moments moments = Imgproc.moments(map); final Point centroid = new Point(); centroid.x = moments.get_m10() / moments.get_m00(); centroid.y = moments.get_m01() / moments.get_m00(); return centroid; }
From source file:com.wheelphone.blobDocking.WheelphoneDocking.java
License:Open Source License
public void followBlob(Point[] centers, float[] radius, int imgWidth, int imgHeight) { if (centers[0].x == 0 && centers[0].y == 0) { newBlobInfo = NO_BLOB_FOUND;/*ww w.j av a2 s . c o m*/ } else { blobCenter = new Point(); blobCenter = centers[0]; blobRadius = radius[0]; currentImgHeight = imgHeight; currentImgWidth = imgWidth; newBlobInfo = BLOB_FOUND; } }
From source file:de.hu_berlin.informatik.spws2014.mapever.camera.CornerDetectionCamera.java
License:Open Source License
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera_cornerdetectioncamera); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); camera_view = (CornerDetectionView) findViewById(R.id.corner_detection_java_surface_view); camera_view.setVisibility(SurfaceView.VISIBLE); camera_view.setCvCameraViewListener(this); camera_view.startMonitoringOrientation(); last_corners = new Point[] { new Point(), new Point(), new Point(), new Point() }; run_detection = true;/*from w w w. j a v a 2s . co m*/ corner_detection_task = new AsyncCornerDetection(this); corner_detection_task.execute(); }
From source file:emotion.EyeRegion.java
public EyeRegion(Mat face) { _face = face;/* w ww.j a v a 2 s . c o m*/ leftOuterEyeCorner = new Point(); leftInnerEyeCorner = new Point(); rightOuterEyeCorner = new Point(); rightInnerEyeCorner = new Point(); rightUpperEyelid = new Point(); rightLowerEyelid = new Point(); leftUpperEyelid = new Point(); leftLowerEyelid = new Point(); rightOuterEyebrowsCorner = new Point(); rightInnerEyebrowsCorner = new Point(); leftOuterEyebrowsCorner = new Point(); leftInnerEyebrowsCorner = new Point(); }
From source file:houghtransform.transform_process.MyTransform.java
@Override public void houghTransform(Mat edges) { Mat _edges = edges.clone();/*from w w w. j a v a 2 s. co m*/ double radian = Math.PI / 180; int degrees = (int) Math.floor(theta * 180 / Math.PI + 0.5); int w = _edges.cols(); int h = _edges.rows(); _edges.convertTo(_edges, CvType.CV_64FC3); int size = w * h; double[] img_data = new double[size]; _edges.get(0, 0, img_data); // Gets all pixels _img_w = w; //Number of columns _img_h = h; //Number of lines //Create the accumulator double hough_h = ((Math.sqrt(2.0) * (double) (h > w ? h : w)) / 2.0); _accu_h = (int) (hough_h * 2.0); // -r -> +r _accu_w = 180; _accu = new int[_accu_h * _accu_w]; for (int i = 0; i < _accu_h * _accu_w; i++) { _accu[i] = 0; } double center_x = w / 2; double center_y = h / 2; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (img_data[(y * w) + x] > 250) { for (int t = 0; t < 180; t = t + degrees) { // y = x * cos( theta ) + y * sin( theta ) double r = (((double) x - center_x) * Math.cos((double) t * radian)) + (((double) y - center_y) * Math.sin((double) t * radian)); _accu[(int) ((Math.floor(r + hough_h) * 180.0)) + t]++; } } } } ArrayList<Point> lines = new ArrayList<>(); if (_accu.length == 0) try { throw new IOException("MyTransform: _accu == 0"); } catch (IOException ex) { System.out.println(ex); } for (int r = 0; r < _accu_h; r++) { for (int t = 0; t < _accu_w; t++) { // Searching in the accumulator a value greater //or equal to the set threshold if (((int) _accu[(r * _accu_w) + t]) >= threshold) { // Is this point a local maxima (9x9) int max = _accu[(r * _accu_w) + t]; //////////////////////////////// for (int ly = -4; ly <= 4; ly++) { for (int lx = -4; lx <= 4; lx++) { if (((ly + r) >= 0 && (ly + r) < _accu_h) && ((lx + t) >= 0 && (lx + t) < _accu_w)) { if ((int) _accu[((r + ly) * _accu_w) + (t + lx)] > max) { max = _accu[((r + ly) * _accu_w) + (t + lx)]; ly = lx = 5; } } } } ///////////////////////////////// if (max > (int) _accu[(r * _accu_w) + t]) continue; Point point = new Point(); point.x = r; point.y = t * radian; lines.add(point); } } } _lines = lines; }
From source file:houghtransform.transform_process.MyTransform.java
@Override public Mat drawLines(Mat scr) { for (Point pt : _lines) { double r = pt.x, t = pt.y; Point pt1 = new Point(); Point pt2 = new Point(); if (t / (Math.PI / 180) >= 45 && t / (Math.PI / 180) <= 135) { pt1.x = -1000;/* ww w .j av a 2 s. c om*/ pt2.x = 1000; pt1.y = ((r - _accu_h / 2) - (-1000 - _img_w / 2) * Math.cos(t)) / Math.sin(t) + _img_h / 2; pt2.y = ((r - _accu_h / 2) - (1000 - _img_w / 2) * Math.cos(t)) / Math.sin(t) + _img_h / 2; } else { pt1.y = -1000; pt2.y = 1000; pt1.x = ((r - _accu_h / 2) - (-1000 - _img_h / 2) * Math.sin(t)) / Math.cos(t) + _img_w / 2; pt2.x = ((r - _accu_h / 2) - (1000 - _img_h / 2) * Math.sin(t)) / Math.cos(t) + _img_w / 2; } //Drawing the lines Imgproc.line(scr, pt1, pt2, new Scalar(0, 0, 255), 1); } return scr; }
From source file:houghtransform.transform_process.OpenCV.java
@Override public Mat drawLines(Mat scr) { for (int x = 1; x < lines.rows(); x++) { double[] vec = lines.get(x, 0); double rho = vec[0], theta1 = vec[1]; Point pt1 = new Point(); Point pt2 = new Point(); double a = Math.cos(theta1), b = Math.sin(theta1); double x0 = a * rho, y0 = b * rho; pt1.x = Math.round(x0 + 1000 * (-b)); pt1.y = Math.round(y0 + 1000 * (a)); pt2.x = Math.round(x0 - 1000 * (-b)); pt2.y = Math.round(y0 - 1000 * (a)); Imgproc.line(scr, pt1, pt2, new Scalar(0, 0, 255), 1); }/* w ww . j a va 2s.co m*/ return scr; }
From source file:in.fabinpaul.sixthsense.ColorBlobDetector.java
License:Apache License
public Point getXY() { marker = new Point(); for (int i = 0; i < mMask.rows(); i++) { for (int j = 0; j < mMask.cols(); j++) { }//from w w w . j a v a 2 s. com } return marker; }