TypeError:是否需要整数(类型为元组)? [重复]
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError:是否需要整数(类型为元组)? [重复]相关的知识,希望对你有一定的参考价值。
CODE:
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)TypeError:必须为整数(元组类型为元组)
float
而不是int
。检查变量x, y, w, h
是否确实为int
。以上是关于TypeError:是否需要整数(类型为元组)? [重复]的主要内容,如果未能解决你的问题,请参考以下文章