How do I extract text from an image?
I am trying to extract the text from an image.
First, I have converted the image into a gray scale image. Then, I have used OpenCV's findcontours() method. Then, I have set minContiguity to 2, maxContiguity to 6, and it didn't work. Then, I changed the threshold value to 9.5. But it didn't work either.
How do I extract the text correctly? The following code snippet is from this tutorial, and it works well for your case: cv::Mat input;. Cv::imread("C:Temptutorial01.jpg"); // Create a copy of the input image with grayscale color model. Cv::Mat gray(input, cv::COLORBGR2GRAY);. // Crop a rectangular area from the top left corner to bottom right corner. // (ie from (0,0) to (width, height)) and save the cropped image. Cv::Mat cropped;. Cv::Rect rect(100,150,150);. Gray.copyTo(cropped, rect); // Threshold the input image using Otsu threshold. Cv::threshold(cropped, gray, 150, 255, cv::THRESHOTSU);. // Find all contours and plot them. Cv::findContours(gray, contours, cv::RETREXTERNAL, cv::CHAINAPPROXNONE);. // Draw each contour. For(int I = 0; I < contours.
Related Answers
How do I keep image quality in InDesign?
In this post we will b...
What is the easiest way to extract text from an image?
How , using Java? For example I have a jpg file in which there is some co...
What type of data can be scraped?
The following types of data can be scraped by a bot: Data for news sites:...