我試圖從數獨板中提取數字。在檢測到電路板,角落和變形後,我只剩下一塊板子,只有一塊板子。 現在我試圖用Tesseract android實現Tess-Two識別數字。 我通過清潔圖像以幫助tesseract在Android上
currentCell = undistortedThreshed.submat(rect);
圖像被劃分到9份,其中rect
是圍繞圖像的矩形。
現在以數字識別。
有些數字,如4,它完全可以識別。有些,大多數是6,7,8被認爲是0或沒有。
我想通過清潔currentCell
圖像儘可能地幫助tesseract。目前它看起來像這樣 。 (也嘗試沒有倒置的閾值)。我想擺脫白線(數獨線)。 我已經試過這樣的事情(從here拍攝)
Imgproc.Canny(currentCell, currentCell, 80, 90);
Mat lines = new Mat();
int threshold = 50;
int minLineSize = 5;
int lineGap = 20;
Imgproc.HoughLinesP(currentCell, lines, 1, Math.PI/180,
threshold, minLineSize, lineGap);
for (int x = 0; x < lines.cols() && x < 1; x++) {
double[] vec = lines.get(0, x);
double x1 = vec[0], y1 = vec[1], x2 = vec[2], y2 = vec[3];
Point start = new Point(x1, y1);
Point end = new Point(x2, y2);
Core.line(currentCell, start, end, new Scalar(255), 10);
}
,但它不畫任何東西,我試着用線的寬度和顏色,但仍沒有搞亂。嘗試在大圖像上繪製線條,放在沒有任何形狀的圖像上,沒有任何工作。
有什麼建議嗎?
編輯
出於某種原因,它不能似乎找到任何行。 這是圖像在應用canny之後會看到的內容,但
HoughLines
未檢測到任何行。嘗試了HoughLines
和HoughLinesP
不同的值,如OpenCV文檔中所示,但沒有任何工作... 這些是非常明顯的線..我做錯了什麼? 謝謝!
使新的標量(0),而不是255. – AruniRC