当前位置: 首页>>代码示例>>Java>>正文


Java Rect类代码示例

本文整理汇总了Java中org.opencv.core.Rect的典型用法代码示例。如果您正苦于以下问题:Java Rect类的具体用法?Java Rect怎么用?Java Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Rect类属于org.opencv.core包,在下文中一共展示了Rect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createParticleReports

import org.opencv.core.Rect; //导入依赖的package包/类
/**
 * Takes the base OpenCV list of contours and changes the output to be easier to
 * work with.
 * 
 * @param contours
 *            The input from the base OpenCV contours output
 */
private void createParticleReports (List<MatOfPoint> contours)
{
    ParticleReport[] reports = new ParticleReport[contours.size()];

    for (int i = 0; i < reports.length; i++)
        {
        reports[i] = new ParticleReport();
        Rect r = Imgproc.boundingRect(contours.get(i));
        reports[i].area = r.area();
        reports[i].center = new Point(r.x + (r.width / 2),
                r.y + (r.height / 2));
        reports[i].boundingRect = r;
        }

    this.particleReports = reports;
}
 
开发者ID:FIRST-Team-339,项目名称:2017,代码行数:24,代码来源:VisionProcessor.java

示例2: Rectangle

import org.opencv.core.Rect; //导入依赖的package包/类
/**
 * Create a rectangle based on a set of points
 *
 * @param points Set of points (at least 4) defining the rectangle
 */
public Rectangle(Point[] points) {
    //Find top-left and bottom-right
    Point min = new Point(Double.MAX_VALUE, Double.MAX_VALUE);
    Point max = new Point(Double.MIN_VALUE, Double.MIN_VALUE);
    for (Point p : points) {
        if (p.x < min.x) {
            min.x = p.x;
        }
        if (p.y < min.y) {
            min.y = p.y;
        }
        if (p.x > max.x) {
            max.x = p.x;
        }
        if (p.y > max.y) {
            max.y = p.y;
        }
    }
    setRect(new Rect(min, max));
}
 
开发者ID:TheBigBombman,项目名称:RobotIGS,代码行数:26,代码来源:Rectangle.java

示例3: drawRectangles

import org.opencv.core.Rect; //导入依赖的package包/类
/**
 * This method is called to overlay rectangles on an image to the video output.
 *
 * @param image specifies the frame to be rendered to the video output.
 * @param detectedObjectRects specifies the detected object rectangles.
 * @param color specifies the color of the rectangle outline.
 * @param thickness specifies the thickness of the rectangle outline.
 */
public void drawRectangles(Mat image, Rect[] detectedObjectRects, Scalar color, int thickness)
{
    //
    // Overlay a rectangle on each detected object.
    //
    synchronized (image)
    {
        if (detectedObjectRects != null)
        {
            for (Rect r: detectedObjectRects)
            {
                //
                // Draw a rectangle around the detected object.
                //
                Imgproc.rectangle(
                    image, new Point(r.x, r.y), new Point(r.x + r.width, r.y + r.height), color, thickness);
            }
        }

        videoSource.putFrame(image);
    }
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:31,代码来源:TrcOpenCvDetector.java

示例4: findAllColors

import org.opencv.core.Rect; //导入依赖的package包/类
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;
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:26,代码来源:ColorFinder.java

示例5: boundingRect

import org.opencv.core.Rect; //导入依赖的package包/类
public static Rect boundingRect(MatOfPoint points)
{
    Mat points_mat = points;
    Rect retVal = new Rect(boundingRect_0(points_mat.nativeObj));
    
    return retVal;
}
 
开发者ID:vulovicv23,项目名称:opencv-documentscanner-android,代码行数:8,代码来源:Imgproc.java

示例6: CamShift

import org.opencv.core.Rect; //导入依赖的package包/类
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;
}
 
开发者ID:GTHSRobotics,项目名称:DogeCV,代码行数:8,代码来源:Video.java

示例7: Mat_to_vector_Rect

import org.opencv.core.Rect; //导入依赖的package包/类
public static void Mat_to_vector_Rect(Mat m, List<Rect> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_32SC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    int[] buff = new int[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
开发者ID:johnhany,项目名称:MOAAP,代码行数:16,代码来源:Converters.java

示例8: stereoRectify

import org.opencv.core.Rect; //导入依赖的package包/类
public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2)
{
    double[] validPixROI1_out = new double[4];
    double[] validPixROI2_out = new double[4];
    stereoRectify_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out, validPixROI2_out);
    if(validPixROI1!=null){ validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; } 
    if(validPixROI2!=null){ validPixROI2.x = (int)validPixROI2_out[0]; validPixROI2.y = (int)validPixROI2_out[1]; validPixROI2.width = (int)validPixROI2_out[2]; validPixROI2.height = (int)validPixROI2_out[3]; } 
    return;
}
 
