-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencv_test.txt
51 lines (38 loc) · 1.22 KB
/
opencv_test.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
import numpy as np
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt
cap = cv2.VideoCapture(0)
ret,frame1 = cap.read()
print(frame1)
#train_data
cap.release()
#cv2.destroyAllWindows()
cap = cv2.VideoCapture(0)
ret,frame2 = cap.read()
print(frame2)
cap.release()
cv2.destroyAllWindows()
cap = cv2.VideoCapture(0)
ret,frame3 = cap.read()
print(frame3)
cap.release()
cv2.destroyAllWindows()
#model
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10, activation='softmax'))
model.summary()
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
history = model.fit(P, train_labels, epochs=10,
validation_data=(test_images, test_labels))