【发布时间】:2023-02-08 02:18:45
【问题描述】:
我想获取二维码的照片并解密,但我不想将二维码保存到磁盘,
await message.photo[-1].download(destination_file = "aaa.png")
我可以在不保存的情况下以某种方式处理生成的图像吗?
import cv2
from pyzbar import pyzbar
@dp.message_handler(state=QrScanState.Qr_Scan_Data, content_types=types.ContentType.PHOTO)
async def send_qr_data(message: types.Message, state: FSMContext):
await message.photo[-1].download(destination_file = "aaa.png")
img = cv2.imread("aaa.png")
barcodes = pyzbar.decode(img)
await bot.send_message(chat_id = message.from_user.id, text = barcodes[0].data.decode())
await state.finish()
我试图在不保存照片的情况下工作,但据我所知,照片的 file_id 在列表中
img = cv2.imread(message.photo[-1])
类型错误:无法将对象转换为“文件名”的“str”
【问题讨论】: