1

I want to use the Vision framework with some images in my assets folder, but I'm struggling with initializing the URL that I need for the request handler:

let imageUrl = URL(what to put here?)
let handler = VNImageRequestHandler(url: imageUrl)

I can easily instantiate UIImage using UIImage(named: imageName) but there is no URL(named: imageName) and I can't figure out what I should use instead.

C. E.
  • 10,297
  • 10
  • 53
  • 77

1 Answers1

2

VNImageRequestHandler also has an initialiser that accepts a CGImage, use that instead.

VNImageRequestHandler(cgImage: UIImage(named: "...").cgImage!)

Outside the context of VNImageRequestHandler, getting the URL from an image in the assets does not seem possible.

Sweeper
  • 213,210
  • 22
  • 193
  • 313