[Python] Google Document AI directly processes CV2 object

Discussão em 'Python' iniciado por Stack, Fevereiro 9, 2025.

  1. Stack

    Stack Membro Participativo

    I know we can upload the image file to be processed in Google DocumentAI; I am building an app that leverages DocumentAI API in Python. Is there a way for DocumentAI to process image in numpy array?

    For instance:

    with open(r'1_0.png', 'rb') as image_file:
    content = image_file.read()


    this is the content that can processed by Document AI Python SDK, but not something like this:

    content = cv2.imread(r'1_0.png', 'rb')


    Is there a way to convert the cv2 image to byte data like the first method to be processed by Google Document AI? I have multiple local processes to work on the input image; and I do not want to create a temp file in the app (consuming space).

    Continue reading...

Compartilhe esta Página