Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Jul 27, 2023
1 parent 9bb51ab commit 15de34c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func detectText(fileName : URL) -> [CIFeature]? {

// Create a new request to recognize text.
let request = VNRecognizeTextRequest(completionHandler: recognizeTextHandler)
request.recognitionLanguages = ["chi_sim", "eng"]
request.recognitionLevel = .accurate
request.recognitionLanguages = ["zh"]
request.usesLanguageCorrection = true

do {
// Perform the text-recognition request.
Expand All @@ -65,24 +67,20 @@ func supportedLanguages() {
let request = VNRecognizeTextRequest()

do {
let supportedLanguages = try request.supportedRecognitionLanguages(for: .accurate, revision: VNRecognizeTextRequest.currentRevision)
let supportedLanguages = try VNRecognizeTextRequest.supportedRecognitionLanguages(for: .accurate, revision: VNRecognizeTextRequest.currentRevision)
print("Supported languages: \(supportedLanguages)")
} catch {
print("Error getting supported languages: \(error)")
}
}

do {
supportedLanguages()
if CommandLine.argc < 2 {
print("Please provide an image path.")
} else {
// 获取图片路径
let inputURL = URL(fileURLWithPath: CommandLine.arguments[1])
if let features = detectText(fileName : inputURL), !features.isEmpty{}
}
} catch {
// handle parsing error
supportedLanguages()
if CommandLine.argc < 2 {
print("Please provide an image path.")
} else {
// 获取图片路径
let inputURL = URL(fileURLWithPath: CommandLine.arguments[1])
if let features = detectText(fileName : inputURL), !features.isEmpty{}
}

exit(EXIT_SUCCESS)

0 comments on commit 15de34c

Please sign in to comment.