开发者ID:SCHS-Robotics,项目名称:Team9261-2017-2018,代码行数:10,代码来源:Calib3d.java

示例9: meanShift

import org.opencv.core.Rect; //导入依赖的package包/类
public static int meanShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    int retVal = meanShift_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;
}
 
开发者ID:johnhany,项目名称:MOAAP,代码行数:8,代码来源:Video.java

示例10: rectify3Collinear

import org.opencv.core.Rect; //导入依赖的package包/类
public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List<Mat> imgpt1, List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
{
    Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
    Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
    double[] roi1_out = new double[4];
    double[] roi2_out = new double[4];
    float retVal = rectify3Collinear_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
    if(roi1!=null){ roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; } 
    if(roi2!=null){ roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; } 
    return retVal;
}
 
开发者ID:vulovicv23,项目名称:opencv-documentscanner-android,代码行数:12,代码来源:Calib3d.java

示例11: getOptimalNewCameraMatrix

import org.opencv.core.Rect; //导入依赖的package包/类
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI, boolean centerPrincipalPoint)
{
    double[] validPixROI_out = new double[4];
    Mat retVal = new Mat(getOptimalNewCameraMatrix_0(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height, validPixROI_out, centerPrincipalPoint));
    if(validPixROI!=null){ validPixROI.x = (int)validPixROI_out[0]; validPixROI.y = (int)validPixROI_out[1]; validPixROI.width = (int)validPixROI_out[2]; validPixROI.height = (int)validPixROI_out[3]; } 
    return retVal;
}
 
开发者ID:linzuzeng,项目名称:Microsphere,代码行数:8,代码来源:Calib3d.java

示例12: onFaceDetected

import org.opencv.core.Rect; //导入依赖的package包/类
@Override
public void onFaceDetected(Rect faceOpenCV, Face face) {
    if (!isStopped && view != null) {
        view.drawFace(faceOpenCV, matrixRgba);
        view.startEyesDetection(faceOpenCV);
    }
}
 
开发者ID:raulh82vlc,项目名称:Image-Detection-Samples,代码行数:8,代码来源:FDOpenCVPresenter.java

示例13: horizontalScale

import org.opencv.core.Rect; //导入依赖的package包/类
public static Rect horizontalScale(Rect original, double factor) {

        double width = original.br().x - original.tl().x;
        double newWidth = width * factor;
        double newLeft = original.tl().x - ((newWidth - width) / 2);
        double height = original.br().y - original.tl().y;

        return new Rect((int) newLeft, (int) original.tl().y, (int) newWidth, (int) height);
    }
 
开发者ID:Deeplocal,项目名称:android-things-drawbot,代码行数:10,代码来源:Utilities.java

示例14: startThread

import org.opencv.core.Rect; //导入依赖的package包/类
public void startThread() {

        if (thread == null) {
            // Create a new thread that will constantly evaluate new camera frames
            thread = new Thread(() -> {

                Mat image = new Mat(CAMERA_HEIGHT, CAMERA_WIDTH, 6);

                while (!Thread.interrupted()) {

                    // Check whether it's time to evaluate a new rame
                    currentFrameTime = sink.grabFrameNoTimeout(image);
                    if (currentFrameTime == 0 || currentFrameTime == prevFrameTime) {
                        continue;
                    }
                    prevFrameTime = currentFrameTime;

                    // Process image using generated pipeline
                    pipeline.process(image);

                    // Get pipeline objects
                    ArrayList<MatOfPoint> mops = pipeline.filterContoursOutput();

                    // Evaluate objects
                    for (MatOfPoint mop : mops) {
                        Rect bRect = Imgproc.boundingRect(mop);
                        Imgproc.rectangle(image, bRect.tl(), bRect.br(), new Scalar(255, 0, 255));
                        // TODO: Evaluate objects
                    }

                    // Send the evaluated image to the output stream
                    output.putFrame(image);

                }
            });
            
            thread.start();
        }
    }
 
开发者ID:vyrotek,项目名称:frc-robot,代码行数:40,代码来源:Vision.java

示例15: floodFill

import org.opencv.core.Rect; //导入依赖的package包/类
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;
}
 
开发者ID:RaiMan,项目名称:Sikulix2opencv,代码行数:8,代码来源:Imgproc.java


注:本文中的org.opencv.core.Rect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。