org.opencv.core.RotatedRect Java Examples
The following examples show how to use
org.opencv.core.RotatedRect.
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: MatOfRotatedRect.java From VIA-AI with MIT License | 6 votes |
public void fromArray(RotatedRect...a) { if(a==null || a.length==0) return; int num = a.length; alloc(num); float buff[] = new float[num * _channels]; for(int i=0; i<num; i++) { RotatedRect r = a[i]; buff[_channels*i+0] = (float) r.center.x; buff[_channels*i+1] = (float) r.center.y; buff[_channels*i+2] = (float) r.size.width; buff[_channels*i+3] = (float) r.size.height; buff[_channels*i+4] = (float) r.angle; } put(0, 0, buff); //TODO: check ret val! }
Example #2
Source File: PaintUtils.java From super-cloudops with Apache License 2.0 | 6 votes |
/** * * 画出所有的矩形 * * @param src * @return */ public static Mat paintCon(Mat src) { Mat cannyMat = GeneralUtils.canny(src); List<MatOfPoint> contours = ContoursUtils.findContours(cannyMat); Mat rectMat = src.clone(); Scalar scalar = new Scalar(0, 0, 255); for (int i = contours.size() - 1; i >= 0; i--) { MatOfPoint matOfPoint = contours.get(i); MatOfPoint2f matOfPoint2f = new MatOfPoint2f(matOfPoint.toArray()); RotatedRect rect = Imgproc.minAreaRect(matOfPoint2f); Rect r = rect.boundingRect(); System.out.println(r.area() + " --- " + i); rectMat = paintRect(rectMat, r, scalar); } return rectMat; }
Example #3
Source File: MatOfRotatedRect.java From LicensePlateDiscern with MIT License | 6 votes |
public void fromArray(RotatedRect...a) { if(a==null || a.length==0) return; int num = a.length; alloc(num); float buff[] = new float[num * _channels]; for(int i=0; i<num; i++) { RotatedRect r = a[i]; buff[_channels*i+0] = (float) r.center.x; buff[_channels*i+1] = (float) r.center.y; buff[_channels*i+2] = (float) r.size.width; buff[_channels*i+3] = (float) r.size.height; buff[_channels*i+4] = (float) r.angle; } put(0, 0, buff); //TODO: check ret val! }
Example #4
Source File: Imgproc.java From OpenCV-android with Apache License 2.0 | 5 votes |
public static RotatedRect minAreaRect(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(minAreaRect_0(points_mat.nativeObj)); return retVal; }
Example #5
Source File: Imgproc.java From FtcSamples with MIT License | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #6
Source File: Imgproc.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #7
Source File: Imgproc.java From ml-authentication with Apache License 2.0 | 5 votes |
public static RotatedRect minAreaRect(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(minAreaRect_0(points_mat.nativeObj)); return retVal; }
Example #8
Source File: Imgproc.java From Form-N-Fun with MIT License | 5 votes |
public static RotatedRect minAreaRect(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(minAreaRect_0(points_mat.nativeObj)); return retVal; }
Example #9
Source File: Imgproc.java From ml-authentication with Apache License 2.0 | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #10
Source File: Imgproc.java From FaceDetectDemo with Apache License 2.0 | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #11
Source File: Imgproc.java From MOAAP with MIT License | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #12
Source File: Video.java From LPR with Apache License 2.0 | 5 votes |
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria) { double[] window_out = new double[4]; RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon)); if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } return retVal; }
Example #13
Source File: Imgproc.java From LicensePlateDiscern with MIT License | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #14
Source File: Imgproc.java From MOAAP with MIT License | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #15
Source File: Imgproc.java From FaceT with Mozilla Public License 2.0 | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #16
Source File: Video.java From LicensePlateDiscern with MIT License | 5 votes |
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria) { double[] window_out = new double[4]; RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon)); if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } return retVal; }
Example #17
Source File: Imgproc.java From OpenCV-Android-Object-Detection with MIT License | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #18
Source File: Imgproc.java From Camdroid with Apache License 2.0 | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #19
Source File: MatOfRotatedRect.java From pasm-yolov3-Android with GNU General Public License v3.0 | 5 votes |
public RotatedRect[] toArray() { int num = (int) total(); RotatedRect[] a = new RotatedRect[num]; if(num == 0) return a; float buff[] = new float[_channels]; for(int i=0; i<num; i++) { get(i, 0, buff); //TODO: check ret val! a[i] = new RotatedRect(new Point(buff[0],buff[1]),new Size(buff[2],buff[3]),buff[4]); } return a; }
Example #20
Source File: Video.java From MOAAP with MIT License | 5 votes |
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria) { double[] window_out = new double[4]; RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon)); if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } return retVal; }
Example #21
Source File: Video.java From react-native-documentscanner-android with MIT License | 5 votes |
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria) { double[] window_out = new double[4]; RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon)); if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } return retVal; }
Example #22
Source File: Imgproc.java From OpenCV-Android-Object-Detection with MIT License | 5 votes |
public static RotatedRect minAreaRect(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(minAreaRect_0(points_mat.nativeObj)); return retVal; }
Example #23
Source File: Video.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria) { double[] window_out = new double[4]; RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon)); if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } return retVal; }
Example #24
Source File: ContoursUtils.java From super-cloudops with Apache License 2.0 | 5 votes |
/** * 寻找轮廓,并按照递增排序 * * @param cannyMat * @return */ public static List<MatOfPoint> findContours(Mat cannyMat) { List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); Mat hierarchy = new Mat(); // 寻找轮廓 Imgproc.findContours(cannyMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0, 0)); if (contours.size() <= 0) { // throw new RuntimeException("未找到图像轮廓"); } else { // 对contours进行了排序,按递增顺序 contours.sort(new Comparator<MatOfPoint>() { @Override public int compare(MatOfPoint o1, MatOfPoint o2) { MatOfPoint2f mat1 = new MatOfPoint2f(o1.toArray()); RotatedRect rect1 = Imgproc.minAreaRect(mat1); Rect r1 = rect1.boundingRect(); MatOfPoint2f mat2 = new MatOfPoint2f(o2.toArray()); RotatedRect rect2 = Imgproc.minAreaRect(mat2); Rect r2 = rect2.boundingRect(); return (int) (r1.area() - r2.area()); } }); } return contours; }
Example #25
Source File: Imgproc.java From ml-authentication with Apache License 2.0 | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #26
Source File: Imgproc.java From MOAAP with MIT License | 5 votes |
public static RotatedRect fitEllipse(MatOfPoint2f points) { Mat points_mat = points; RotatedRect retVal = new RotatedRect(fitEllipse_0(points_mat.nativeObj)); return retVal; }
Example #27
Source File: MatOfRotatedRect.java From VIA-AI with MIT License | 4 votes |
public void fromList(List<RotatedRect> lr) { RotatedRect ap[] = lr.toArray(new RotatedRect[0]); fromArray(ap); }
Example #28
Source File: MatOfRotatedRect.java From LicensePlateDiscern with MIT License | 4 votes |
public List<RotatedRect> toList() { RotatedRect[] ar = toArray(); return Arrays.asList(ar); }
Example #29
Source File: AutoCalibrationManager.java From ShootOFF with GNU General Public License v3.0 | 4 votes |
private Optional<MatOfPoint2f> estimatePatternRect(Mat traceMat, MatOfPoint2f boardRect) { // We use this to calculate the angle final RotatedRect boardBox = Imgproc.minAreaRect(boardRect); final double boardBoxAngle = boardBox.size.height > boardBox.size.width ? 90.0 + boardBox.angle : boardBox.angle; // This is the board corners with the angle eliminated final Mat unRotMat = getRotationMatrix(massCenterMatOfPoint2f(boardRect), boardBoxAngle); final MatOfPoint2f unRotatedRect = rotateRect(unRotMat, boardRect); // This is the estimated projection area that has minimum angle (Not // rotated) final MatOfPoint2f estimatedPatternSizeRect = estimateFullPatternSize(unRotatedRect); // This is what we'll use as the transformation target and bounds given // back to the cameramanager boundsRect = Imgproc.minAreaRect(estimatedPatternSizeRect); if (boundsRect.boundingRect().x < 0 || boundsRect.boundingRect().y < 0 || boundsRect.boundingRect().y+boundsRect.boundingRect().height >= this.camera.getViewSize().getHeight() || boundsRect.boundingRect().x+boundsRect.boundingRect().width >= this.camera.getViewSize().getWidth()) { logger.debug("Pattern found but autocalibration failed--Cannot dedistort within camera bounds, make sure the projector area is a perfect rectangle and try again"); return Optional.empty(); } // We now rotate the estimation back to the original angle to use for // transformation source final Mat rotMat = getRotationMatrix(massCenterMatOfPoint2f(estimatedPatternSizeRect), -boardBoxAngle); final MatOfPoint2f rotatedPatternSizeRect = rotateRect(rotMat, estimatedPatternSizeRect); if (logger.isTraceEnabled()) { logger.trace("center {} angle {} width {} height {}", boardBox.center, boardBoxAngle, boardBox.size.width, boardBox.size.height); logger.debug("boundsRect {} {} {} {}", boundsRect.boundingRect().x, boundsRect.boundingRect().y, boundsRect.boundingRect().x + boundsRect.boundingRect().width, boundsRect.boundingRect().y + boundsRect.boundingRect().height); Core.circle(traceMat, new Point(boardRect.get(0, 0)[0], boardRect.get(0, 0)[1]), 1, new Scalar(255, 0, 0), -1); Core.circle(traceMat, new Point(boardRect.get(1, 0)[0], boardRect.get(1, 0)[1]), 1, new Scalar(255, 0, 0), -1); Core.circle(traceMat, new Point(boardRect.get(2, 0)[0], boardRect.get(2, 0)[1]), 1, new Scalar(255, 0, 0), -1); Core.circle(traceMat, new Point(boardRect.get(3, 0)[0], boardRect.get(3, 0)[1]), 1, new Scalar(255, 0, 0), -1); Core.line(traceMat, new Point(unRotatedRect.get(0, 0)[0], unRotatedRect.get(0, 0)[1]), new Point(unRotatedRect.get(1, 0)[0], unRotatedRect.get(1, 0)[1]), new Scalar(0, 255, 0)); Core.line(traceMat, new Point(unRotatedRect.get(1, 0)[0], unRotatedRect.get(1, 0)[1]), new Point(unRotatedRect.get(2, 0)[0], unRotatedRect.get(2, 0)[1]), new Scalar(0, 255, 0)); Core.line(traceMat, new Point(unRotatedRect.get(3, 0)[0], unRotatedRect.get(3, 0)[1]), new Point(unRotatedRect.get(2, 0)[0], unRotatedRect.get(2, 0)[1]), new Scalar(0, 255, 0)); Core.line(traceMat, new Point(unRotatedRect.get(3, 0)[0], unRotatedRect.get(3, 0)[1]), new Point(unRotatedRect.get(0, 0)[0], unRotatedRect.get(0, 0)[1]), new Scalar(0, 255, 0)); Core.line(traceMat, new Point(estimatedPatternSizeRect.get(0, 0)[0], estimatedPatternSizeRect.get(0, 0)[1]), new Point(estimatedPatternSizeRect.get(1, 0)[0], estimatedPatternSizeRect.get(1, 0)[1]), new Scalar(255, 255, 0)); Core.line(traceMat, new Point(estimatedPatternSizeRect.get(1, 0)[0], estimatedPatternSizeRect.get(1, 0)[1]), new Point(estimatedPatternSizeRect.get(2, 0)[0], estimatedPatternSizeRect.get(2, 0)[1]), new Scalar(255, 255, 0)); Core.line(traceMat, new Point(estimatedPatternSizeRect.get(3, 0)[0], estimatedPatternSizeRect.get(3, 0)[1]), new Point(estimatedPatternSizeRect.get(2, 0)[0], estimatedPatternSizeRect.get(2, 0)[1]), new Scalar(255, 255, 0)); Core.line(traceMat, new Point(estimatedPatternSizeRect.get(3, 0)[0], estimatedPatternSizeRect.get(3, 0)[1]), new Point(estimatedPatternSizeRect.get(0, 0)[0], estimatedPatternSizeRect.get(0, 0)[1]), new Scalar(255, 255, 0)); Core.line(traceMat, new Point(rotatedPatternSizeRect.get(0, 0)[0], rotatedPatternSizeRect.get(0, 0)[1]), new Point(rotatedPatternSizeRect.get(1, 0)[0], rotatedPatternSizeRect.get(1, 0)[1]), new Scalar(255, 255, 0)); Core.line(traceMat, new Point(rotatedPatternSizeRect.get(1, 0)[0], rotatedPatternSizeRect.get(1, 0)[1]), new Point(rotatedPatternSizeRect.get(2, 0)[0], rotatedPatternSizeRect.get(2, 0)[1]), new Scalar(255, 255, 0)); Core.line(traceMat, new Point(rotatedPatternSizeRect.get(3, 0)[0], rotatedPatternSizeRect.get(3, 0)[1]), new Point(rotatedPatternSizeRect.get(2, 0)[0], rotatedPatternSizeRect.get(2, 0)[1]), new Scalar(255, 255, 0)); Core.line(traceMat, new Point(rotatedPatternSizeRect.get(3, 0)[0], rotatedPatternSizeRect.get(3, 0)[1]), new Point(rotatedPatternSizeRect.get(0, 0)[0], rotatedPatternSizeRect.get(0, 0)[1]), new Scalar(255, 255, 0)); } return Optional.of(rotatedPatternSizeRect); }
Example #30
Source File: MatOfRotatedRect.java From LPR with Apache License 2.0 | 4 votes |
public void fromList(List<RotatedRect> lr) { RotatedRect ap[] = lr.toArray(new RotatedRect[0]); fromArray(ap); }