projectstreet-detection-docker

Docker for detecting streets. (WIP)
git clone git://archive.git.mtrnord.blog/Nordgedanken/projectstreet-detection-docker.git
Log | Files | Refs | README

face_detect.py (668B)


      1 import cv2
      2 import sys
      3 
      4 # Get user supplied values
      5 imagePath = sys.argv[1]
      6 cascPath = sys.argv[2]
      7 
      8 # Create the haar cascade
      9 faceCascade = cv2.CascadeClassifier(cascPath)
     10 
     11 # Read the image
     12 image = cv2.imread(imagePath)
     13 gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
     14 
     15 # Detect faces in the image
     16 faces = faceCascade.detectMultiScale(
     17     gray,
     18     scaleFactor=1.1,
     19     minNeighbors=5,
     20     minSize=(30, 30),
     21     flags = cv2.CASCADE_SCALE_IMAGE
     22 )
     23 
     24 print "Found {0} faces!".format(len(faces))
     25 
     26 # Draw a rectangle around the faces
     27 for (x, y, w, h) in faces:
     28     cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
     29 
     30 cv2.imwrite("/root/shared/results/image.jpeg", image)