Home › Forums › TWAIN Classic › getting TW_EXTIMAGEINFO
- This topic has 17 replies, 3 voices, and was last updated 8 years, 8 months ago by peterlee.
- AuthorPosts
Hi all,
i’m trying to get some informations (eg. barcode) from scanned page. I’ve downloaded a NETMasters code example, implemented two structures –
[StructLayout(LayoutKind.Sequential, Pack = 2)]
internal struct TwInfo
{
public short InfoID;
public short ItemType;
public short NumItems;
public short CondCode;
public int Item;
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
internal class TwExtImageInfo
{
public int NumInfos;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public TwInfo Info;
}
, enum
internal enum TwEImgInf: short {
...
formvertdocoffset = 0x1218,
barcodecount = 0x1219,
barcodeconfidence = 0x121a,
...
}
and function
[DllImport("twain_32.dll", EntryPoint = "#1")]
private static extern TwRC DSextImgInfo([In, Out] TwIdentity origin, [In, Out] TwIdentity dest, TwDG dg, TwDAT dat, TwMSG msg, TwExtImageInfo extimginf );
according to specification, i’m trying to get information right after i recieve XFERDONE. My code is :
TwExtImageInfo extinf = new TwExtImageInfo();
extinf.NumInfos = 1;
extinf.Info.CondCode = 0;
extinf.Info.InfoID = (short)TwEImgInf.barcodecount;
extinf.Info.ItemType = (short)TwType.Int32;
extinf.Info.NumItems = 0;
extinf.Info.CondCode = 0;
rc = DSextImgInfo(appid, srcds, TwDG.Image, TwDAT.ExtImageInfo, wMSG.Get, extinf);
i’m allways get error “cannot marshal field Info of type TwExtImageInfo”. can anyone help me with this? i’m nearly mad… 🙁
i took a somewhat different approach, i asked for every standard extInfo (not just the barcode info) but if you want to translate the classes from vb.net the code is over at http://www.codeplex.com/opentwain. if you run the sample app the extInfo will output in your ide.
.
thanks gabe, i will take a look to opentwain.
i’ve got one more question about capabilities… application supplied with my scanner (HP Scanjet N7710) can read barcodes. When i read supported capabilities there is no one ICAP_BARCODE*, but when i get CustomData i have found this line –
“BarType=0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0:BarAutoReadFront=1:BarAutoReadBack=1:BarcodeEnabled=1:BarcodeParameters=”.
So, support this scanner barcode detection or not? Reading TWEI_BARCODECOUNT always returns 0… 🙁
Is there a possibility that supplied application use ISIS besides twain?what driver are you using? Ther is typically a driver on the cd that came with you hp scanner that has a name ‘hp commercial twain %model number%’
check if you get barcode info out of the extInfo with the commercial driver, and you may have to look into their custom extInfo, I’ll often go looking for another 100 or 2 over the standard set of id for extra/undocumented info
.
i’m using driver supplied with scanner, these two files :
hp7710co.dll – Hewlett Packard ScanJet VendorSetup Extension Dynamic Link Library
hpgt7710.dll – Hewlett Packard ScanJet N7710 series common scanner interface library
Do you think that the problem is in these drivers? I tryied to found another on the HP web site, but it seems that this is the only one which they have 🙁the scanner came with a cd. search the cd for a directory that contains the word ‘commercial’
You’ll like that driver much much more (at least I typically do)I’ve tried finding those drivers online but I seldom have much success,.. though that could just be my poor internet searching skills… hard to say.
.
i’ve found nothing 🙁 it seems like there is no other driver. grr. i will try some hp forum and we’ll see… thaks for help
on the other hand, i seem to remember that the toolkit would display all sorts of info if you set the logging to full…
if run twack_32 and set the message level to full and acquire do you see any mention of a barcode in the dialogs (assuming you are scanning something with a barcode)?
.
twack, when set messagelevel:full, tells me only informations about tw_imageinfo and tw_imagelayout 🙁
do you see CAP_ENABLEDSUIONLY under supportedCaps?
jop, and it’s set to true by default
is a read only Cap, it just indicates that the device supports the capability (you can’t set it)
then my last idea for getting extInfo out of the device is to run the device from opentwain. If you start the guiharness project form opentwain with your debugger, you should see a whole bunch of stuff scroll thru your output window (vs 2005) some of the stuff that scrolls by will be all of the extInfo.
…and if i misremember the current build I posted and if i happened to have commented out the method that outputs all the extInfo lemme know and I’ll tell you where/how do re-enable the output.
.
So, i send trace info into the text file, and this is result for extimageinfo :
Standard ExtImageInfo Start
1200 4608 BarCodeX 0 UInt32 5 Success
1201 4609 BarCodeY 0 UInt32 5 Success
1202 4610 BarCodeText Str255 12 Success
1203 4611 BarCodeType 4294967295 UInt32 5 Success
...
1219 4633 BarCodeCount 0 Int32 2 Success
121A 4634 BarCodeConfidence 0 Int32 2 Success
121B 4635 BarCodeRotation 0 UInt32 5 Success
121C 4636 BarCodeTextLength 0 UInt32 5 Success
Standard ExtImageInfo Finished
strange is, that opentwain crash after acquiring image on HP N7710 (Epson RX585 and HP 4500C are ok). Problem was in twCapability.vb / m_ReadStr255 – when trying to read bytes from pointer returned by ACAP_XFERMECH, TWEI_BOOKNAME and TWEI_CAMERA. Try and catch on
byt = Runtime.InteropServices.Marshal.ReadByte(fixPtr, Position)
solved this, but i dont know where is the problem…
was it an AccessViolationException? and was it due to the ptr being null or 0?
I’ll look back thru the code, and one more thing – you are feeding a document that contains a valid barcode right?
.
did m_ReadStr255 loop thru at all before it threw or was it the first pass thru that went kaboom? wondering if they put any text in there at all or not,..
.
- AuthorPosts