private void btn_image_Click(object sender, EventArgs e){ OpenFileDialog open = new OpenFileDialog(); // Display the image selection dialog, and upon successful image selection, proceed if (open.ShowDialog() == DialogResult.OK) { // Display selected image in the picture box img_image.Image = new Bitmap(open.FileName); // Initialize IronTesseract for OCR processing varOcr = new IronTesseract { // Set the OCR language to JapaneseBest for optimal accuracyLanguage = OcrLanguage.JapaneseBest }; // Using 'OcrInput' to process the selected image file using (varInput = new OcrInput(open.FileName)) { // Perform OCR to extract text from the image varResult = Ocr.Read(Input); // Display recognized text in the rich text box txt_output.Text = Result.Text; // Save the output as a text file named "JapaneseText.txt"Result.SaveAsTextFile("JapaneseText.txt"); } }}
private void btn_image_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
// Display the image selection dialog, and upon successful image selection, proceed
if (open.ShowDialog() == DialogResult.OK)
{
// Display selected image in the picture box
img_image.Image = new Bitmap(open.FileName);
// Initialize IronTesseract for OCR processing
var Ocr = new IronTesseract
{
// Set the OCR language to JapaneseBest for optimal accuracy
Language = OcrLanguage.JapaneseBest
};
// Using 'OcrInput' to process the selected image file
using (var Input = new OcrInput(open.FileName))
{
// Perform OCR to extract text from the image
var Result = Ocr.Read(Input);
// Display recognized text in the rich text box
txt_output.Text = Result.Text;
// Save the output as a text file named "JapaneseText.txt"
Result.SaveAsTextFile("JapaneseText.txt");
}
}
}
Private Sub btn_image_Click(ByVal sender AsObject, ByVal e AsEventArgs) Dim open As New OpenFileDialog() ' Display the image selection dialog, and upon successful image selection, proceed If open.ShowDialog() = DialogResult.OKThen ' Display selected image in the picture box img_image.Image = New Bitmap(open.FileName) ' Initialize IronTesseract for OCR processing DimOcr = New IronTesseractWith {.Language = OcrLanguage.JapaneseBest} ' Using 'OcrInput' to process the selected image fileUsingInput = New OcrInput(open.FileName) ' Perform OCR to extract text from the image DimResult = Ocr.Read(Input) ' Display recognized text in the rich text box txt_output.Text = Result.Text ' Save the output as a text file named "JapaneseText.txt"Result.SaveAsTextFile("JapaneseText.txt")EndUsing End IfEnd Sub
Private Sub btn_image_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim open As New OpenFileDialog()
' Display the image selection dialog, and upon successful image selection, proceed
If open.ShowDialog() = DialogResult.OK Then
' Display selected image in the picture box
img_image.Image = New Bitmap(open.FileName)
' Initialize IronTesseract for OCR processing
Dim Ocr = New IronTesseract With {.Language = OcrLanguage.JapaneseBest}
' Using 'OcrInput' to process the selected image file
Using Input = New OcrInput(open.FileName)
' Perform OCR to extract text from the image
Dim Result = Ocr.Read(Input)
' Display recognized text in the rich text box
txt_output.Text = Result.Text
' Save the output as a text file named "JapaneseText.txt"
Result.SaveAsTextFile("JapaneseText.txt")
End Using
End If
End Sub