# Android OpenCV Improving detection quality

Currently I am developing an app, which will detect circles from photos. I have managed to write a code for this, but through some testing I noticed that it has trouble recognizing shape if I move phone away a bit. Can I somehow improve the result? Because I have seen as way smaller circles were detected in other peoples programs. Also I need my app to recon only 9 circles, which it does if I have more, but if the amount is smaller it crashes. Here's my detection code:

Mat mat = new Mat(bitmap.getWidth(), bitmap.getHeight(),
CvType.CV_8UC1);
Mat grayMat = new Mat(bitmap.getWidth(), bitmap.getHeight(),
CvType.CV_8UC1);

Utils.bitmapToMat(bitmap, mat);

int colorChannels = (mat.channels() == 3) ? Imgproc.COLOR_BGR2GRAY
: ((mat.channels() == 4) ? Imgproc.COLOR_BGRA2GRAY : 1);

Imgproc.cvtColor(mat, grayMat, colorChannels);

Imgproc.GaussianBlur(grayMat, grayMat, new Size(9, 9), 2, 2);

// accumulator value
double dp = 1.2d;
// minimum distance between the center coordinates of detected circles in pixels
double minDist = 100;

double param1 = 70, param2 = 72;

Mat circles = new Mat(bitmap.getWidth(),
bitmap.getHeight(), CvType.CV_8UC1);

Imgproc.HoughCircles(grayMat, circles,

int numberOfCircles = 9;

for (int i=0; i<numberOfCircles;  i++) {

double[] circleCoordinates = circles.get(0, i);

int x = (int) circleCoordinates[0], y = (int) circleCoordinates[1];

Point center = new Point(x, y);
android.graphics.Point centerC = new android.graphics.Point(x, y);