本文整理汇总了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;
}
示例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();
}
示例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);
}