I can find the circle when I look for the Hoff circle on a grayscale image through opencv, but once I binarize that grayscale image through OpenCV, I can"t find the circle. Here"s some code
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image_test);
Mat srcMat=new Mat();
Utils.bitmapToMat(bitmap,srcMat);
Mat grayMat=new Mat();
//
Imgproc.cvtColor(srcMat,grayMat,Imgproc.COLOR_RGB2GRAY);
Mat binaryMat =new Mat();
//
Imgproc.threshold(grayMat,binaryMat,40,255,Imgproc.THRESH_BINARY);
// grayMat binaryMat
Mat effectMat = OpenCvHelper.findEffectArea(grayMat, 5, 20, 5,
seekbarWidth.getProgress(),
seekbarHeight.getProgress(),
seekbarIntervalx.getProgress(),
seekbarIntervaly.getProgress());
if (effectMat == null) {
Toast.makeText(this, "", Toast.LENGTH_SHORT).show();
return;
}
mImage.setImageBitmap(mat2Bitmap(effectMat));
here is the code to find the circle in OpencvHelper.findEffectArea ():
Mat matchAnchorMat = new Mat();
Imgproc.HoughCircles(mat, matchAnchorMat, Imgproc.CV_HOUGH_GRADIENT, 1, minDist, param1, param2, minRadius, maxRadius);
int size = matchAnchorMat.cols();
Log.w(TAG,"findCircle() :"+size);
List<CircleInfo> pointList = new ArrayList<>();
for (int i = 0; i < size; iPP) {
double[] data = matchAnchorMat.get(0, i);
CircleInfo circleInfo = new CircleInfo(data[0], data[1], data[2]);
pointList.add(circleInfo);
}
return pointList;