INNER CODE UNIT · Python
image
vietnh1009/QuickDraw · camera_app.py:89
image = canvas_gs[y:y + h, x:x + w]
image = cv2.resize(image, (28, 28))
image = np.array(image, dtype=np.float32)[None, None, :, :]
image = torch.from_numpy(image)
logits = model(image)
predicted_class = torch.argmax(logits[0])
# print (CLASSES[predicted_class])
is_shown = True
else:
print("The object drawn is too small. Please draw a bigger one!")
points = deque(maxlen=512)
canvas = np.zeros((480, 640, 3), dtype=np.uint8)
# Read frame from camera
ret, frame = camera.read()
frame = cv2.flip(frame, 1)
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
kernel = np.ones((5, 5), np.uint8)