本篇內(nèi)容介紹了“Python怎么實現(xiàn)識別圖片中的所有人臉并顯示出來”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!
業(yè)務包括:企業(yè)網(wǎng)站建設、移動網(wǎng)站建設、商城網(wǎng)站制作、網(wǎng)站營銷推廣等服務,并且涵蓋域名與空間、雅安服務器托管、云服務器、等互聯(lián)網(wǎng)基礎服務;創(chuàng)新互聯(lián)公司聯(lián)建站以互聯(lián)網(wǎng)的創(chuàng)新理念,成熟完善的建站體系,開拓進取的精神,專業(yè)的解決方案和顧問咨詢服務,幫助客戶在互聯(lián)網(wǎng)時代提升形象、把握商機、實現(xiàn)價值,提高企業(yè)的核心競爭力。
使用Python3實現(xiàn)識別圖片中的所有人臉并顯示出來,代碼如下:
# -*- coding: utf-8 -*- # 識別圖片中的所有人臉并顯示出來 # filename : find_faces_in_picture.py from PIL import Image import face_recognition # 將jpg文件加載到numpy 數(shù)組中 image = face_recognition.load_image_file("linuxidc.com.jpg") # 使用默認的給予HOG模型查找圖像中所有人臉 # 這個方法已經(jīng)相當準確了,但還是不如CNN模型那么準確,因為沒有使用GPU加速 # 另請參見: find_faces_in_picture_cnn.py face_locations = face_recognition.face_locations(image) # 使用CNN模型 # face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=0, model="cnn") # 打?。何覐膱D片中找到了 多少 張人臉 print("I found {} face(s) in this photograph.".format(len(face_locations))) # 循環(huán)找到的所有人臉 for face_location in face_locations: # 打印每張臉的位置信息 top, right, bottom, left = face_location print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right)) # 指定人臉的位置信息,然后顯示人臉圖片 face_image = image[top:bottom, left:right] pil_image = Image.fromarray(face_image) pil_image.show()
# 或者執(zhí)行python文件 $ python3 www.linuxidc.com.py
從圖片中識別出10張人臉,并顯示出來。
I found 10 face(s) in this photograph. A face is located at pixel location Top: 445, Left: 1867, Bottom: 534, Right: 1957 A face is located at pixel location Top: 544, Left: 643, Bottom: 619, Right: 718 A face is located at pixel location Top: 478, Left: 1647, Bottom: 553, Right: 1722 A face is located at pixel location Top: 504, Left: 126, Bottom: 594, Right: 215 A face is located at pixel location Top: 536, Left: 395, Bottom: 611, Right: 469 A face is located at pixel location Top: 544, Left: 1042, Bottom: 619, Right: 1116 A face is located at pixel location Top: 553, Left: 818, Bottom: 627, Right: 892 A face is located at pixel location Top: 511, Left: 1431, Bottom: 586, Right: 1506 A face is located at pixel location Top: 564, Left: 1227, Bottom: 626, Right: 1289 A face is located at pixel location Top: 965, Left: 498, Bottom: 1017, Right: 550
如下圖:
“Python怎么實現(xiàn)識別圖片中的所有人臉并顯示出來”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
名稱欄目:Python怎么實現(xiàn)識別圖片中的所有人臉并顯示出來
網(wǎng)頁網(wǎng)址:http://aaarwkj.com/article34/jpoppe.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供域名注冊、搜索引擎優(yōu)化、面包屑導航、企業(yè)網(wǎng)站制作、自適應網(wǎng)站、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)