minSize = (30, 30))
	frameClone = frame.copy()

	new_hat = frameClone.copy()
	cv2.rectangle(new_hat, (0,0), (new_hat.shape[1],new_hat.shape[0]), 
		(255, 255, 255), -1)

	# loop over the face bounding boxes and draw them
	for (x, y, w, h) in faceRects:
		# cv2.rectangle(frameClone, (x, y), (x + w, y + h), (0, 255, 0), 2)
		
		if 1.4 * w < 80:
			width = 80
		else:
			width = int(1.4 * w)
		resized_hat = imutils.resize(hat, width = width)
		if (y + 0.25 * resized_hat.shape[0]) > resized_hat.shape[0] and (x - 5 + resized_hat.shape[1]) < frameClone.shape[1]:
			fix = 1
			x_offset = x - 5
			y_offset = y - 0.75 * resized_hat.shape[0]
			new_hat[y_offset:y_offset + resized_hat.shape[0], 
				x_offset:x_offset + resized_hat.shape[1]] = resized_hat
			gray_hat = cv2.cvtColor(new_hat, cv2.COLOR_BGR2GRAY)
			# blurred_hat = cv2.GaussianBlur(gray_hat, (3,3), 0)
			# edged_hat = cv2.Canny(gray_hat, 169, 255)
			edged_hat = auto_canny.auto_canny(gray_hat)
		
			(_, cnts, _) = cv2.findContours(edged_hat.copy(), cv2.RETR_EXTERNAL,
				cv2.CHAIN_APPROX_SIMPLE)

			# create negative mask
	# detect faces in the image and then clone the frame
	# so tbeard we can draw on it
	faceRects = fd.detect(gray, scaleFactor = 1.1, minNeighbors = 5,
		minSize = (30, 30))
	frameClone = frame.copy()

	new_beard = frameClone.copy()
	cv2.rectangle(new_beard, (0,0), (new_beard.shape[1],new_beard.shape[0]), 
		(255, 255, 255), -1)

	# loop over the face bounding boxes and draw them
	for (x, y, w, h) in faceRects:
		# cv2.rectangle(frameClone, (x, y), (x + w, y + h), (0, 255, 0), 2)
		
		resized_beard = imutils.resize(beard, width = w)
		if (resized_beard.shape[0] + y + (3/5 * h)) < frameClone.shape[0]:
			fix = 1
			x_offset = x
			y_offset = y + (3/5 * h)
			new_beard[y_offset:y_offset + resized_beard.shape[0], 
				x_offset:x_offset + resized_beard.shape[1]] = resized_beard
			gray_beard = cv2.cvtColor(new_beard, cv2.COLOR_BGR2GRAY)
			# blurred_beard = cv2.GaussianBlur(gray_beard, (5,5), 0)
			# edged_beard = cv2.Canny(gray_beard, 169, 255)
			edged_beard = auto_canny.auto_canny(gray_beard)
			
			(_, cnts, _) = cv2.findContours(edged_beard.copy(), cv2.RETR_EXTERNAL,
				cv2.CHAIN_APPROX_SIMPLE)
		
			# print("I count {} beard(s)".format(len(cnts)))