回答編集履歴
2
補足
test
CHANGED
@@ -25,3 +25,15 @@
|
|
25
25
|
+model.train(samples, cv2.ml.ROW_SAMPLE, responses)
|
26
26
|
|
27
27
|
```
|
28
|
+
|
29
|
+
あと`im = cv2.imread('pi.png')`の戻り値は絶対にチェックしてください。
|
30
|
+
|
31
|
+
```Python
|
32
|
+
|
33
|
+
assert im is not None, 'cannot open file as image.'
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
◇参考情報
|
38
|
+
|
39
|
+
[python opencvでグレースケール変換を行いたい](https://teratail.com/questions/134267)
|
1
追記
test
CHANGED
@@ -7,3 +7,21 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
[OpenCV 3.4.1: KNearest function not found](https://stackoverflow.com/questions/51145691/opencv-3-4-1-knearest-function-not-found)
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
「TypeError: only size-1 arrays can be converted to Python scalars」で検索すると
|
16
|
+
|
17
|
+
[KNN train() in cv2 with opencv 3.0](https://stackoverflow.com/questions/32980675/knn-train-in-cv2-with-opencv-3-0)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```diff
|
22
|
+
|
23
|
+
-model.train(samples, responses)
|
24
|
+
|
25
|
+
+model.train(samples, cv2.ml.ROW_SAMPLE, responses)
|
26
|
+
|
27
|
+
```
|