1.使用dir和inspect查看一个module的成员、类、文件
import cv2
import inspect
print(dir(cv2))#查看所包含的函数
print(dir(inspect))#查看包含内容
结果:
2.人脸识别——人脸匹配
import cv2
import face_recognition
import matplotlib.pyplot as plt
known_image=cv2.imread("IMG_6855.JPG")
known_image=face_recognition.load_image_file("IMG_6855.JPG")
unknown_image=cv2.imread("IMG_3634.JPG")
unknown_image=face_recognition.load_image_file("IMG_3634.JPG")
known_encoding=face_recognition.face_encodings(known_image)[0]
unknown_encoding=face_recognition.face_encodings(unknown_image)[0]
results=face_recognition.compare_faces([known_encoding],unknown_encoding,tolerance=0.6)
if results[0]==True:
print("匹配成功,该未知图片与已有图片人脸可匹配!")
else:
print("匹配失败!")
print(known_encoding)
print(unknown_encoding)
plt.imshow(known_image)
plt.axis('off')
plt.show()
plt.imshow(unknown_image)
plt.axis('off')
plt.show()