質問編集履歴
1
字数制限の関係で一旦findContoursが出てくる箇所まで追記しました。またforやifに「宣言が必要です」と出てきています
test
CHANGED
File without changes
|
test
CHANGED
@@ -88,6 +88,58 @@
|
|
88
88
|
|
89
89
|
|
90
90
|
|
91
|
+
Mat img_gray;
|
92
|
+
|
93
|
+
cv::cvtColor(input, img_gray, CV_BGR2GRAY);
|
94
|
+
|
95
|
+
cv::blur(img_gray, img_gray, Size(5, 5));
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
void Sobel(InputArray src, OutputArray dst, int ddepth, int xorder, int yorder, int ksize = 3, double scale = 1, double delta = 0, int borderType = BORDER_DEFFAULT);
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
//Find vertical lines. Car plates have high density of vertical lines
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
Mat img_sobel;
|
108
|
+
|
109
|
+
Sobel(img_gray, img_sobel, CV_8U, 1, 0, 3, 1, 0);
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
//threshold image
|
114
|
+
|
115
|
+
Mat img_threshold;
|
116
|
+
|
117
|
+
cv::threshold(img_sobel, img_threshold, 0, 255, CV_THRESH_OTSU + CV_THRESH_BINARY);
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
Mat element = cv::getStructuringElement(MORPH_RECT, Size(17, 3));
|
122
|
+
|
123
|
+
morphologyEx(img_threshold, img_threshold, CV_MOP_CLOSE, element);
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
//Find contours of possibles plates
|
128
|
+
|
129
|
+
vector<vector<Point>> contours;
|
130
|
+
|
131
|
+
findContours(img_threshold, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
91
143
|
```
|
92
144
|
|
93
145
|
> エラー
|