Reputation: 10627
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.
Upvotes: 1
Views: 351
Reputation: 273600
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.
Upvotes: 2