Python/OpenCV网络摄像头向后移动

2024-06-25 05:22:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我不知道是什么问题,但当我在网络摄像头上移动时,它捕捉到了我的脸,但它不是我动作的镜子,而是向后/反向的。在

有人知道怎么解决这个问题吗?在

def网络摄像头(网络摄像头、分类器、低比例):

    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   

Tags: in网络forreadifcv2frame摄像头