Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Sending Batch request to azure cognitive API for TEXT-OCR

Aperta
#32 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
azure, python
Ambito
api

Direzione di ricerca

Inizia esaminando l’endpoint Azure Cognitive API utilizzato in recognise_text, in particolare la richiesta recognizeText e il relativo flusso di polling di Operation-Location. L’issue non indica alcun file o test del repository, e il completamento non è definito perché chiede se sia possibile inviare più immagini in un’unica richiesta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I am calling azure cognitive API for OCR text-recognization and I am passing 10-images at the same time simultaneously (as the code below only accepts one image at a time-- that is 10-independent requests in parallel) which is not efficient to me, from processing point of view, as I need to use extra modules i.e: Celery and multiprocessing.

So, is there a way to send all the 10-images in a single request and get the output at once then do post processing?

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)

Any help would be really appreciated.

Lingua principale
HTML
Stelle
241
Fork
279
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure-Samples/cognitive-services-REST-api-samples

Tutte le issue di Azure-Samples/cognitive-services-REST-api-samples

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.