Skip to content

Commit

Permalink
AlfredOCR
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlings committed Mar 2, 2023
1 parent d2c8cc4 commit 3e68feb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions assets/code/AlfredOCR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct AlfredOCR {
static var snap: URL!

static func run() {
fileManager.assert()
fileManager.validate()
recognizeText(in: snap)
}
}
Expand All @@ -29,7 +29,7 @@ extension AlfredOCR {
recognizeLanguage: Bool = true,
languages: [String] = languages,
recognitionLevel: VNRequestTextRecognitionLevel = .accurate,
handler: @escaping (VNRequest, Error?) -> () = recognizeTextHandler
handler: @escaping (VNRequest, Error?) -> () = ocrHandler
) {
let nsImage: NSImage = .init(byReferencing: imageURL)
guard
Expand All @@ -52,7 +52,7 @@ extension AlfredOCR {
}
}

static private func recognizeTextHandler(request: VNRequest, error: Error?) {
static private func ocrHandler(request: VNRequest, error: Error?) {
guard let observations = request.results as? [VNRecognizedTextObservation] else {
return
}
Expand All @@ -77,7 +77,7 @@ extension AlfredOCR {

extension FileManager {
@discardableResult
func assert() -> Never? {
func validate() -> Never? {
guard fileExists(atPath: PATH) else {
print("OCR Failure: Nothing to recognize")
Darwin.exit(EXIT_FAILURE)
Expand Down

0 comments on commit 3e68feb

Please sign in to comment.