【发布时间】:2014-08-27 22:39:16
【问题描述】:
我需要能够连接 USB 扫描仪(特别是 Epson Perfection V550)。我试过ImageScanner,它似乎没有找到我的设备(我也尝试安装twain,但它有问题说
Could not find any downloads that satisfy the requirement twain.)
所以我转而求助于PyUSB,它可以看到设备在那里。我现在遇到的问题是我不确定我需要发送什么设备才能扫描并给我发回图片。
这是我运行的代码:
import usb.core
import usb.util
import sys
venderID = 0x04B8
productID = 0x013B
dev = usb.core.find(idVendor=venderID, idProduct=productID)
for cfg in dev:
print cfg
输出结果是:
CONFIGURATION 1: 2 mA ====================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x20 (32 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0xc0 Self Powered
bMaxPower : 0x1 (2 mA)
INTERFACE 0: Vendor Specific ===========================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0xff Vendor Specific
bInterfaceSubClass : 0xff
bInterfaceProtocol : 0xff
iInterface : 0x0
ENDPOINT 0x81: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0xff
ENDPOINT 0x2: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x2 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0xff
【问题讨论】:
-
您是明确地尝试在代码中执行此操作,还是对有效的应用程序感到满意?我对适用于 Fujitsu ScanSnap S1500 的 vuescan 很满意。适用于 Linux 和 Windows 的 USB 扫描仪,但可能不是您的。
-
明确尝试用 Python 来做这件事。我可以使用扫描仪附带的默认软件进行访问,但这不是这个项目的目标。
-
PyUSB 仅允许您访问原始 USB 描述符/端点。要让您的扫描仪运行,您必须在 Python 中实现自己的驱动程序,这是很多的工作。你会更适合尝试让 TWAIN 工作。
-
查看这个项目,看看它是否可以帮助您让 TWAIN 正常工作。 github.com/pelletier/django-dynamictwain
-
我会调查的。看起来很有趣。
标签: python usb image-scanner