Python 尽管图像裁剪清晰,但细分错误输出

Python 尽管图像裁剪清晰,但细分错误输出,python,opencv,computer-vision,tesseract,Python,Opencv,Computer Vision,Tesseract,我有一张裁剪过的照片 与此图像一起使用image_to_字符串的输出为186592183 对如何处理这个问题有什么建议吗 #cropping detected objects and passing into tesseract OCR A = [] for i in indices: i = i[0] box = boxes[i] x = box[0] y = box[1] w = box[2] h = box[3]

我有一张裁剪过的照片

与此图像一起使用image_to_字符串的输出为186592183 对如何处理这个问题有什么建议吗

 #cropping detected objects and passing into tesseract OCR
 A = []
 for i in indices:
     i = i[0]
     box = boxes[i]
     x = box[0]
     y = box[1]
     w = box[2]
     h = box[3]
     crop_img = image[y:y+h, x:x+w]
     cv2.imwrite("Crop/crop__" + str(i) + ".jpg",crop_img)
     #Resize the image
     img = cv2.resize(crop_img, None, fx=4, fy=4)
     #Convert image to grayscale
     gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
     #Convert image to black and white
     roi = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 95, 4)
     #saving the roi regions
     cv2.imwrite("Crop/roi__" + str(i) + ".jpg",roi)

     roi = cv2.threshold(roi,0,255,cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]

     #passing to tesseract
     #c = py.image_to_string(roi, config = '--oem 3 --psm 7 ')
     #roi = cv2.resize(roi, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_LINEAR)
     #c = py.image_to_string(roi, config = ' --psm 10 digits ')
     c = py.image_to_string(roi, config='--psm 11')

 cv2_imshow(roi)`
这是剪切前的原始图像


如果不是“186592183”,那么您想要什么文本?您是否尝试添加所使用的特定语言?例如,
py.image\u to_字符串(roi,config='--psm 11',lang='ara')
?抱歉,如果你的图片中不是阿拉伯语。为了澄清我只想要数字在这个例子中184 2183我想知道为什么Tesseract认为4是6没有OCR是完美的。对tesseract公平地说,裁剪图像中的4不是那么清晰。水平条和垂直条的交点可能被解释为一个填充圆。您可以尝试使用数据集训练tesseract,希望检测效果有所提高。