• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

c# - Twain question: is it possible to scan just one document from feeder?

[复制链接]
菜鸟教程小白 发表于 2022-6-22 22:05:36 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

I am playing with the code from http://www.codeproject.com/KB/dotnet/twaindotnet.aspx

I am having a problem because twain returns control only after all documents in feeder are scanned. This leads to high memory usage if I scan 20 or more documents.

I thought of scanning just one document at a time from the feeder and saving the image and calling the api again in a loop.

I am setting cap_xfercount to 1 but this does not seem to help:

    TwCapability cap = new TwCapability(TwCap.XferCount, 1);
    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);

What do I need to do to scan just one document from the feeder? Any suggestions appreciated.



Best Answer-推荐答案


I'm sorry that I'm not familiar with the twaindotnet project, but I do have a lot of experience with document scanning through TWAIN.

First a note: Not all document feeders can feed in single-page mode; some important scanner families always scan everything in the feeder once started. And, quite a few TWAIN drivers won't honor XFERCOUNT=1, no matter what the standard says.

If you try to solve the problem by forcing the scanner to scan "one page jobs", you will be limited to the (indeterminate) set of scanners that happen to support that. The TWAIN standard just doesn't require this feature. (But yes - CAP_AUTOSCAN=FALSE and XFERCOUNT=1 would be the combo to try.)

There is a better solution (time & patience permitting) - It sounds like what you want to do is process and dispose of each image as it arrives, instead of collecting them all in memory. Figure out how to get your TWAIN library to hand you each image (or write it to a file) as it arrives instead of stacking them up in memory, and you'll have a solution that works with all document-feeding scanners. And it will scan quite a bit faster with most scanners, too...

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap