Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tesseract OCR LED/LCD display text recognition #4274

Open
NandhiniYeganathan opened this issue Jun 26, 2024 · 0 comments
Open

Tesseract OCR LED/LCD display text recognition #4274

NandhiniYeganathan opened this issue Jun 26, 2024 · 0 comments

Comments

@NandhiniYeganathan
Copy link

NandhiniYeganathan commented Jun 26, 2024

Current Behavior

Hi All,
I am trying to detect the numeric values from the digital display LED/LCD(Remote and other devices). Integrated the tesseract along with GPUImage and used the trained data. But it's not giving a proper result. Integration using Swift(iOS).

Here is the code:

let tesseract: G8Tesseract = G8Tesseract(language: "eng")!


tesseract.delegate = self


tesseract.charWhitelist = "0123456789:"


tesseract.charBlacklist = "abcdefghijklmnopqrstuvwxyz_+-=/?.,><()*&^%$#@!:;"


let imageCheck = UIImage(named: "remote1.jpg")//Sample image, but we need to capture the image from camera then used it


let scaledImage = newImage?.scaledImage(1000)

let preprocessedImage = scaledImage?.preprocessedImage() ?? scaledImage

if let tesseract = G8Tesseract(language: "eng") {

tesseract.engineMode = .tesseractOnly

tesseract.pageSegmentationMode = .auto
//Auto Adjustment to Input Image
var inputImage = CIImage(image: preprocessedImage!)
let options:[CIImageAutoAdjustmentOption : AnyObject] = [.enhance:1 as AnyObject]
let filters = inputImage!.autoAdjustmentFilters(options: options)

    for filter: CIFilter in filters {
       filter.setValue(inputImage, forKey: kCIInputImageKey)
   inputImage =  filter.outputImage
      }
    let cgImage = context.createCGImage(inputImage!, from: inputImage!.extent)
    tesseract.image =  UIImage(cgImage: cgImage!)

    //Apply noir Filter
    let currentFilter = CIFilter(name: "CIPhotoEffectTonal")
    currentFilter!.setValue(CIImage(image: UIImage(cgImage: cgImage!)), forKey: kCIInputImageKey)

    let output = currentFilter!.outputImage
    let cgimg = context.createCGImage(output!, from: output!.extent)
    let processedImage = UIImage(cgImage: cgimg!)
    tesseract.image = processedImage
   // tesseract.image = preprocessedImage!
    tesseract.recognize()
    debugPrint("Text: \(String(describing: tesseract.recognizedText))")

}
Scaled image reference get from: https://www.kodeco.com/2010498-tesseract-ocr-tutorial-for-ios

O/P which is am getting:
Optional(" 9 9\n 11593 7\n 1 80\n \n0\n5533\n\n")"

remote1

Expected Behavior

Expected Output: 25, 5:21

Suggested Fix

No response

tesseract -v

No response

Operating System

macOS 14 Sonoma

Other Operating System

No response

uname -a

No response

Compiler

No response

CPU

No response

Virtualization / Containers

No response

Other Information

Could you please anyone guide me to resolve this

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant