Running Pigo in Python example

This commit is contained in:
Endre Simo
2019-02-02 14:02:10 +02:00
parent 721cec1e9b
commit 3ce4f3795c
6 changed files with 0 additions and 0 deletions

28
examples/web/capture.py Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python2
import cv2
import imutils
from imutils.video import VideoStream
import time, sys
vs = VideoStream(resolution=(320, 240)).start()
time.sleep(1.0)
while(True):
frame = vs.read()
frame = imutils.resize(frame, width=640, height=480)
#cv2.imshow('frame',frame)
res = bytearray(cv2.imencode(".jpeg", frame)[1])
size = str(len(res))
sys.stdout.write("Content-Type: image/jpeg\r\n")
sys.stdout.write("Content-Length: " + size + "\r\n\r\n")
sys.stdout.write( res )
sys.stdout.write("\r\n")
sys.stdout.write("--informs\r\n")
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
vs.stop()