質問編集履歴

2

コードを書き換えました。

2018/08/29 17:25

投稿

fufufu000
fufufu000

スコア29

test CHANGED
File without changes
test CHANGED
@@ -40,11 +40,11 @@
40
40
 
41
41
  # 先ほど集めてきた画像データのあるディレクトリ
42
42
 
43
- input_data_path = 'imaga000'
43
+ input_data_path = 'images/'
44
44
 
45
45
  # 切り抜いた画像の保存先ディレクトリ(予めディレクトリを作っておいてください)
46
46
 
47
- save_path = 'imaga111'
47
+ save_path = 'images111/'
48
48
 
49
49
  # OpenCVのデフォルトの分類器のpath。(https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xmlのファイルを使う)
50
50
 
@@ -54,9 +54,11 @@
54
54
 
55
55
 
56
56
 
57
+
58
+
57
59
  # 収集した画像の枚数(任意で変更)
58
60
 
59
- image_count = 100
61
+ images_count = 100
60
62
 
61
63
  # 顔検知に成功した数(デフォルトで0を指定)
62
64
 
@@ -66,9 +68,9 @@
66
68
 
67
69
  # 集めた画像データから顔が検知されたら、切り取り、保存する。
68
70
 
69
- for i in range(image_count):
71
+ for i in range(images_count):
70
72
 
71
- img = cv2.imread(input_data_path + str(i) + '.jpg', cv2.IMREAD_COLOR)
73
+ img = cv2.imread(input_data_path + str(i) + ".png", cv2.IMREAD_COLOR)
72
74
 
73
75
  gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
74
76
 
@@ -92,7 +94,7 @@
92
94
 
93
95
  h = rect[3]
94
96
 
95
- cv2.imwrite(save_path + 'cutted_images' + str(face_detect_count) + '.jpg', img[y:y+h, x:x+w])
97
+ cv2.imwrite(save_path + 'images' + str(face_detect_count) + '.jpg', img[y:y+h, x:x+w])
96
98
 
97
99
  face_detect_count = face_detect_count + 1
98
100
 

1

ファイルパスを変更しました。

2018/08/29 17:25

投稿

fufufu000
fufufu000

スコア29

test CHANGED
File without changes
test CHANGED
@@ -40,11 +40,11 @@
40
40
 
41
41
  # 先ほど集めてきた画像データのあるディレクトリ
42
42
 
43
- input_data_path = r"C:\Users\saito\PycharmProjects\kenkyu\images.png"
43
+ input_data_path = 'imaga000'
44
44
 
45
45
  # 切り抜いた画像の保存先ディレクトリ(予めディレクトリを作っておいてください)
46
46
 
47
- save_path = r"C:\Users\saito\PycharmProjects\kenkyu\cutted_images.png"
47
+ save_path = 'imaga111'
48
48
 
49
49
  # OpenCVのデフォルトの分類器のpath。(https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xmlのファイルを使う)
50
50