//Grey level
bmpSource = ImageUtils.ConvertToGrayscale(
bmpSource );
//Median filter
bmpSource = ImageUtils.ApplyMedianFilter(
bmpSource );
//convert to format RGB 8888
bmpSource = ImageUtils.JPEGtoRGB888(
bmpSource ); //Get MAT from my bitmap Mat imgSource = new Mat(); Utils.bitmapToMat(
bmpSource , imgSource);
//grey opencv Imgproc.cvtColor(imgSource, imgSource, Imgproc.COLOR_BGR2GRAY); Mat imgCirclesOut = new Mat(); float rayon = (float)(
bmpSource.getHeight() / 4) ;
Imgproc.HoughCircles(imgSource, imgCirclesOut, Imgproc.CV_HOUGH_GRADIENT, 1, 10);//, 150, 75, (int)rayon-10, (int)rayon+10);
float circle[] = new float[3];
//retrieve circles float[][] cercles = new float[imgCirclesOut.cols()][3];
for (int i = 0; i < imgCirclesOut.cols(); i++) { imgCirclesOut.get(0, i, circle); cercles[i][0] = circle[2];// rayon cercles[i][1] = circle[0];// x center cercles[i][2] = circle[1];// y center }
HoughCircles.
Saisissez le code icibmpSource = ImageUtils.JPEGtoRGB888(bmpSource );
Mat imgSource = new Mat(), imgCirclesOut = new Mat();
Utils.bitmapToMat(bmpSource , imgSource);
//grey opencv
Imgproc.cvtColor(imgSource, imgSource, Imgproc.COLOR_BGR2GRAY);
Imgproc.GaussianBlur( imgSource, imgSource, new Size(9, 9), 2, 2 );
Imgproc.HoughCircles( imgSource, imgCirclesOut, Imgproc.CV_HOUGH_GRADIENT, 1, imgSource.rows()/8, 200, 100, 0, 0 );
float circle[] = new float[3];
Log.w("circles", imgCirclesOut.cols()+""); // Renvoi tjrs 0 !!!!!!
for (int i = 0; i < imgCirclesOut.cols(); i++)
{
imgCirclesOut.get(0, i, circle);
org.opencv.core.Point center = new org.opencv.core.Point();
center.x = circle[0];
center.y = circle[1];
Core.circle(imgSource, center, (int) circle[2], new Scalar(255, 255, 0, 255), 4);
}
Bitmap bmp = Bitmap.createBitmap(bmpSource.getWidth(), bmpSource.getHeight(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(imgSource, bmp);
...