 |
OpenCV
3.2.0
Open Source Computer Vision
|
An example using the Hough circle detector
#include <iostream>
using namespace std;
static void help()
{
cout << "\nThis program demonstrates circle finding with the Hough transform.\n"
"Usage:\n"
"./houghcircles <image_name>, Default is ../data/board.jpg\n" << endl;
}
int main(int argc, char** argv)
{
"{help h ||}{@image|../data/board.jpg|}"
);
if (parser.has("help"))
{
help();
return 0;
}
string filename = parser.get<string>("@image");
if(img.empty())
{
help();
cout << "can not open " << filename << endl;
return -1;
}
vector<Vec3f> circles;
100, 30, 1, 30
);
for(
size_t i = 0;
i < circles.size();
i++ )
{
}
imshow(
"detected circles", img);
return 0;
}
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition: mat.hpp:1959
@ IMREAD_COLOR
If set, always convert image to the 3 channel BGR color image.
Definition: imgcodecs.hpp:67
void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0)
Converts an image from one color space to another.
int waitKey(int delay=0)
Waits for a pressed key.
Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
@ COLOR_BGR2GRAY
convert between RGB/BGR and grayscale, color conversions
Definition: imgproc.hpp:538
void HoughCircles(InputArray image, OutputArray circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0)
Finds circles in a grayscale image using the Hough transform.
Template class for short numerical vectors, a partial case of Matx.
Definition: matx.hpp:306
void medianBlur(InputArray src, OutputArray dst, int ksize)
Blurs an image using the median filter.
@ LINE_AA
antialiased line
Definition: core.hpp:218
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
Scalar_< double > Scalar
Definition: types.hpp:606
@ HOUGH_GRADIENT
basically 21HT, described in
Definition: imgproc.hpp:473
Point2i Point
Definition: types.hpp:183
n-dimensional dense array class
Definition: mat.hpp:741
for i
Definition: modelConvert.m:63
Designed for command line parsing.
Definition: utility.hpp:735
Definition: affine.hpp:52
void circle(InputOutputArray img, Point center, int radius, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a circle.