Circle detection opencv
I'll start with the Hough line transform.

The hough transform works by creating a buffer (2 dimensional in our case) which represents all the possible lines in the image. 

Any possible line can be represented with those 2 numbers $(\rho, \theta)$

From wikipedia



Note this uses polar coordinates to avoid division by zero issues rather than your typical $y = mx + c$ for a line

The hough transform scans an image and casts votes into the 2 dimensional buffer corresponding to $(\rho, \theta)$ values.

The buffer slots that accumulate the most votes are likely to be attributed to the presence of a line for that $(\rho, \theta)$ value.

That's the basic idea of the Hough transform but it can get more complicated from here. 

For selecting $(\rho, \theta)$ values from the buffer, methods can get more sophisticated, such as using kernel density estimation. Although I don't think opencv does that.

In the case of the Hough circle transform, we now have a 3 dimensional buffer. 
$(x, y, r)$

Where 

$x, y $:  coordinates of center of circle

$r $: radius

Now in practice there's more to making the Hough transform work than this.

Take a look at the source code for the icvHoughCirclesGradient function.

Its here 

Also cvHoughCircles and cv::HoughCircles

you can see that the function is also doing canny edge detection and sobel filtering.

These operations have their own input parameters which you can also see as inputs to the hough function. 

Examining the function signature

void cv::HoughCircles( InputArray _image, OutputArray _circles,
int method, double dp, double min_dist,
double param1, double param2,
int minRadius, int maxRadius )


Method: There seems to be only on method now, probably left this for future development

dp: this is the resolution of the votes buffer

min_dist : is the minimum distance between circles (ie: circles that are too close must be part of the same circle)

minRadius and maxRadius are just that.

param1 and param2 are a bit more cryptic

but if you spot the lines 

int canny_threshold = cvRound(param1);
int acc_threshold = cvRound(param2);


You'll see these are related to the canny edge detection and the accumulator threshold for selecting a circle from votes.