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


Java Imgproc.HoughCircles方法代码示例

本文整理汇总了Java中org.opencv.imgproc.Imgproc.HoughCircles方法的典型用法代码示例。如果您正苦于以下问题:Java Imgproc.HoughCircles方法的具体用法?Java Imgproc.HoughCircles怎么用?Java Imgproc.HoughCircles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opencv.imgproc.Imgproc的用法示例。


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

示例1: DetectCircle

import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
/**
 * Detects circles in a binary image.
 * 
 * @param threshold The thresholded mat
 * @param distance min distance between circles
 * @return matrix of detected circles
 */
public static Mat DetectCircle(Mat threshold,int distance) {

    Mat circles = new Mat();
    Imgproc.HoughCircles(threshold, circles, Imgproc.CV_HOUGH_GRADIENT,1,distance);

    return circles;
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:15,代码来源:CvProcessing.java

示例2: onCameraFrame

import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    Mat input = inputFrame.gray();
    Mat circles = new Mat();
    Imgproc.blur(input, input, new Size(7, 7), new Point(2, 2));
    Imgproc.HoughCircles(input, circles, Imgproc.CV_HOUGH_GRADIENT, 2, 100, 100, 90, 0, 1000);

    Log.i(TAG, String.valueOf("size: " + circles.cols()) + ", " + String.valueOf(circles.rows()));

    if (circles.cols() > 0) {
        for (int x=0; x < Math.min(circles.cols(), 5); x++ ) {
            double circleVec[] = circles.get(0, x);

            if (circleVec == null) {
                break;
            }

            Point center = new Point((int) circleVec[0], (int) circleVec[1]);
            int radius = (int) circleVec[2];

            Imgproc.circle(input, center, 3, new Scalar(255, 255, 255), 5);
            Imgproc.circle(input, center, radius, new Scalar(255, 255, 255), 2);
        }
    }

    circles.release();
    input.release();
    return inputFrame.rgba();
}
 
开发者ID:ahmetozlu,项目名称:real_time_circle_detection_android,代码行数:30,代码来源:MainActivity.java

示例3: HoughCircles

import org.opencv.imgproc.Imgproc; //导入方法依赖的package包/类
void HoughCircles() {
    Mat grayMat = new Mat();
    Mat cannyEdges = new Mat();
    Mat circles = new Mat();

    //Converting the image to grayscale
    Imgproc.cvtColor(originalMat, grayMat, Imgproc.COLOR_BGR2GRAY);

    Imgproc.Canny(grayMat, cannyEdges, 10, 100);

    Imgproc.HoughCircles(cannyEdges, circles, Imgproc.CV_HOUGH_GRADIENT, 1, cannyEdges.rows() / 15);//, grayMat.rows() / 8);

    Mat houghCircles = new Mat();
    houghCircles.create(cannyEdges.rows(), cannyEdges.cols(), CvType.CV_8UC1);

    //Drawing lines on the image
    for (int i = 0; i < circles.cols(); i++) {
        double[] parameters = circles.get(0, i);
        double x, y;
        int r;

        x = parameters[0];
        y = parameters[1];
        r = (int) parameters[2];

        Point center = new Point(x, y);

        //Drawing circles on an image
        Imgproc.circle(houghCircles, center, r, new Scalar(255, 0, 0), 1);
    }

    //Converting Mat back to Bitmap
    Utils.matToBitmap(houghCircles, currentBitmap);
    imageView.setImageBitmap(currentBitmap);
}
 
开发者ID:johnhany,项目名称:MOAAP,代码行数:36,代码来源:MainActivity.java


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