Merge pull request #4112 from sturkmen72:patch-1
This commit is contained in:
commit
0c67c6c136
@ -1689,6 +1689,7 @@ See the line detection example below:
|
|||||||
#include <opencv2/highgui.hpp>
|
#include <opencv2/highgui.hpp>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -1774,18 +1775,19 @@ Example: :
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Mat img, gray;
|
Mat img, gray;
|
||||||
if( argc != 2 && !(img=imread(argv[1], 1)).data)
|
if( argc != 2 || !(img=imread(argv[1], 1)).data)
|
||||||
return -1;
|
return -1;
|
||||||
cvtColor(img, gray, COLOR_BGR2GRAY);
|
cvtColor(img, gray, COLOR_BGR2GRAY);
|
||||||
// smooth it, otherwise a lot of false circles may be detected
|
// smooth it, otherwise a lot of false circles may be detected
|
||||||
GaussianBlur( gray, gray, Size(9, 9), 2, 2 );
|
GaussianBlur( gray, gray, Size(9, 9), 2, 2 );
|
||||||
vector<Vec3f> circles;
|
vector<Vec3f> circles;
|
||||||
HoughCircles(gray, circles, HOUGH_GRADIENT,
|
HoughCircles(gray, circles, HOUGH_GRADIENT,
|
||||||
2, gray->rows/4, 200, 100 );
|
2, gray.rows/4, 200, 100 );
|
||||||
for( size_t i = 0; i < circles.size(); i++ )
|
for( size_t i = 0; i < circles.size(); i++ )
|
||||||
{
|
{
|
||||||
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
|
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
|
||||||
@ -1797,6 +1799,8 @@ Example: :
|
|||||||
}
|
}
|
||||||
namedWindow( "circles", 1 );
|
namedWindow( "circles", 1 );
|
||||||
imshow( "circles", img );
|
imshow( "circles", img );
|
||||||
|
|
||||||
|
waitKey(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user