當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。