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]:
<matplotlib.image.AxesImage at 0x90b8550>

In [11]:
_ = cv2.rectangle(img, (0,0), (50,50), (0,0,255), 2)

In [12]:
plt.imshow(img)


Out[12]:
<matplotlib.image.AxesImage at 0x1aec7710>

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)


(2448, 3264, 3)

In [ ]:


In [21]:
# img = cv2.resize((int(w*0.5),int(h*0.5)))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-5da8672c27a8> in <module>()
----> 1 img = cv2.resize((int(w*0.5),int(h*0.5)))

TypeError: Required argument 'dsize' (pos 2) not found

In [40]:
img.shape


Out[40]:
(330, 500, 3)

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]:
array([[124,  65, 180, 180]], dtype=int32)

In [25]:


In [27]:
type(img)


Out[27]:
numpy.ndarray

In [39]:
plt.imshow(img[:,:,::-1])


Out[39]:
<matplotlib.image.AxesImage at 0x292a72e8>

In [ ]: