質問編集履歴
1
インデントを追加したコードに編集しました。よろしくお願いいたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
from google.colab import drive
|
9
|
+
```from google.colab import drive
|
10
10
|
|
11
11
|
drive.mount('/content/drive')
|
12
12
|
|
@@ -32,24 +32,16 @@
|
|
32
32
|
|
33
33
|
def paint_chinese(im, chinese, position, fontsize, color_bgr):
|
34
34
|
|
35
|
-
|
36
|
-
|
37
35
|
img_PIL = Image.fromarray(cv2.cvtColor(im, cv2.COLOR_BGR2RGB))
|
38
36
|
|
39
37
|
font = ImageFont.truetype(
|
40
38
|
|
41
39
|
'SourceHanSansSC-Medium.otf', fontsize, encoding="utf-8")
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
41
|
color = color_bgr[::-1]
|
48
42
|
|
49
43
|
draw = ImageDraw.Draw(img_PIL)
|
50
44
|
|
51
|
-
|
52
|
-
|
53
45
|
draw.text(position, chinese, font=font, fill=color)
|
54
46
|
|
55
47
|
img = cv2.cvtColor(np.asarray(img_PIL), cv2.COLOR_RGB2BGR)
|
@@ -136,8 +128,6 @@
|
|
136
128
|
|
137
129
|
|
138
130
|
|
139
|
-
|
140
|
-
|
141
131
|
img_name = "avatar_%d.png" % (maskIndex)
|
142
132
|
|
143
133
|
path = "/content/drive/My Drive/Face/A_face/" + img_name
|
@@ -190,22 +180,14 @@
|
|
190
180
|
|
191
181
|
cv2.putText(frame_copy, label, (left, top-10), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2)
|
192
182
|
|
193
|
-
|
194
|
-
|
195
183
|
|
196
184
|
|
197
185
|
writer.write(frame_copy)
|
198
186
|
|
199
187
|
|
200
188
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
189
|
frameData['frame'] = index
|
206
190
|
|
207
|
-
|
208
|
-
|
209
191
|
frameData['data'] = maskFrameDatas
|
210
192
|
|
211
193
|
|
@@ -237,3 +219,17 @@
|
|
237
219
|
|
238
220
|
|
239
221
|
cv2.destroyAllWindows()
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
```
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
個人的にチャレンジしてみたことはindex,maskindex,fpsなどの値を変えてみたことです。frameData['frame']=index
|
230
|
+
|
231
|
+
などと書かれているので、indexの値を制限すれば取得するframe数も制限されると考えました。
|
232
|
+
|
233
|
+
ちなみにこのコードは以下のサイトから引用させていただきました。
|
234
|
+
|
235
|
+
(https://qiita.com/ebiflyyyyyyyy/items/4f8cc781a86c3f9d8700)
|