Camera makes mirror image

I didn’t notice this before, but the Camera feature in Codea is making mirror images with the back (outward facing) camera, ie they are flipped on the x axis. This happens in the Camera demo app and my own apps using the camera. The front camera (that shows our ugly faces) isn’t doing this.

Has anyone else noticed this?

Makes sense - the outward facing camera is designed for FaceTime.

To flip the image make the width of the camera sprite negative.

From the camera demo, line 41 becomes


    sprite( CAMERA, WIDTH/2, HEIGHT/2, -math.min( camWidth, WIDTH ),math.min( camHeight, HEIGHT ) )

that’s neat, cool, thanks

the explanation doesn’t make sense to me, though, because when I use the camera outside of Codea, it doesn’t flip the image…

and I think an explanation is needed inside the Camera app to show how to flip it back the right way, because I can’t think of many apps that will use a flipped image

Yeah I noticed that too so when I’d made a shader for the camera filter I had flipped the X coordinates. And even in your motion detection program if you swipe left it shows right(it was like that the last time i saw not sure if you updated it), the same reason may

no wonder I couldn’t get it to work properly (although I was working with the front camera, which doesn’t flip the image)

@sorry, my mistake - I was getting front and back camera mixed up

You’re right - I don’t know why it mirrors - I’m guessing the same code is used for both cameras and TLL and it was tested using the forward camera

Apologies for this — it’s a bug that came about when we normalised texture coordinates between iOS native loaded images and Codea’s image() type. I’m pretty sure I can fix this one by the next update.

One more point to raise:

The reason the front camera is mirrored (which comes out as not-mirrored in Codea due to this bug) is because Apple’s front camera stream is automatically mirrored so it behaves more like looking into an actual mirror — this is to make capturing self-portraits less disconcerting. You can try this out in Photo Booth. However Apple then flips the image once it is actually captured and saved to disk.

My thought is to copy Apple’s default behaviour, which would result in both camera images mirroring from what they currently are right now. The back camera would produce an un-mirrored stream, and the front would generate a mirrored stream.

Thanks, Simeon

I would guess the default should be the same as the normal view from the iPad camera app, to avoid confusion. If the demo project then explains how to flip the image as per West’s solution above, then we have the choice of which way to show the image. But I would start from what is expected.

Oh please keep it the same as it is my code is heavyly dependent of the flipped camera

@Mnjk78lg - see fix above, it just takes a minus sign to flip it