0

I get from AR session, the current frame with: self.sceneView.session.currentFrame?.capturedImage so I get a CVPixelBuffer with my image information.

I followed this link to convert my CVPixelBuffer to CGImage. (I use previously createCGImage method but this method create a memory leak in my app.)

But I have an issue now, the CGImage received at the end is on the landscape mode and not portrait (my app allows only portrait mode) like you can see on the image below.

UIImage generated from CGImage

So I'm trying to fix this rotation. I saw vImageRotate90_ARGB8888(_:_:_:_:_:) exist but I have trouble to use it because my pointer for the backColor is always nil.

Do you have any method to rotate it without a memory leak because I have to rotate it couple times per seconde?

Thanks

A.Ozda
  • 39
  • 9
  • Create `UIImage` by using this constructor `UIImage(cgImage: CGImage, scale: CGFloat, orientation: UIImage.Orientation)` and providing the orientation `.landscape`. – Eugene Dudnyk Sep 23 '20 at 18:25
  • Thanks for your quick answer, i can't provide the orientation ```.landscape``` only ```left,up,down or right``` are accepted. When i put ```.right``` the image keep the smae aspect ration, and landscape and are like stretch. As you can see on this picture :https://ibb.co/NrZSGc5 – A.Ozda Sep 23 '20 at 19:17
  • > So I'm trying to fix this rotation. I saw vImageRotate90_ARGB8888(_:_:_:_:_:) exist but I have trouble to use it because my pointer is always nil - Which pointer did you mean? – Eugene Dudnyk Sep 23 '20 at 19:56
  • UnsafePointer,, i don't know what should i place here for the backColor – A.Ozda Sep 23 '20 at 20:14
  • https://stackoverflow.com/a/23899034/321542 this answer shows what to put there - the UInt8 array of 4 zeroes. – Eugene Dudnyk Sep 23 '20 at 20:26
  • I tried a rotation with vImageRotate, and I get this : https://ibb.co/xjRZbpj (it's my keyboard). If you have any clue – A.Ozda Sep 24 '20 at 16:03
  • Seems like your pixel format is different from ARGB8888. Try to figure out the pixel format of your pixel buffer before choosing the rotation function. – Eugene Dudnyk Sep 24 '20 at 21:38

0 Answers0