In [1]:
import cv2
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [7]:
img = np.ones((100,100,3))
In [8]:
plt.imshow(img)
Out[8]:
In [11]:
_ = cv2.rectangle(img, (0,0), (50,50), (0,0,255), 2)
In [12]:
plt.imshow(img)
Out[12]:
In [13]:
classifier = cv2.CascadeClassifier('C:\ProgramData\Anaconda3\Lib\site-packages\cv2\data\haarcascade_frontalface_default.xml')
In [29]:
In [30]:
w, h, c = img.shape
print(img.shape)
In [ ]:
In [21]:
# img = cv2.resize((int(w*0.5),int(h*0.5)))
In [40]:
img.shape
Out[40]:
In [37]:
img = cv2.imread('e:/pics/test/a1.jpg')
#
# D:\\project\\ml\\deep\\faceai\\faceai\\img\\xingye-1.png
gray =cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
face = classifier.detectMultiScale(gray, scaleFactor=1.2, minNeighbors=3, minSize=(32, 32))
for rect in face:
x,y,w,h = rect
cv2.rectangle(img, (x,y), (x+h,y+w), (0,255,0),2)
In [38]:
face
Out[38]:
In [25]:
In [27]:
type(img)
Out[27]:
In [39]:
plt.imshow(img[:,:,::-1])
Out[39]:
In [ ]: