Orientation Issue ios Vision VNImageRequestHandler

I am trying to detect faces through the camera using VNImageRequestHandler(iOS Vision). When I point to a photo with the camera in landscape mode, it detects faces, but with the opposite orientation mode.

  let detectFaceRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, options: [:])

enter image description here

+4
source share
1 answer

Convert the image to CIImage and apply the orientation property as shown below and pass it to the imagerequest handler

let orientation = CGImagePropertyOrientation(uiImage.imageOrientation)
   let imageElement = ciImage.applyingOrientation(Int32(orientation.rawValue))

        // Show the image in the UI.
        originalImage.image = uiImage

also check https://github.com/gunapandianraj/iOS-Vision code to convert Vision rect to UIKit rect

+2
source

Source: https://habr.com/ru/post/1679852/


All Articles