make_img.py 380 Bytes
from numpy import array, savetxt
from PIL import Image
import sys
import picamera
import time

camera = picamera.PiCamera()

camera.start_preview()
time.sleep(3)
camera.stop_preview()

filename = 'image.jpg'
camera.capture(filename)

img = array(Image.open(filename).resize((32,32), Image.ANTIALIAS)).transpose(2,0,1).flatten()

savetxt('input.txt', img, fmt='%d', delimiter=' ')