Last active
June 16, 2017 05:58
-
-
Save sankarcheppali/a3c735f2742788fa6fb6a6666dabdc08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import picamera | |
import cv2 | |
import numpy | |
#Create a memory stream so photos doesn't need to be saved in a file | |
stream = io.BytesIO() | |
#Get the picture (low resolution, so it should be quite fast) | |
#Here you can also specify other parameters (e.g.:rotate the image) | |
with picamera.PiCamera() as camera: | |
camera.resolution = (320, 240) | |
camera.capture(stream, format='jpeg') | |
#Convert the picture into a numpy array | |
buff = numpy.fromstring(stream.getvalue(), dtype=numpy.uint8) | |
#Now creates an OpenCV image | |
img = cv2.imdecode(buff, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment