Gra*_*y D 1 python webcam opencv
我不确定问题是什么,但是当我在网络摄像头上四处走动时,它会捕捉到我的脸,但它不是我动作的镜子,而是向后/倒转。
有谁知道如何解决这一问题?
def Webcam(webcam, classifier, downScale):
if webcam.isOpened():
rval, frame = webcam.read()
else:
rval = False
while rval:
# detect faces and draw bounding boxes
minisize = (frame.shape[1]/downScale,frame.shape[0]/downScale)
miniframe = cv2.resize(frame, minisize)
faces = classifier.detectMultiScale(miniframe)
for f in faces:
x, y, w, h = [ v*downScale for v in f ]
cv2.rectangle(frame, (x,y), (x+w,y+h), (0,0,255))
cv2.putText(frame, "Press ESC to close.", (5, 25),
cv2.FONT_HERSHEY_SIMPLEX, 1.0, (255,255,255))
cv2.imshow("Face Crop", frame)
# get next frame
rval, frame = webcam.read()
key = cv2.waitKey(10)
if key in [27, ord('Q'), ord('q')]: # exit on ESC
break
Run Code Online (Sandbox Code Playgroud)
相机不是镜子。
但是您可以轻松翻转()使其表现得像一面镜子:
rval, frame = webcam.read()
frame = cv2.flip(frame,1)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6011 次 |
| 最近记录: |