Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pygame shows image letters mirrored

Can you please help me understand why pygame shows my image as mirrored? Please see the attached image for more info:

enter image description here

I am capturing an image from PiCamera into PiRGBArray stream, then creating a pygame surface module and displaying the image.

This is the code:

camera = PiCamera()
camera.resolution = (640, 480)
rawCapture = PiRGBArray(camera, size=(640, 480))

pygame.init()
lcdDisplay = pygame.display.set_mode((480,640))

for frame in camera.capture_continuous(rawCapture, format="rgb", 
    image = frame.array

    surf=pygame.surfarray.make_surface(image)
    lcdDisplay.blit(surf, (0,0))    

    pygame.display.update()
    pygame.display.flip()

    # clear the stream 
    rawCapture.truncate(0)
like image 588
haykp Avatar asked Dec 18 '25 09:12

haykp


1 Answers

You're capturing the image from a camera, and a camera is not a mirror :-)

Think of it this way: if the camera is facing front, and you take a picture, it'll look "correct". If you flip it to face it towards you, the image is flipped.

This is not related to pygame, it's just how cameras (webcams) work.

like image 127
ChatterOne Avatar answered Dec 20 '25 21:12

ChatterOne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!