简体   繁体   English

Python SDK Azure 计算机视觉:“字节”object 没有属性“读取”

[英]Python SDK Azure Computer Vision: 'bytes' object has no attribute 'read'

I am currently developing simple demo how to capture some text over the object such as license plate, Bus number, etc using combination Azure custom vision and Azure OCR.我目前正在开发简单的演示,如何使用组合 Azure 自定义视觉和 Azure OCR 在 object 上捕获一些文本,例如车牌、公交车号码等。

I have issue when sending image to Azure OCR like below: 'bytes' object has no attribute 'read'将图像发送到 Azure OCR 时出现问题,如下所示:“字节”object 没有属性“读取” 在此处输入图像描述

Simply by capturing frame from camera and send it to Azure OCR Read using Python SDK.只需从相机捕获帧并将其发送到 Azure OCR 使用 Python SDK 读取。

Anyone has similar issue like above?有人有类似上述的问题吗? How to fix it?如何解决? and the best way to send frame into Azure OCR Read以及将帧发送到 Azure OCR 读取的最佳方式

below some snippet from my code (Let say the frame already cropped from custom vision boundaries process):下面是我代码中的一些片段(假设框架已经从自定义视觉边界过程中裁剪):

highest_prob = predictions[0]
image_text = detect_text(frame, highest_prob)

to function:至 function:

def detect_text(image, highest_prob):
    # Convert image to byte string
    img_str = cv2.imencode(".jpg", image)[1].tostring()

    #Call API with image and raw response (allows you to get the operation location)
    recognize_printed_results = computervision_client.read_in_stream(img_str, raw=True)

Capturing camera using:捕获相机使用:

cap = cv2.VideoCapture(0)
while True:
    ret, frame = cap.read()
    if not ret:
        break

Computer vision libraries cannot be accessible from the root environment and we need to get the libraries to access inside the virtual environment.无法从根环境访问计算机视觉库,我们需要让这些库在虚拟环境中访问。 With respect to CV2, upgrade the version of computer vision which solves the issue.针对CV2,升级解决问题的计算机视觉版本。 The read operation needs to have some upgrade in the form of computer vision library support.读取操作需要以计算机视觉库支持的形式进行一些升级。

pip install --upgrade azure-cognitiveservices-vision-computervision

use ComputerVisionClient.analyze_image() to read the list of images.使用ComputerVisionClient.analyze_image()读取图像列表。 Not as an individual entity.不是作为一个单独的实体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python; urllib 错误:AttributeError: 'bytes' object 没有属性 'read' - Python; urllib error: AttributeError: 'bytes' object has no attribute 'read' AttributeError: 'bytes' object 在 Python Sockets 库上没有属性 'read' - AttributeError: 'bytes' object has no attribute 'read' on Python Sockets Library python3 socket send recev 'bytes' object 没有属性 'read' - python3 socket send recev 'bytes' object has no attribute 'read' Azure Python SDK:“ServicePrincipalCredentials”对象没有“get_token”属性 - Azure Python SDK: 'ServicePrincipalCredentials' object has no attribute 'get_token' AttributeError: 'bytes' object 没有属性 'read' - AttributeError: 'bytes' object has no attribute 'read' Azure 计算机视觉 SDK read_in_stream 总是返回错误请求 - Azure Computer Vision SDK read_in_stream always returns Bad Request “模块”对象没有属性“ to_bytes” Python - 'module' object has no attribute 'to_bytes' Python Python 错误 'bytes' 对象没有属性 'encode' - Python error 'bytes' object has no attribute 'encode' AttributeError: 'bytes' object 从 python 中的 GCS 读取.gz 文件时没有属性 'read' - AttributeError: 'bytes' object has no attribute 'read' while reading .gz file from GCS in python 'bytes'对象没有'encode'属性 - 'bytes' object has no attribute 'encode'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM