Question

I am not sure what the issue is but when I move around on the webcam it captures my face but it is not a mirror of my movements, it is backwards/inverted.

Does anyone know how to fix this?

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   
Was it helpful?

Solution

a camera is not a mirror.

but you can easily flip() it to behave like a mirror:

rval, frame = webcam.read()
frame = cv2.flip(frame,1)

OTHER TIPS

rval, frame = webcam.read()

frame = cv2.flip(frame,0)

In cv2.flip() argument try using 0 if you want to flip in y axis, 1 if you want to flip in x axis and -1 if want to flip in both axes.

It's clearly mentioned in documentation provided by @berak flip()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top