Python 使用字节流读取图片并转换成图片格式显示

Python 使用字节流读取图片并转换成图片格式显示

auth = HTTPBasicAuth("admin".encode('utf-8'), "12345")
response = requests.post("http://192.168.1.120/action/snap?cam=0", auth=auth)

if response.status_code == 200:
    response_byte = response.content
    bytes_stream = BytesIO(response_byte)
    capture_img = Image.open(bytes_stream)
    capture_img = cv2.cvtColor(np.asarray(capture_img), cv2.COLOR_RGB2BGR)
    cv2.imshow("capture_img", capture_img)
    cv2.waitKey(0)

 

你可能感兴趣的:(OpenCV杂谈)