ios - Mirroring (flipping) camera preview layer -


so using avcapturesession take pictures front camera. creating previewlayer session display current image on screen.

previewlayer = avcapturevideopreviewlayer(session: session) previewlayer.videogravity = avlayervideogravityresizeaspectfill 

it works should. have problem because need implement button flip / mirror (transform) preview layer - users have choice take normal selfie picture or take mirrored one.

i have tried transforming previewlayer , kinda works. problem if rotate device, preview picture rotates in other way since transformed. (in default or other camera app picture rotates camera). has idea how achieve that?

mirroring preview layer: (i tried transforming layer , view later, same result).

@ibaction func mirrorcamera(_ sender: anyobject) {         cameramirrored = !cameramirrored   if cameramirrored {     // transforming view     self.videopreviewview.transform = cgaffinetransform(scalex: -1, y: 1);     // or layer     self.previewlayer.transform = catransform3dmakescale(-1, 1, 1);    } else {     self.videopreviewview.transform = cgaffinetransform(scalex: 1, y: 1);     self.videopreviewview.transform = catransform3dmakescale(1, 1, 1);   }         } 


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -