(frame, face_cascade, minsize=(30, 30))
return success, frame[y:y+h, x:x+w]
Attempts to find faces in the image, and crops the largets.
	
	Arguments

	frame			-	A numpy.ndarray with unsigned, 8-bit
					integers that reflect the greyscale values
					of the image.
	
	Keyword Arguments
	
	minsize		-	A (w,h) tuple that indicates what size a
					face should minimally be. Default = (30,30)
	
	Returns
	
	success, crop	-	success is a Boolean that indicates whether
					a face could be detected in the frame.
					crop is a numpy.ndarray with unsigned,
					8-bit integers that reflect the greyscale
					values of the largest rect in the image
					where a face could be detected.
Attempts to find faces in the image, and crops the largets.
	
	Arguments
Attempts to find faces in the image and crops the largets . Arguments
def _crop_face(frame, face_cascade, minsize=(30, 30)):
	
	"""Attempts to find faces in the image, and crops the largets.
	
	Arguments

	frame			-	A numpy.ndarray with unsigned, 8-bit
					integers that reflect the greyscale values
					of the image.
	
	Keyword Arguments
	
	minsize		-	A (w,h) tuple that indicates what size a
					face should minimally be. Default = (30,30)
	
	Returns
	
	success, crop	-	success is a Boolean that indicates whether
					a face could be detected in the frame.
					crop is a numpy.ndarray with unsigned,
					8-bit integers that reflect the greyscale
					values of the largest rect in the image
					where a face could be detected.
	"""
	
	# Return straight away when frame==None
	if frame is None:
		return False, None
	
	# Find all potential faces in the frame.
	faces = face_cascade.detectMultiScale(
		frame,
		scaleFactor=1.1,
		minNeighbors=5,
		minSize=minsize,
		flags = cv2.cv.CV_HAAR_SCALE_IMAGE
		)
	
	# Find out what the largest face is (this is assumed to be the
	# actual face when multiple faces are present).
	if len(faces) == 0:
		success = False
		x, y, w, h = 0, 0, frame.shape[1], frame.shape[0]
	else:
		success = True
		lh = 0
		for i in range(len(faces)):
			if faces[i][3] > lh:
				x, y, w, h = faces[i]

	# In DEBUG mode, draw the original frame and the detected faces.
	if _DEBUG:
		# Display the frame in the top-left pane.
		_AX[0][0].set_title("potential faces")
		_AX[0][0].imshow(frame, cmap='gray')
		for i in range(len(faces)):
			r = faces[i]
			_AX[0][0].add_patch(patches.Rectangle( \
				(r[0],r[1]), r[2], r[3], fill=False, linewidth=1))
		_AX[0][0].add_patch(patches.Rectangle( \
			(x,y), w, h, fill=False, linewidth=3))
	
	# Return the cropped frame.
	return success, frame[y:y+h, x:x+w]
def _crop_face ( frame , face_cascade , minsize = ( 30 , 30 ) ) : # Return straight away when frame==None if frame is None : return False , None # Find all potential faces in the frame. faces = face_cascade . detectMultiScale ( frame , scaleFactor = 1.1 , minNeighbors = 5 , minSize = minsize , flags = cv2 . cv . CV_HAAR_SCALE_IMAGE ) # Find out what the largest face is (this is assumed to be the # actual face when multiple faces are present). if len ( faces ) == 0 : success = False x , y , w , h = 0 , 0 , frame . shape [ 1 ] , frame . shape [ 0 ] else : success = True lh = 0 for i in range ( len ( faces ) ) : if faces [ i ] [ 3 ] > lh : x , y , w , h = faces [ i ] # In DEBUG mode, draw the original frame and the detected faces. if _DEBUG : # Display the frame in the top-left pane. _AX [ 0 ] [ 0 ] . set_title ( "potential faces" ) _AX [ 0 ] [ 0 ] . imshow ( frame , cmap = 'gray' ) for i in range ( len ( faces ) ) : r = faces [ i ] _AX [ 0 ] [ 0 ] . add_patch ( patches . Rectangle ( ( r [ 0 ] , r [ 1 ] ) , r [ 2 ] , r [ 3 ] , fill = False , linewidth = 1 ) ) _AX [ 0 ] [ 0 ] . add_patch ( patches . Rectangle ( ( x , y ) , w , h , fill = False , linewidth = 3 ) ) # Return the cropped frame. return success , frame [ y : y + h , x : x + w ]