Skip to content

Commit e6c694c

Browse files
committed
fix(ios): latest Image orientation
1 parent 2572e4e commit e6c694c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/mlkit-core/platforms/ios/src/TNSMLKitHelper.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,17 +667,16 @@ public class TNSMLKitHelper: NSObject, AVCaptureVideoDataOutputSampleBufferDeleg
667667

668668
let image = VisionImage(buffer: sampleBuffer)
669669

670+
let orientation = getOrientation(deviceOrientation: UIDevice.current.orientation, cameraPosition: videoInput!.device.position)
670671

671-
image.orientation = getOrientation(deviceOrientation: UIDevice.current.orientation, cameraPosition: videoInput!.device.position)
672+
image.orientation = orientation
672673

673674
if retrieveLatestImage {
674675
let ciimage = CIImage(cvImageBuffer: buffer!)
675676

676-
if let cgImage = context.createCGImage(ciimage, from: ciimage.extent) {
677-
self._latestImage = UIImage(cgImage: cgImage)
678-
}else {
679-
self._latestImage = nil
680-
}
677+
self._latestImage = UIImage(ciImage: ciimage, scale: 1.0, orientation: orientation)
678+
} else {
679+
self._latestImage = nil
681680
}
682681

683682

0 commit comments

Comments
 (0)