ios - AVCaptureStillImageOutput Image orientation is wrong -
i'm running avcapturesession
still images on user action (button press). i've problem orientation rotated 90 degree although set values :
- (void)setupavcapture { //capture session _session = nil; _session = [[avcapturesession alloc] init]; [_session setsessionpreset:avcapturesessionpreset1280x720]; //preview view self.previewlayer = nil; self.previewlayer = [[avcapturevideopreviewlayer alloc] initwithsession:_session]; [self.previewlayer setvideogravity:avlayervideogravityresizeaspectfill]; calayer *rootlayer = [_previewview layer]; [rootlayer setmaskstobounds:yes]; [[_previewlayer connection]setvideoorientation:avcapturevideoorientationportrait]; }
and
- (ibaction)captureimage:(id)sender { avcaptureconnection *stillimageconnection = [stillimageoutput connectionwithmediatype:avmediatypevideo]; [stillimageconnection setvideoorientation:avcapturevideoorientationportrait]; [stillimageoutput capturestillimageasynchronouslyfromconnection:stillimageconnection completionhandler:^(cmsamplebufferref imagedatasamplebuffer, nserror *error) { if (imagedatasamplebuffer != nil) { nsdata *imagedata = [avcapturestillimageoutput jpegstillimagensdatarepresentation:imagedatasamplebuffer]; cgdataproviderref dataprovider = cgdataprovidercreatewithcfdata((cfdataref)imagedata); cgimageref cgimageref = cgimagecreatewithjpegdataprovider (dataprovider, nil, yes, kcgrenderingintentdefault); _capturedimage = [uiimage imagewithcgimage:cgimageref scale:1.0 orientation:uiimageorientationup]; } }];
thanks in advance
try uiimageorientationleft orientation.
Comments
Post a Comment