-
-
Save ageitgey/1c1cb1c60ace321868f7410d48c228e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import dlib | |
from skimage import io | |
# Take the image file name from the command line | |
file_name = sys.argv[1] | |
# Create a HOG face detector using the built-in dlib class | |
face_detector = dlib.get_frontal_face_detector() | |
win = dlib.image_window() | |
# Load the image into an array | |
image = io.imread(file_name) | |
# Run the HOG face detector on the image data. | |
# The result will be the bounding boxes of the faces in our image. | |
detected_faces = face_detector(image, 1) | |
print("I found {} faces in the file {}".format(len(detected_faces), file_name)) | |
# Open a window on the desktop showing the image | |
win.set_image(image) | |
# Loop through each face we found in the image | |
for i, face_rect in enumerate(detected_faces): | |
# Detected faces are returned as an object with the coordinates | |
# of the top, left, right and bottom edges | |
print("- Face #{} found at Left: {} Top: {} Right: {} Bottom: {}".format(i, face_rect.left(), face_rect.top(), face_rect.right(), face_rect.bottom())) | |
# Draw a box around each face we found | |
win.add_overlay(face_rect) | |
# Wait until the user hits <enter> to close the window | |
dlib.hit_enter_to_continue() |
ELHoussineT
commented
May 26, 2023
via email
Its working.
…On Fri, 26 May 2023, 17:18 Daruin Herrera, ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
import os
import sys
import dlib
from skimage import io, exposure
from skimage.feature import hog
import cv2
import matplotlib.pyplot as plt
main = os.path.abspath(sys.argv[0])
file_name = os.path.abspath(os.path.join(os.path.dirname(main),
"examples","faces","2.jpg"))
Contruye histograma de un rostros para identificación
image = cv2.imread(file_name)
fd, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16),
cells_per_block=(1, 1), visualize=True, channel_axis=2)
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,
20))
ax2.axis('off')
ax2.imshow(hog_image_rescaled, cmap=plt.cm.gray)
ax2.set_title('Histogram of Oriented Gradients')
plt.show()
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/ageitgey/1c1cb1c60ace321868f7410d48c228e1#gistcomment-4580744>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE5NYIOG5RA6PNC4JJ6W4O3XIDCUDBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVAZTQMJQGQ4TQMFHORZGSZ3HMVZKMY3SMVQXIZI>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment