-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path35_circle_detection.cpp
More file actions
37 lines (26 loc) · 962 Bytes
/
Copy path35_circle_detection.cpp
File metadata and controls
37 lines (26 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat orgimg, gryimg;
orgimg = imread("image.jpg");
cvtColor(orgimg, gryimg, COLOR_BGR2GRAY); // BGR to gray
// Gauss Filter uygula
GaussianBlur(gryimg, gryimg, Size(3, 3), 2, 2);
vector<Vec3f> circles; // 3 boyutlu float daire kordinat vektoru
HoughCircles(gryimg, circles, HOUGH_GRADIENT, 1, gryimg.rows / 8, 90, 90); // son 2 parametrenin degistilmesi daire tespitini ayarlar
for (size_t i = 0; i < circles.size(); i++)
{
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
int radius = cvRound(circles[i][2]);
circle(orgimg, center, 1, Scalar(0, 255, 0), -1, 8, 0); // original image uzerine cember ciz
circle(orgimg, center, radius, Scalar(0, 0, 255), 3, 8, 0);
}
imshow("Hough Circle", orgimg);
waitKey(0);
return 0;
}