Forum Replies Created
- AuthorPosts
/*
* Class: ocr_zarf
* Method: zarf_AcquireNative
* Signature: ()[B
*/
__declspec(dllexport) jbyteArray __stdcall Java_ocr_zarf_zarf_1AcquireNative (JNIEnv * JEnvironmentPointer, jobject jayObject)
{ // 1
static jfieldID fid_s = NULL; /* cached field ID for s */
jclass cls = (*JEnvironmentPointer)->GetObjectClass(JEnvironmentPointer, jayObject);
jclass localRefBufferClass = (*JEnvironmentPointer)->FindClass(JEnvironmentPointer, "java/awt/image/DataBufferByte");
if(availability > 0x00000000)
{ // 2
void * ImageHandle_hnative=(void *)TWAIN_AcquireNative(0x00000000,TWAIN_GRAY);
if(ImageHandle_hnative) // 0 == NULL == no entry
{ // 3
//
void * bitMapHandle=(void *)GlobalLock(ImageHandle_hnative);
if(bitMapHandle)
{
LPSTR pBitmapInfo;
PBITMAPINFOHEADER pBitmapInfoPointer = (PBITMAPINFOHEADER)bitMapHandle;
KalyttaPointer = ( KalyttaPointer ) pBitmapInfoPointer;
LONG const widthOfImage=(LONG)pBitmapInfoPointer->biWidth;
LONG const heightOfImage=(LONG)pBitmapInfoPointer->biHeight;
int bitsPerPixel=(int)pBitmapInfoPointer->biBitCount;
if((widthOfImage > 0x00000000)&&(heightOfImage > 0x00000000))
{
int RowScanIndex=heightOfImage;
unsigned char * imageData= ( unsigned char * ) malloc( heightOfImage * widthOfImage );
do
{
DIB_ReadRow((void *)pBitmapInfoPointer,--RowScanIndex, ( unsigned char * ) imageData[RowScanIndex]);
}
while(RowScanIndex > 0x00000000);
// begin image ops
// end image ops
free(imageData);
GlobalFree(bitMapHandle);
}
}
}
}
}
this is going pretty slow, any suggestions on how to go about this?
🙂@fct wrote:
I’m talking about the already-compiled TWAIN data source application linked from the front page in twain.org.
Okay, it will probably do a lot to orient me in the twain spec to run the testbed first,…I have to keep some idea of where I am at.
@fct wrote:You’re looking at data for an 8bpp palette color mode.
That’s neither 8bpp grayscale mode nor 24bpp RGB. It’s almost sure you won’t need to use that.
Just grabbed something to elicit your next paragraph
@fct wrote:
All the technical information you need to understand how TWAIN works is in the specification. EZTwain classic implements parts of it, but just reading the source (or the TWAIN.H header) won’t cut it if you need to extend EZTwain.
So it gives all ( *ALL* ) [in][out]? ( don’t use that syntax, here for clarity ) I use as in the code you posted somewhat down the page. What is at issue here ( I did extract the text of the spec – and have it where I can find it ) is reading those specs too often do not have enough of the information that is in the headers ( #defines as paramater values ), thus results do not always have enough information to disentangle things like the poster I was just reading on The Code Project who had struggles trying do get the vals passed into the message loop and what they convey.
I guess I am in a professional grade of work that I am not normally encountering.
Your work is remarkable, I do not know if I will need to extend EZTwain as I have not made enough progress to report. I knew the code snip I pulled probably had the wrong bpp and so on, sorta what we get to here to be effective is a 0-1-2-3-4-5- do this do that to get a basic grayscale from what amounts to beginner grade work, doing that without knowing what ( coder ) doing. Writing code is vastly more powerful than pushing a few reset buttons on the front panel…..
@fct wrote:
From the EZTWAIN.H header:
.....
// This affects AcquireNative, AcquireToClipboard, and EnableSource.
...Okay, that’s where I’m gonna start.
@fct wrote:Also, sorry. SetIndicators is a function I implemented myself, it’s not in the EZTwain code you downloaded. But anyway it’s mostly one line using the CAP_INDICATORS capability and the TWAIN_SetCapOneValue function.
?
@fct wrote:
Then consider implementing either buffered or direct to disk transfers.
Can that be done with a call you have already implemented in EZTwain?
Before I run some code and tear up my only machine that I can use for a development platform:
int EZTAPI TWAIN_IsAvailable(void);
goes to ( … terminology… ) the operating system, sort of a shell that calls into kernel mode, returning true ( non-zero ) if a device of some kind has been installed on the system that supports twain – correct?
@fct wrote:
“Use of operation triplets” in the TWAIN 1.9 spec. It’s necessary to know about how triplets work to setup the scanner. The spec also has a list of icaps with explanations about their functionality and parameters. With that basis and the functions in EZTwain it’s easy to change parameters. It’s important to spend some time going over the TWAIN spec (at least the sections relevant to application developers).
I’m gonna be awhile on this, will have to check back ( re-post ) if addional research leads are needed.
@fct wrote:
Also download and use the TWAIN sample application from the twain.org website, it’s useful to list and test the capabilities supported in the scanner.
I have two directories:
Twain_DS_sample01
which has
TWAIN Data Source [DS]
which is a ram resident virtual scanner, and
TWAIN Application
which is a TWAIN Application and gets into vc and so on, I threw away vc a long time ago and use a C/C++ compiler that expects one to dig through the headers yourself, and in doing so I am seeing a great deal of very professonal work.
@fct wrote:
The ICAP you’re asking about is in the TWAIN.H file. Once you incorporate that header file to your project, if you’re using Visual Studio with autocomplete/intellisense enabled you can just type “tw” and control+space to get a list of TWAIN-related declarations.
I had pretty much found that already or knew I would be finding it momentarily as soon as I dug in, intellisense drives me nuts. What I was asking is a “where to start” when I start looking at
TW_UINT8 Index; /* Value used to index into the color table. */
TW_UINT8 Channel1; /* First tri-stimulus value (e.g Red) */
TW_UINT8 Channel2; /* Second tri-stimulus value (e.g Green) */
TW_UINT8 Channel3; /* Third tri-stimulus value (e.g Blue) */and do not have sufficiently informed technical information to dig into. I have tried the magic-button approach and that just will not cut it for where I want this to run. On the opposition postion, I will be in over my head so it is a hell of a job trying to find ground zero in ten acres of code with no cs degree.
@fct wrote:
To use the library with no UI displaying, check the EZTwain functions TWAIN_SetHideUI and TWAIN_SetIndicators.
My ui will be driven by Java, this is native code which may pop-up a dialog if it just has to but pretty sure I can do reading on SetHideUI && SetIndicators and figure it out. I have a lot of reading to do, it’s gonna be where to find the values that are passed into these calls and what the rerturn value signifies that is of consequence in my questions. Documentaton, so called becaue it is, does not do me any good when it insists on calling throgh the shell to give me the documentation, I run in raw text mode with editors that do not have to do a context switch on every character and consider it a litmus test of the beginner to be able to dig throgh 10k headers and find in things almost as fast as the intellisense but without the intrusion from the sales department that brings.
It doesn’t do any good to use that stuff if one has to kowtow to help department from hell and breaks the budget.
@fct wrote:
The functions declared in EZTWAIN.H are also a good way to learn how to program TWAIN.
So I could just start with
HANDLE EZTAPI TWAIN_AcquireNative(HWND hwndApp, unsigned wPixTypes);
and call GlobalFree after the call, wouldn’t that release the handle to the data I just got? I mean I was looking a little deeper and for some reason someone had done the load with copy semantics. I understand how that stuff gets started, STL has a lot of it and we have some very good reasons why that happens but if I call something and it just has to do copy-semantics then it can write the copy to a pointer I alloc and it needs to free the pointer it alloc’d after passsing the buffer.
Bloating ram is exactly one of the attack vectors I see too much of, I’m a near-nutcase about it.
/* ICAP_PIXELTYPE values (PT_ means Pixel Type) */
9 indice, including:
#define TWPT_GRAY 1
#define TWPT_RGB 2where’s ICAP? I know about google and so on, + wkik has profound consequences in information availability and will go to both of those places right now … but I was trying to do that last time I posted and had 50,000 lines of code available – did not know where I was at. What I am asking for from you is a one-point place to start such that I do not drill in on consumer grade resources: The place I am writing this to run has to run as commercial grade equipment, do so in an arena of the linguists that are being shipped by todays “computer science” graduate level work, having trace controls that can be linked to SHA or MD-5 in the background ( no ui ) ….
Just where to start, that’s all.
I spent something around three days digging into the internals, ended up with part done sorting things to where they should be and stuff like:
javascannerukcommscomputingdeviceukcommscomputingnewsindex.html
due to the usual. There’s a stubb for the idea on google, someone has taken the position of Team Lead and has a discussion avenue stubbed with some code to work with, I sorta need to set aside the compression work as likely to drill-in to historical matters and get nothing done. ( me – maybe them too )
….javaEZTWAIN1VCEZTWAIN.C has a message loop already coded at line 198 so I can get in the message loop, thus achieving a way to retire the allocated resources on long loads when a shutdown hook in code might be the way someone else would do it.
At 958 in EZTWAIN.C the code
hDSMLib = LoadLibrary(szSMDir);
…. I guess what we do here is load the twain dll and call into that, but I do not see the point of the copy operation in there, ( that was some C/CPP code deeper in the exploration ) efforts to just get the datastream drilled in on what we know and loath:
“… ( some commercial entity ) …. is no longer in business, TIFF Class F remains in use and is considered by some to be an excellent storage format for facsimile data.”
( not the tiff stuff, the 🙄 no-longer-in-business-because-tried-to-do-something: USEFUL )
… is there some call that will get me TWAIN_RGB ? I do not see what the pallette is for, ( if I can get ) a simple translation that will get the datastream extracted by going through the pallette operation or whatever it wants to do arriving at what amouts to a pointer into the data, with a height x width value and a way to do grayscale[][] from the DIB would really help matters for me right this moment.
I spent last night stubbing a dll to receive the call from Java – there are issues there as Java code practice is that numbers are signed, always, nothing else is signed ….. getting direct bitops and byte ops on image data directly in Java is asking for it.
I did manage to run javah on my Java sources, contorted from the preliminary work of bahri.gencsoy
here’s what I have stubbed in the dll to recieve the call into native code:
/* Gabriel DeClieu (also referenced as Mathieu Gabriel De
* Clieu and Chevalier Gabriel Mathiew de Clieu) was a French
* naval officer whom is attributed to bringing coffee to the
* Americas in 1723. It is said that the Dutch unwittingly
* provided Louis XIV of France with a coffee bush that
* Gabriel DeClieu in turn made due with a seedling which he
* transported to Martinique whilst supposedly sacrificing his
* water ration to the seedling after a storm ravaged his
* vessel. Within 50 years of an official survey a recorded 19
* million coffee trees are said to have sprouted within that
* time. It is said that 90% of the world's coffee spread from
* this single plant.[source: wiki]
*/
__declspec(dllexport) long _callUncompressedCMYKload(void* data_pointer, long data_size)
{
;//int fntessjnidll(void)
}
//
__declspec(dllexport) long _callUncompressedCMYKstore(void* data_pointer,long data_size)
{
;//int fntessjnidll(void)
}note placing active code behind comment marker for now
and there hung on the java does not do signed character stuff and how to call in,….. i was running low on brain-calories at that point, and had been for several hours.
I tried to write a C++ class for this, don’t think I really need that, probably Java will load a dll just as well …. still sorting things where they need to be – Issue 93: TessDLL wraper for java at google goes into several issues, I just wrote my own Java code and dug in for the effort:
// remove this line to get the file to compile.
private Khazad khazad = new Khazad();
// load dll I am prototyping:
static{Runtime.getRuntime().loadLibrary("****DLL");}
// the designer of testJeractApproach affirms under the
// reasonable person test that there are no intentions of basing
// the work on practices of the 16-bit bus.
public testJeractApproach(File fileName)
{
//
super();
//
dataBufferByte = new DataBufferByte(DataBufferByte.TYPE_INT,0x40000);
//
edgeDetector = new CannyEdgeDetector();
}
//skipping the issue of L-2 writebacks and so on ( for now ) that the use of java.io.File raises, going for some sort of “read the scanner” as a delcared buffer and begin some sort of edge detection or other work, first just getting the thing to run so I could use it for my own work in my daily business, from Java, to do intake on warehousing reports.
The whole thing stalled on getting grayscale[][] as image_height / image_width – I do not have the skills to do imaging on a flat dataspace ( [] rather than [][] ) and at that point I had about five thought trains running in parallel, looking at function calls buried so deep in thousands of lines of code that I felt my grasp of where I was at evaporating like Coffee Aroma being breezed out an Open Window…..
gonna have to set down the work for a few days and take care of business.
found an open project at mms computing, a great deal of the work is already done – what we will have to contend with is gui – those things should be called “notorious interface” – has isues like: “Due to the fact that twain is signalling events through the OS-dependent event queues, we need to set up an application window including it’s wndProc callback function.” …. I am put in a pitiful position of not being able to tell you the place where this will run will use that to make life difficult for me + and do it for no reason.
The place where I am going to setup is an isolated area protected by SSL and so on, we drive some things remotely as it is proven ……
never mind.
So anyway, there are going to be some compiler warnings and errors that are going to be uh, challenging 🙂 to get rid of, e.g. packing ints into a byte array:
// copy container pointed to by 'handle' into byte buffer
That sits aside trying to implement CannyEdgeDetector + OCR …. having never done so. Gosh, the possiblities, Road Dog doing forefront cs! Hope I don’t get any re-entrant callbacks stuck in a loop……
I’ve been working on this an hour, all I get for g4 is mac … some tiff and jpeg stuff but this is gonna be slogging unless I can get some trick pointers. Okay,
An image consists of ( ? ) a bitstream which I may consider for the moment to be alpha rgb packed according to some spec. Would rather user cmyk but that will come soon enough.
Graphics will have headers that tell one such things as 640×480 and 1028×764 such as how the bitops packed the pixels. jpeg has advanced compression algora that are beyond me. I want { x , y } ordered pair has enough information that I can decide if that pixel is recordable as set, vis-a-vis “blank”
A great deal will be simplified if I can get past the information that assumes one does not wish to study bits, bytes, and Alpha + Color channel…gonna be needless waste otherwise.
That was an exploratory work to open some headroom, I am swamped at the moment and have to patch up some work later in the datastream as I have concepting meeting this weekend, and – uh ….. Houston, … ? …. hello ?-! ( answer-back: ) “There are no problems, everyting is wonderful.”
That’s gonna get into SSL & PKI – running over absurdly mis-configured user-space. We ( my New Team Lead & I ) will be bringing up an Electronic Office, isolated from the paper office, good isolation subject to engineering grade work, review and testing. What my hope is here is that a scanner-driver, which may well and I expect it to, be callable through JNI – or any simple tool once I gain beginner grasp on the scope, nomenclature, and standard practices of the linkage issues …. surely we can pass a pointer to a few kilobytes or quarter meg or something, does not make sense to go through a context switch just to get 10-k of data.
Anyway: You have given me enough to work with now.
You can also implement different transfer modes (buffered, disk) that depending on the capabilities of the scanner will make the image available as already compressed JPGs, PNGs, TIFs, etc
I’m gonna model the entire project on HP Officejet J4680 Series, because I have one to do testing on, with the intent of making an efficient and safe driver across the entire HP small – mid size business products. With few hooks, a baseline or reference implementation upon which a coder, working in isolation and thwarted in attempts to get documentation can obtain enough info to get a functional and safe driver running, resistant to shell hooks.
I don’t want to scare people, obviously you are aware of the issues.
I’m gonna be swamped for a few days, I knew one call was a file creation call and the other was a minimal reference, what I need here is I have no familiarity with the codebase, so I do not know where to look for teh data trasfer modes that may have already been coded. It looks to me like it is what I think you are working arournd, a rather minimal implementation so if one wants to do graphics ( with the codebase ) then one will have to write some graphics.
The twist here is that I am experienced in this get-going phase, cannot resolve the above by looking at what I have unpacked.
EZTWAIN Classic (eztw32.dll) is a Windows DLL that provides an easy
interface to the TWAIN image acquisition protocol.Great, where’s the sources? I see:
Access
Clarion
Csharp
Dbase
Delphi
Lotusscript
Perl
Powerbasic
Powerbuilder
Progress
Vb
Vb.Net
Vc
Vfp
Readme.TxtTimeout, visit: The Boiler Room
I’ gonna have to do some preliminary orientation on:
saved directly to G4 compressed TIFs and JPEGs. Unfortunately my company doesn't allow me to share code, but I can tell you that the implementation is short and mostly painless once you understand the concepts, as long as you're comfortable with C/C++.
… to that end I am buried in Jeff Heaton’s Introduction to Neural Networks for Java right at the moment…….
What I am trying to do here is program away the “betrayal” that comes when someone who is not informed on computer science and does not wish to be tries to do intake on a thousand printed documents does not have to contort in fear of:
“… the crucial question is whether, on the information available to the defendant when the contract was made, he should, or the reasonable man in his position would, have realized that such loss was sufficiently likely to result from the breach of contract to make it proper to hold that the loss flowed naturally from the breach or that loss of that kind should have been within his contemplation.”
Source:Kuofos v. C. Czarikow Ltd. (The Heron II)
Contemporary shrink wrap insists on going through INT13, masking off needed control codes and data-blocking being done like a dime-size hole in the wall, rather than idempotence employed to gate system calls to the ideosyncratc scheduler of popular commercial grade software so as to get an efficient data-block size of say 100k or quarter meg or whatever it wants so that it is the 802.11-G that is throttlling, not the device or the mainboard and process asscociated with intake.
I can spec some stuff here, now, and in perpituity: We take a raw image stream, do AI on it ( as OCR ) and take what can be recognized as a base character set ( okay, internationalization is here – still, we work to the benefit of technical people ) leaving styled document, as though it were never here, never discussed, only twiddly-diddly for people who want to be nice.
At some point, shortly there after, we proide what in computer science is called a filter interface, such that human intervention either by gui or by spell checker and context validation, is provided for the the programmer and Team Lead. It is part of the license that the code cannot be used save user accept the burden to implement some sort of sanity check at this point.
Then we give a text stream in Java, as Java’s Great Bean directs, free of system-dependent issues such as 0X0A / 0X0D letting 0xcafebabe rule from thereon……
Consider taking your next vacation in the Chinggis khaan home land.
if (TWAIN_Mgr(DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &twid))
and
if (OpenFile(szSMDir, &of, OF_EXIST) != -1) {
?? … so where’s …. this is gonna get involved, all this file read goes through some 16 bit legacy code that really should be fluffed to 1k buffers and burst-mode transfer in a wider data rate thinking, plus the device independent bitmap and making the data ( therein ) available to what Java calls a pixel grabber is going to be learning Data Source Manager … where’s the sources for that?
( I’m in over my head, I have never done graphics )
i’ve seen those other tools, what they do for security doesn’t do anything for me, that is in large part why i want to do this scanner interface to java -all that stuff always shell-hookers everything … doing something like “shielding username from response header” or something, then it always calls into 16-code. Mozilla’s good, Firefox has some cool tools, what do you need them for?
I know it sounds off-topic, but that is exactly the topic. Ever read the headers for gc.h ?
Digital Mars, check it in to your code repository. Fast, single pass compiler with code path analysis.
spike, i’ll be talkin to ya – due to personal experience, i will be working from sources only, and for what it is worth – i use dm. ( google it ) I would have googled for EZ_Twain but sometimes such pages pop-up a rather infantile ui right in the browser client area and totally hook the kernel entry points to the point that one cannot regain a controlled shutdow-reboot with even crtl-alt-del so I just do not cook the info if i think it will lead to a commercial site. I enjoy digging into code, i wrote 1,800 lines of java in the past ten or so days from just before x-mas, fa8298b8 ampersand g *ail dot cee oh em.
my ask about PCL was to disentangle driving the printer from driving the scanner, it appears from doing a few scans since the post that driving the scanner portion of the hp may be done cleanly with twain.h
that is of course, after i find the implementation.
#ifdefined dewine
#define dewine declined
#else define dewine devinewouldn’t it be simpler just to do private static final String dewine =”devine”?
Re-reading original poster’s question, I think I can ask this question: Where’s the rest of DS_Entry && DSM_Entry + thanks greatly for the steer on JNI but where is the cited tool? ( EZTwain classic library ) ( sources – compile from source ) … and while we’re at it, where are sources for Printer Control Language? Maybe I can just use twain.h but I don’t know what I’m doing here.
I just gave up on using my new HP Officejet J4680 Series from shrink-wrapped software. Will be using hand-text_editor_manual method until such time as I can go through the headers for TWAIN. We must assume at this point that any such work will present unanticipated failures if we do not call,…..
Not intending to be difficult or make rebuttal, what is your question? That code I found gets bytes from an image file using established Java method calls, to do what I think you as will need be that we write the driver to talk to the device. That resolves to reading the headers for Twain. Have you read them? Basic idea is that is 2171 lines of defines, with two or three entry points for system calls so I need to ask what if any compiler are you using?
I am working on a similar project, so far I have determined that it is likely that we will have to go through JNI – Java Native Interface. Yesterday I found the header for twain as a consequence of looking in the driver forum here – I have managed to raise the scanner using Java Print API … took awhile and all I got was the printer name and a good listing of MIME types the printer can print. I also found some code on the Sun Fora which provides a remarkably good starting point.
License on the code is thus:
I know that it’s quite a long time that those posts are here but I found them while looking for an OCR solution in Java, and I would like to share the FREE answer I have created.
I browsed lots of posts while searching for OCR in Java, and all was linking to Asprise / javaocr, but those are unaffordable for non-commercial project.
URL == “http://forums.sun.com/thread.jspa?threadID=423280”
Java and OCR ( Ajit at York ) Started Jul 16, 2003 5:09 AM
- AuthorPosts