python twain 扫描
def multiScan(self):
""" Scan and return an array of PIL objects
If no images, will return an empty array
""" self.scanner.RequestAcquire(0, 1)
images = []
handles = []
try:
handle, more = self.scanner.XferImageNatively()
handles.append(handle)
except twain.excDSTransferCancelled:
return []
while more != 0:
try:
handle, more = self.scanner.XferImageNatively()
handles.append(handle)
except twain.excDSTransferCancelled:
more = 0 for handle in handles:
images.append(Image.open(StringIO(twain.DIBToBMFile(handle))))
twain.GlobalHandleFree(handle) return images
import twain sm = twain.SourceManager(0)
ss = sm.OpenSource() for i in range(3): //for ex. 3 documents in the scanner device
ss.RequestAcquire(0,0)
rv = ss.XferImageNatively()
if rv:
(handle, count) = rv
twain.DIBToBMFile(handle, '{i}.bmp'.format(i))
import twain sm = twain.SourceManager(0)
sm.SetCallback(onTwainEvent)
ss = sm.OpenSource()
index = 0 for i in range(3): //for ex. 3 documents in the scanner device
ss.RequestAcquire(0,0) def onTwainEvent(event):
if event == twain.MSG_XFERREADY:
saveImage() def saveImage():
rv = ss.XferImageNatively()
if rv:
(handle, count) = rv
twain.DIBToBMFile(handle, '{index}.bmp'.format(index))
index += 1
import twain
sm = twain.SourceManager(0)
ss = sm.OpenSource()
ss.RequestAcquire(0,0)
rv = ss.XferImageNatively()
if rv:
(handle, count) = rv
twain.DIBToBMFile(handle, 'image.bmp')
1、降低扫描分辨率、能用灰度就不用彩色、能用24位彩色就不用32位彩色
2、使用自动进纸器
3、采用高压缩比的图像格式,能用jpg就不用tiff,能用tiff就不用bmp
Source.GetCapabilityDefault(CapabilityCode)
Source.GetCapability(CapabilityCode)
Source.GetCapabilityCurrent(CapabilityCode)
Source.SetCapability(CapabilityCode)
Source.ResetCapability(CapabilityCode)
Source.GetImageInfo():返回XResolution, YResolution, ImageWidth, ImageLength, SamplesPerPixel, BitsPerSample, BitsPerPixel, Planar, PixelType, Compression
Source.GetImageLayout():返回((left, top, right, bottom) document_number, page_number, frame_number)
One of the CAP_* (Generic Capabilities), ICAP_ (Image Capabilities)
python twain 扫描的更多相关文章
- python twain模块
>>> help(twain) Help on module twain: NAME twain - Created on Sep 4, 2011 DESCRIPTION @auth ...
- Python批量扫描服务器指定端口状态
闲来无事用Python写了一个简陋的端口扫描脚本,其简单的逻辑如下: 1. python DetectHostPort.py iplist.txt(存放着需要扫描的IP地址列表的文本,每行一个地址) ...
- [Python] 文件扫描
文件扫描 下载 https://github.com/YouXianMing/FileManager 细节 1. 基于Python 3.60,其他版本未测试 2. 支持扫描深度,不设置则扫描全部,设置 ...
- python 资产扫描01
本地建立的三个文件: Asset1.txt 用来保存扫描到的资产 Asset2.txt 用来导入给定的资产 Repeat.txt 保存重复的资产 程序的功能: 1.资产扫描,以 位置:资产 格式保存到 ...
- python端口扫描
简易版: #author:Blood_Zero #coding:utf-8 import socket import sys PortList=[21,22,23,25,80,135] # host= ...
- Python实现扫描作业配置自动化
持续集成平台接入扫描作业是一项繁琐而又需要细致的工作,于是趁着闲暇时间,将代码扫描作业用Python代码实现了配置自动化. 每次配置作业的过程中,都会在checkcode1或者checkcode3上 ...
- python 端口扫描程序
#! /usr/bin/env python3 #-*- coding:utf-8 -*- import socket import threading OPEN_COUNT = 0 lock = t ...
- python多线程扫描爆破网站服务器思路【笔记】
这个扫描是概率问题,是需要字典的,以下代码是作为参考,字典可以去网上下载,我就不提供,我提供的是思路! #!/usr/bin/env python # coding=utf-8 from IPy ...
- Python脚本扫描给定网段的MAC地址表(scapy或 python-nmap)
目录 用scapy模块写 用 python-nmap 模块写 python3.7 windows环境 以下两个都可以扫描指定主机或者指定网段的 IP 对应的 MAC 地址,然后保存到 csv 文件中 ...
随机推荐
- MongoDB学习笔记:快速入门
MongoDB学习笔记:快速入门 一.MongoDB 简介 MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统.在高负载的情况下,添加更多的节点,可以保证服务器性能.M ...
- Docker学习(4) 守护式容器
守护式容器 stop - 等待信号 kill - 直接干死
- VB 老旧版本维护系列---有点懵逼的webserver访问
有点懵逼的webserver访问 '定义webserver地址 Dim postUrl As String = "" '定义webserver所需xml字符串参数 Dim xmlR ...
- 关于YumRepo Error: All mirror URLs are not using ftp......报错的解决方法
https://blog.csdn.net/u013999945/article/details/69942941 解决了我的问题
- git介绍及使用
一.架构 版本库(仓库):工作区中有一个隐藏目录.git,这个目录不属于工作区,而是git的版本库,是git管理的所有内容. 暂存区:版本库中包含一个临时区域,保存下一步要提交的文件. 分支:版本库中 ...
- .NET Worker Service 作为 Windows 服务运行及优雅退出改进
上一篇文章我们了解了如何为 Worker Service 添加 Serilog 日志记录,今天我接着介绍一下如何将 Worker Service 作为 Windows 服务运行. 我曾经在前面一篇文章 ...
- SAI常用快捷键大全
一.默认常用工具快捷键如下: N 铅笔 B 喷枪 V 笔 X 前/背景色切换 - 前景色与透明色切换 C 水彩笔 A 选区笔 S 选区擦 D 清空当前图层 F 向下转写 (当前图层内容合并至下层,该层 ...
- 创建Akamai cdn api授权
注:通过Akamai Cli purge和通过Akamai API进行刷新之前,都要事先创建类似于如下的刷新的凭据,这两种刷新方式所创建的凭据是相同的. 目的:创建Akamai CDN API授权以便 ...
- Kubernetes自动伸缩pod-HPA
在运维中,虽然能预先知道负载何时会飙升,或者如果负载的变化是较长时间内逐渐发生的,手动扩容也是可以接受的,但指望靠人工干预来处理突发而不可预测的流量增长,仍然不够理想. 幸运的是,Kubernetes ...
- 6. QT国际化 translate QT语言家 翻译
main. QTranslator *qtTranslator = new QTranslator(); if (IsChinese()) { qtTranslator->load(" ...