Hi everyone, I need some help with the flow of the Tesseract pre-procesing.
Here's a thermography image I'm attempting to detect:
the code I'm using in .NET is the following:
Try
' Load the image using OpenCvSharp
Dim src As Mat = Cv2.ImRead(imagePath, ImreadModes.Grayscale)
' Apply preprocessing steps
Dim processedImage As New Mat()
Cv2.Resize(src, processedImage, New Size(src.Width * size, src.Height * size)) ' Resize to double the size
Cv2.Threshold(processedImage, processedImage, threshold, maxval, ThresholdTypes.Otsu) ' Apply thresholding
' Save the preprocessed image to a temporary file on the desktop
Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim tempImagePath As String = System.IO.Path.Combine(desktopPath, "temp_image.png")
Cv2.ImWrite(tempImagePath, processedImage)
Using engine As New TesseractEngine("C:\Program Files\Tesseract-OCR\tessdata", "eng", EngineMode.Default)
' Load the preprocessed image
Using img As Pix = Pix.LoadFromFile(tempImagePath)
' Perform OCR
Using page As Page = engine.Process(img)
' Get the recognized text
Dim recognizedText As String = page.GetText()
Return recognizedText
End Using
End Using
End Using
Catch ex As Exception
Return "Error performing OCR: " & ex.Message
End Try
End Function
admittedly, this was done with the help of a particular AI, but I've been tuning it in all the places (size, threshold and maxval) and still got nothing.
Quite sure the flow is incorrect. Can anyone suggest any additional pre-processing?
Thanks.