I'm trying to use Apple Vision VNDetectHorizonRequest class for detecting the horizon line on photo. However, it won't seem to return any results. I tried multiple images and it won't detect anything. Am I misusing it?
let inputImage = NSImage(contentsOf: URL(filePath: "../path/to/horizon-sample.jpeg"))!
let cgImage = inputImage.cgImage(forProposedRect:nil, context:nil, hints:nil)!
let imageRequestHandler = VNImageRequestHandler(cgImage: cgImage)
let horReq = VNDetectHorizonRequest()
{ req, err in
if let error = err {
print("error:", error)
return
}
print("done horizon results:", req.results)
}
try imageRequestHandler.perform([horReq])
This prints:
done horizon results: Optional([])
Here is the images I tried (in full resolution: