- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在调用 Azure 认知 API 进行 OCR 文本识别,并且同时传递 10 个图像(因为下面的代码一次只接受一个图像 - 即 10 个独立的请求并行),从处理的角度来看,这对我来说效率不高,因为我需要使用额外的模块,即:Celery 和多处理。
那么,有没有办法在单个请求中发送所有 10 张图像并立即获取输出,然后进行后期处理?
import time
from io import BytesIO
import cv2
import requests
from PIL import Image as PILImage
from PIL import Image
file_list = []
headers = {
"Ocp-Apim-Subscription-Key": "<API-KEY>",
'Content-Type': 'application/octet-stream'}
p = "symbol_sample.jpg"
print(p,"p")
def recognise_text(p):
p = cv2.imread(p)
cropped_image = PILImage.fromarray(p)
buffer = BytesIO()
cropped_image.save(buffer, format="JPEG")
image_bytes = buffer.getvalue()
try:
response = requests.post(
"https://centralindia.api.cognitive.microsoft.com/vision/v2.0/recognizeText?mode=Printed",
headers=headers,
data=image_bytes
)
header_link = str(response.headers['Operation-Location'])
while (True):
headers_get = {
"Ocp-Apim-Subscription-Key": "<API-KEY>"",
'Content-Type': 'application/json'
}
result = requests.get(
url=header_link,
headers=headers_get
)
response_r = result.json()
if response_r["status"] == "Succeeded":
return response_r
else:
time.sleep(4)
except Exception as e:
print(e)
return ""
image1="symbol_sample.jpg"
o = recognise_text(image1)
print(o)
任何帮助将不胜感激。
最佳答案
我猜您正在寻找 Batch Read File
public class BatchReadFileSample
{
public static async Task RunAsync(string endpoint, string key)
{
ComputerVisionClient computerVision = new ComputerVisionClient(new ApiKeyServiceClientCredentials(key))
{
Endpoint = endpoint
};
const int numberOfCharsInOperationId = 36;
string localImagePath = @"Images\handwritten_text.jpg"; // See this repo's readme.md for info on how to get these images. Alternatively, you can just set the path to any appropriate image on your machine.
string remoteImageUrl = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/ComputerVision/Images/printed_text.jpg";
Console.WriteLine("Text being batch read ...");
await BatchReadFileFromStreamAsync(computerVision, localImagePath, numberOfCharsInOperationId);
await BatchReadFileFromUrlAsync(computerVision, remoteImageUrl, numberOfCharsInOperationId);
}
// Read text from a remote image
private static async Task BatchReadFileFromUrlAsync(ComputerVisionClient computerVision, string imageUrl, int numberOfCharsInOperationId)
{
if (!Uri.IsWellFormedUriString(imageUrl, UriKind.Absolute))
{
Console.WriteLine("\nInvalid remote image url:\n{0} \n", imageUrl);
return;
}
// Start the async process to read the text
BatchReadFileHeaders textHeaders = await computerVision.BatchReadFileAsync(imageUrl);
await GetTextAsync(computerVision, textHeaders.OperationLocation, numberOfCharsInOperationId);
}
// Recognize text from a local image
private static async Task BatchReadFileFromStreamAsync(ComputerVisionClient computerVision, string imagePath, int numberOfCharsInOperationId)
{
if (!File.Exists(imagePath))
{
Console.WriteLine("\nUnable to open or read local image path:\n{0} \n", imagePath);
return;
}
using (Stream imageStream = File.OpenRead(imagePath))
{
// Start the async process to recognize the text
BatchReadFileInStreamHeaders textHeaders = await computerVision.BatchReadFileInStreamAsync(imageStream);
await GetTextAsync(computerVision, textHeaders.OperationLocation, numberOfCharsInOperationId);
}
}
关于azure - 向 Azure 认知 API 发送批量请求以进行 TEXT-OCR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56632715/
根据 Wikipedia 的说法,“拉丁文打字文本的准确识别现在被认为在很大程度上解决了可以提供清晰成像的应用程序(例如扫描打印文档)的问题。”但是,它没有给出引用。 我的问题是:这是真的吗?当前最先
我在将包含文本图像的 JPG 文件转换为文本文件时遇到问题。我尝试了 ABBYY 的 OCR SDK 和其他一些 OCR 来源,但没有一个包含格鲁吉亚语。 你能告诉我是否有任何可用于格鲁吉亚语的 OC
有人给了我一大堆惊人的信息。它是 200MB 的 .tiff 扫描公告图像,可以追溯到 40 年代。我想将其数字化,但我对 OCR 一无所知。一些早期的 Material 几乎无法被人类阅读,更不用说
我正在尝试通过 python-tesseract 使用 tesseract-OCR 来读取看起来像这样的低分辨率字体: 不幸的是,该图像返回 ZIJZHZI 我认为分辨率太低,这会导致问题。我试过放大
OCR 软件是否能够可靠地将如下图像转换为值列表? 更新: 更详细的任务如下: 我们有一个客户端应用程序,用户可以在其中打开报告。此报告包含一个值表。 但并不是每个报告看起来都一样——不同的字体、不同
我正在尝试使用 Tesseract-OCR检测其中包含纯文本的图像文本,但这些文本具有名为Journal 的手写字体。 例子: 结果不是最好的: Maxima! size` W (35) 有没有可能改
我已经开始了一个简单的项目,它必须获得一个包含带有上标的文本的图像,然后通过使用 OCR(目前我正在使用 tesseract)它必须识别上标字符 + 正常字符。 例如,我们有一个化学方程式,例如 Cl
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我目前正在研究 OCR(波斯语), 尽管“fas.traineddata”在tessdata中可用,但是当我使用以下命令时,什么也没发生: import pytesseract from PIL im
我对文本片段中下标和上标的一般识别有疑问。 示例图片: 我使用 Tesseract 4.1.1 和 https://github.com/tesseract-ocr/tessdata_best 下可用
在过去的 3 个月里,我一直在尝试训练 Tesseract 通过识别我拥有的图像集合,由于真正的缺乏 正确的文档,以及非常高的复杂性,我开始 放弃将 Tesseract 作为解决方案。 我正在寻找一种
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 12 个月前关闭。 Improve this
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
下面是我的电表读数 52425.5(粗略)的图片: 什么程序/技术可以帮助我自动抄表?备注: 这是较为清晰的图像之一。许多图像都有静态。我可以忽略(让程序说“错误”)带有太多静态的图片。 相机有一个固
大写字母OCR(光学字符识别)的常见错误有哪些? 例如FOR -> FOB 最佳答案 要获得最准确的答案,最好使用针对您的问题的特定数据样本自行测试。不同字符/单词组合的错误率可能有很大差异,具体取决
对于我想教 Tesseract 将复选框识别为单词的客户。当 Tesseract 应该识别一个空的复选框时,它工作得很好。 此命令与 this 结合使用教程就像一个魅力,Tesseract 能够找到空
我正在使用 Tesseract OCR将扫描的 PDF 转换为纯文本。总体而言,它非常有效,但我对扫描文本的顺序有疑问。带有表格数据的文档似乎是逐列向下扫描,而更自然的方式是逐行扫描。一个非常小的例子
在哪里可以找到 cube 的 tesseract ocr 土耳其语扩展模式? 文件: tr.cube.fold tr.cube.lm tr.cube.nn tr.cube.params tr.cube
我正在编写一个用于训练 Tesseract OCR 图像的生成器。 在为 Tesseract OCR 的新字体生成训练图像时,最佳值是什么: 新闻部 以磅为单位的字体大小 字体是否应该抗锯齿 边界框是
我的文本带有一些不那么复杂的数学符号,如下所示。 Tesseract OCR 默认无法识别此类数学符号(+-、角度)。我如何通过 tesseract 识别这些数学符号? 最佳答案 只需使用以下语句:
我是一名优秀的程序员,十分优秀!