Detecting pape out with auto scan

Discussions about image processing and document imaging.
heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Detecting pape out with auto scan

Post by heard » Tue Jun 03, 2008 8:59 pm

Hi Loic,
Can you tell me how to detect a paper out condition when I'm using auto scan?
I'm trying to eliminate the dialog box that comes up when the scanner runs out of paper, but I think the 'scan ahead' feature of the auto scan is causing me some problems.

Here is essentially what I want to do (partial code):

While image_ID<>0
image1.AcquiretoGDPictureImage
image1.SaveAsTiff('test.'&str(counter))
counter=counter+1
End while

If I runs this code, I get the 'Feeder is out of paper message' from TWAIN.
So I tried to do this:

While image_ID<>0 and bfeederloaded
image1.AcquiretoGDPictureImage
image1.SaveAsTiff('test.'&str(counter))
counter=counter+1
bfeederloaded=image1.IsFeederLoaded
End while

This code gets rid of my message, but it only saves the first image to disk. I beleive this is because the 'IsFeederLoaded' is being checked before the transfer is complete and thus, before the file is written.

How do I get around this?
Thanks,
Heard

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan/pending xfer

Post by heard » Mon Jun 09, 2008 4:47 pm

Hi Loic,
I have been working on this some while reading the TWAIN spec. :?
It looks like I need to be able to tell if there are any pending transfers and if so, stay in the loop.
How can I do this?

Thanks,
Heard

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detecting pape out with auto scan

Post by Loïc » Tue Jun 10, 2008 10:05 am

Hi Heard,

What are you trying to do with the code you gave me ?

Loïc

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan

Post by heard » Tue Jun 10, 2008 2:44 pm

Hi Loic,
What I'm tryihng to do is to have a loop running that acquires the images. When the feeder runs out of paper, I don't want TWAIN to complain and issue a message saying 'Retry or Cancel'. My users won't like that.

This works fine if I don't use auto scan. But if I use autoscan, I will get the message because the feeder runs out of paper and TWAIN issues the message BEFORE my code can check for paper out. This is happening because there are pending transfers, I believe.

I have since modified my code to check XferCount and I got it to work, but I don't really think this is what XferCount is supposed to be used for. I think I need to check for pending transfers, but I don't know how to do that with gdpicturepro.

So to make it clear, I want the user to be able to stack 10 page of paper in the feeder and start scanning with autoscan turned on. When the feeder runs out of paper, I don't want any messages from TWAIN about being out of paper.

Thanks,
Heard

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detecting pape out with auto scan

Post by Loïc » Tue Jun 10, 2008 2:50 pm

Ok Heard, thanks.

Could you give me the complete code you are using to acquire all the document feeder content ?

Best regards,

Loïc

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan

Post by heard » Tue Jun 10, 2008 3:55 pm

Loic,
Here you go, along with a twainlog.

Heard
Attachments
loic.zip
(570.98 KiB) Downloaded 490 times

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detecting pape out with auto scan

Post by Loïc » Tue Jun 10, 2008 3:58 pm

Heard, I just need the source code you are using for scanning.

You already gave me a portion but I need to know what twain functions you called before scanning...

IE:

Code: Select all

image1.SetAutoFeed(True)
While image_ID<>0 and bfeederloaded
   image1.AcquiretoGDPictureImage
   image1.SaveAsTiff('test.'&str(counter))
   counter=counter+1
   bfeederloaded=image1.IsFeederLoaded
End while


Loïc

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan

Post by heard » Tue Jun 10, 2008 4:26 pm

Ok. Sorry.

setcurrentpixeltype(0)
sethideUI(true)
setcurrentresolution(200)
setduplex(false)
selectfeeder(true)
setautoscan(true)
setpapersize(3)
disableautosourceclose(true)

Heard

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detecting pape out with auto scan

Post by Loïc » Tue Jun 10, 2008 7:13 pm

Heard,

I need all the TWAIN code you use. From the source openning to the source closing.

Without that I can't help you...


Loïc

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan

Post by heard » Tue Jun 10, 2008 8:00 pm

Ok Loic. As you know, I do not program in Visual Basic.
I have given you all the code and a log file generated as it runs, but I will try to convert it into VB for you.

This will take me a while. But I'll post it here.

Heard

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detecting pape out with auto scan

Post by Loïc » Tue Jun 10, 2008 8:06 pm

No problem Heard,

you can give me your code into your environment language.

However, I maybe understood your issue.

You are using

Code: Select all

DisableAutoSourceClose(true)
Are you sure you need this ?

I think your problem will gone away if you remove this call.

Else, if you really want to get the source always open you have to check the Twain state like that:

Code: Select all

Dim Counter As Long

Counter = 0

Imaging1.TwainSelectSource
Imaging1.TwainOpenDefaultSource
Imaging1.TwainSetCurrentPixelType (0)
Imaging1.TwainSetHideUI (True)
Imaging1.TwainSetCurrentResolution (200)
Imaging1.TwainEnableDuplex (False)
Imaging1.TwainSelectFeeder (True)
Imaging1.TwainSetAutoScan (True)
Imaging1.TwainSetPaperSize (3)
Imaging1.TwainDisableAutoSourceClose (True)

While Imaging1.TwainGetState > 5 Or Counter = 0
     Imaging1.TwainAcquireToGdPictureImage
     Call Imaging1.SaveAsTIFF("test" & Str(Counter) & "tif")
     Counter = Counter + 1
     Imaging1.CloseNativeImage
Wend

Hope this help.

Loïc

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan

Post by heard » Tue Jun 10, 2008 8:22 pm

Ok, Loic,
Here you go.

twainsourcename=image.TwainGetDefaultSourceName
opensourcesucces=image.TwainOpenDefaultSource(twainsourcename)


If opensourcesuccess,
image.TwainSetHideUI(true)
image.TwainSetCurrentResolution(200)
image.TwainEnableDuplex(false)
image.TwainSelectFeeder(true)
image.TwainSetAutoScan(true)
image.TwainSetPaperSize(3)
image.TwainDisableAutoSourceClose(true)
endif

v.cap_item_type=image.TwainGetCapItemType(1)

image_ID=999
breturn=false
totalpages=0

while image_ID<>0 and not(breturn)
image.AcquireToGdPictureImage(image_ID)
If image_ID<>0 and image_ID<>999
totalpages=totalpages+1
image.SaveAsTiff(‘c:\test’&str(totalpages))
image.CloseNativeImage
breturn=image.GetCapCurrentNumeric(cap_item_type,cap_xfer_count)
endif
endwhile

image.TwainCloseSource

Thanks,
Heard

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detecting pape out with auto scan

Post by Loïc » Tue Jun 10, 2008 8:23 pm

Heard,

Check my previous post. It solve your problem.


Loïc

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan

Post by heard » Tue Jun 10, 2008 8:25 pm

Loic,
I didn't see your response until after I posted that last code. Let me look at that a while.
Thanks,
Heard

heard
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Detecting pape out with auto scan

Post by heard » Tue Jun 10, 2008 8:32 pm

Hi Loic,
You are excellent! That fixed my problem. I knew it should be simple but could not figure it out. :?
Thank you!

Heard :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests