This project shows text extraction from the input image. It is used for road sign texts translations. First, the image is preprocessed using OpenCv functions and than the text from road sign is detected and extracted.
Input
The process
- Image preprocessing
Imgproc.cvtColor(img, img, Imgproc.COLOR_BGR2GRAY); Imgproc.GaussianBlur(img, img, new Size(5,5), 0); Imgproc.Sobel(img, img, CvType.CV_8U, 1, 0, 3, 1, 0); Imgproc.threshold(img, img, 0, 255, Imgproc.THRESH_OTSU+THRESH_BINARY);
- Contour detection
List<MatOfPoint> contours; Imgproc.findContours(img, contours, new Mat(), Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);
- Deleting contours on edges, small contours, wrong ratio contours and wrong histogram contours
- Preprocessing before extraction
- Extraction
TessBaseAPI baseApi = new TessBaseAPI(); baseApi.init(TESSBASE_PATH, DEFAULT_LANGUAGE); baseApi.setImage(bm); String resultParcial;
- Translation