質問編集履歴

1

エラー内容は解決したが、実行が行えていない。

2020/07/12 13:11

投稿

obakoh
obakoh

スコア11

test CHANGED
File without changes
test CHANGED
@@ -5,6 +5,8 @@
5
5
  https://www.pc-koubou.jp/magazine/21280
6
6
 
7
7
  このサイトを参考にしながらカスケード分類器を作成し、作成した分類器で画像から人物検出しようとしました。
8
+
9
+ エラーは起きていないのですが画像が表示されません。なぜなのでしょうか??
8
10
 
9
11
 
10
12
 
@@ -14,13 +16,11 @@
14
16
 
15
17
 
16
18
 
17
- File "<ipython-input-1-ae5277c76afa>", line 3
19
+ ()
18
20
 
19
- img = cv.imread('3374709_s.jpg')
20
21
 
21
- ^
22
22
 
23
- IndentationError: unexpected indent
23
+ と表示されていてエラーは起きていない。
24
24
 
25
25
 
26
26
 
@@ -32,38 +32,38 @@
32
32
 
33
33
 
34
34
 
35
- img = cv.imread('3374709_s.jpg')
35
+ img = cv.imread('3374709_s.jpg')
36
36
 
37
37
 
38
38
 
39
- grayimg = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
39
+ grayimg = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
40
40
 
41
41
 
42
42
 
43
- custom_cascade = cv.CascadeClassifier('cascade.xml')
43
+ custom_cascade = cv.CascadeClassifier('cascade.xml')
44
44
 
45
45
 
46
46
 
47
- custom_rect = custom_cascade.detectMultiScale(grayimg, scaleFactor=1.07, minNeighbors=2, minSize=(1, 1))
47
+ custom_rect = custom_cascade.detectMultiScale(grayimg, scaleFactor=1.07, minNeighbors=2,minSize=(1, 1))
48
+
49
+
50
+
51
+ print(custom_rect)
48
52
 
49
53
 
50
54
 
55
+ if len(custom_rect) > 0:
56
+
51
- print(custom_rect)
57
+ for rect in custom_rect:
58
+
59
+ cv.rectangle(img, tuple(rect[0:2]), tuple(rect[0:2]+rect[2:4]), (0, 0, 255), thickness=3)
52
60
 
53
61
 
54
62
 
55
- if len(custom_rect) > 0:
63
+ cv.imshow('image', img)
56
-
57
- for rect in custom_rect:
58
-
59
- cv.rectangle(img, tuple(rect[0:2]), tuple(rect[0:2]+rect[2:4]), (0, 0, 255), thickness=3)
60
64
 
61
65
 
62
66
 
63
- cv.imshow('image', img)
67
+ cv.waitKey(0)
64
68
 
65
-
66
-
67
- cv.waitKey(0)
68
-
69
- cv.destroyAllWindows()
69
+ cv.destroyAllWindows()