Slide 223
Slide 223 text
class Camera(object):
●
def __init__(self):
●
self.video = cv2.VideoCapture(0)
●
self.video.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 320)
●
self.video.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 240)
●
●
def get_frame(self):
●
success, frame = self.video.read()
●
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
●
faces = faceCascade.detectMultiScale(
●
gray,
●
scaleFactor=1.1,
●
minNeighbors=5,
●
minSize=(30, 30),
●
flags=cv2.cv.CV_HAAR_SCALE_IMAGE
●
)
●
for (x, y, w, h) in faces:
●
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
●
ret, jpeg = cv2.imencode('.jpg', frame)
●
return np.array(jpeg).tostring()
Camera + OpenCV + HTTP Streaming
$ vi camera_pi.py