类型错误:需要一个整数(得到类型元组)?



这段代码几天前就可以工作了。但是现在得到类型错误

法典:

import cv2
import numpy as np
import pytesseract
from langdetect import detect_langs
from pytesseract import *
from flask import Flask,request
import requests 
try:
from PIL import Image
except ImportError:
import Image
#pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'

img = Image.open('G:/Agrima/example_code_API/OCR/FDA.png')
#h, w, c = img.shape
d = pytesseract.image_to_data(img,output_type=Output.DICT)

detected_ocr = image_to_string(img)
points = []
n_boxes = len(d['text'])
for i in range(n_boxes):
if int(d['conf'][i]) > 60:
(x, y, w, h) = (d['left'][i], d['top'][i], d['width'][i],d['height'][i])
img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
mark = {'x':x,'y':y,'width':w,'height':h}
points.append({'mark':mark})
# print(points)
cv2.imshow('img', img)
cv2.waitKey(0)

img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)错误

还尝试更改为img = cv2.rectangle(img, int((x, y)), int((x + w, y + h)), (0, 255, 0), 2)

错误日志 :

img = cv2.rectangle(img, (x, y(, (x + w, y + h(, (0, 255, 0(, 2( 类型错误:需要整数(获取类型元组(

我相信错误陈述可能会产生误导。我记得曾经遇到过这个问题,因为我的坐标(x,y(float而不是int。检查您的变量x, y, w, h是否确实int

最新更新