Skip to content

Instantly share code, notes, and snippets.

@rueedlinger
Last active November 25, 2016 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rueedlinger/47fa1b49a9ab451da7384cfda66fa0f6 to your computer and use it in GitHub Desktop.
Save rueedlinger/47fa1b49a9ab451da7384cfda66fa0f6 to your computer and use it in GitHub Desktop.
Raspberry Pi and OpenCV
#!/bin/bash
fswebcam -r 800x600 input.jpg
#!/usr/bin/env python2
import numpy as np
import cv2
print(cv2.__version__)
# install opencv-data
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
img = cv2.imread('input.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
print('face found:', x, y)
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
cv2.imwrite('output.jpg', img)
#!/bin/bash
cd /home/pi
wget https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment