本文整理匯總了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);
}