import matplotlib.pyplot as plt import time from skimage.feature import hog from skimage import data, exposure import face_recognition import cv2 image = data.astronaut() image = face_recognition.load_image_file("testimage.png") face_location = face_recognition.face_locations(image) # print(image) fd, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16), cells_per_block=(1, 1), visualize=True, multichannel=True) fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4), sharex=True, sharey=True) ax1.axis('off') ax1.imshow(image, cmap=plt.cm.gray) ax1.set_title('Input image') # Rescale histogram for better display hog_image_rescaled = exposure.rescale_intensity(hog_image, in_range=(0, 10)) ax2.axis('off') ax2.imshow(hog_image_rescaled, cmap=plt.cm.gray) ax2.set_title('Histogram of Oriented Gradients') plt.show() print('done') # # Display the results # (top, right, bottom, left) = face_location[0] # # Scale back up face locations since the frame we detected in was scaled to 1/4 size # top *= 4 # right *= 4 # bottom *= 4 # left *= 4 # # Draw a box around the face # cv2.rectangle(image, (left, top), (right, bottom), (0, 0, 255), 2) # # Draw a label with a name below the face # cv2.rectangle(image, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED) # font = cv2.FONT_HERSHEY_DUPLEX # cv2.putText(image, '...', (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1) # # Display the resulting image # cv2.imshow('Video', image) # time.sleep(10)