Info

Discussions about machine vision support in GdPicture.
Post Reply
User avatar
m.cordini
Posts: 20
Joined: Mon Jun 25, 2007 11:41 am
Location: Piacenza ( Italy )
Contact:

Info

Post by m.cordini » Wed Jan 30, 2013 6:01 pm

Hi Loic
How are you ?

I'm Marco from AlmaPro Italy and in the next few days we will probably buy a full license (for another scanning app). Now we are testing your OMR engine but we have a doubt: how can we build a "template" to apply to every survey acquired from scanner ? Do we have to calculate the coordinates of every single box in the document and then pass to the ORM programmatically. In an old 3th party suite we can draw a template, test it and the use it in our application.

Best regards
Marco Cordini
Alma Pro srl

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

Re: Info

Post by Loïc » Wed Jan 30, 2013 6:09 pm

Hello Marco!

Nice to see you again.

This is a quite good question. We have an OMR specialist in the team that is working on such issue. Currently you have to determine by yourself the bounding box size of each item, but with the anchoring mechanism you can easily determine the offset.

If you need some precision just let me know and I will ask our specialist to assist you.

Cheers!

Loïc

User avatar
m.cordini
Posts: 20
Joined: Mon Jun 25, 2007 11:41 am
Location: Piacenza ( Italy )
Contact:

Re: Info

Post by m.cordini » Wed Jan 30, 2013 6:19 pm

Thanks Loic,
I send in attachment we have to do. If your person can 'lend a hand I would be very grateful.

Marco
Attachments
Test.zip
(44.45 KiB) Downloaded 622 times

User avatar
m.cordini
Posts: 20
Joined: Mon Jun 25, 2007 11:41 am
Location: Piacenza ( Italy )
Contact:

Re: Info

Post by m.cordini » Thu Feb 14, 2013 12:24 pm

Hi Loic,

any news for me ???
Marco

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Info

Post by SamiKharma » Thu Feb 14, 2013 1:03 pm

Hi,

Loic has asked him to help you with this.
Ok, to start, there are layers in the process of making OMR recognition apps:
1. The Form set up (which is what you are wondering about)
2. The matching of the form (alignment due to translation in scanning)
3. The recognition

Now steps 2 and 3 are handled by our sdk through the OMRDetect functions, and the FindAnchor.
The anchoring mechanism will determine how much translation the filled test has gone under in scanning, then you apply that translation to the rectangles that correspond to the OMR fields and then you run your OMRDetect function. (If you need more on this please do ask)

Now your question, what do I do with the rectangles, and how do I make a form that i can reuse over and over again?
Yes there are some sdks that will make you make a form, but here in GdPicture, we realized that our customers prefer more control over their forms. And since it is an app level design we could not disagree and force our Form template format.
That being said, we will provide a demo app that will include all of this integrated together in the next couple of months.
Here are some hints on how to do it:
You need to create a class called FormTemplate, in that class, you shall have an array of Rectangles, that you can initialize per form in the contructor, for example, if you have 20 questions, each having 4 possible answers, you will need 80 fields.
You will also need a string to recognize the form (this could be done a million other ways, id, handles, etc).
Your constructor call should look like this:

Code: Select all

FormTemplate( "Chemsitry A101, SPR13", 80)
Where the first parameter is the string to identify the form, and the second is to specify the number of fields.
Then you can populate the fields by passing an array of Rects to a SetRects function in the form.
Finally, you have a ready form to use over any scanned document of that form.

Now finally, how to draw the rectangles on a GdViewer, and make their values populate the form automatically.
Say you load your form onto GdViewer, there are a set of functions in the GdViewer called Highlighted Regions:
https://www.gdpicture.com/guides/gdpicture/v9/html/con ... gions.html
And there is the Rectangle Of Selection:
https://www.gdpicture.com/guides/gdpicture/v9/html/con ... ction.html
You need to use those two together.

Basically, on mouse up, you get the area of the rectangle of selection on the document using GetRectCoordinatesOnDocument, and you add a region using AddRegion.
You do this for every form field. When you are done, you save, call SetRects in your FormTemplate instance.

Now when you scan filled tests, you use the anchor mechanism to measure the offset, and just offset the rectangles in your FormTemplate by adding the offset. Then you call the OMRDetect function over the scanned image.

I know all this information could be overwhelming, but it is aimed at describing a whole application at once :).
Again, we will implement all the above and more in an easy to understand manner in a demo app that you could probably adopt or use as is in the next couple of months.

Best Regards,
Sami Kharma
GdPicture Support

User avatar
m.cordini
Posts: 20
Joined: Mon Jun 25, 2007 11:41 am
Location: Piacenza ( Italy )
Contact:

Re: Info

Post by m.cordini » Thu Feb 14, 2013 6:05 pm

Thanks Sami, now it'a a little bit more clear.

I took a look at the anchor sample but i found it "complicated" for my case. I didn't understand the ROI management (es: the numericupdown value updated only if increased, ecc ...)

I have to scan some surveys, save them as tif, read x marks and show a report to the user.

I set up a single survey template, saved the anchor and mark points coordinates in an xml, but how can I create the anchor_template_id without using gdViewer ? I saw that in your sample you use conversion between inch and mm, use getregionid, and so on ..

Best regards,
Marco

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Info

Post by SamiKharma » Thu Feb 14, 2013 8:32 pm

Hi,

The anchor sample uses the same idea i described for creating Rectangles on the OMR fields using the GdViewer and the mouse.
It is in mainly two steps:
1. Draw a RectangleOfSelection using Mouse, retrieve the position using GdViewer.GetRectCoordinatesOnDocument
2. Add a region using GdViewer.AddRegion using the position information obtained in 1.

Now when you create anchor, you retrieve that information by getting the positions of the region added in 2.
This means that you can skip point 2 all together, and use the coordinates in 1 and call CreateAnchorTemplate immediately, but point 2 is to make it more graphically friendly.

Finally, how to accomplish the above without a viewr (meaning without mouse selection). Extremely simple, if you know where your anchor is, just call CreateAnchorTemplate immediately, and then FindAnchor on the other documents with the anchor template returned.

As to the search area (which you saw in mm etc), i usually advise that the search area is not too big compared to the size of the original anchor. Meaning,
Left = AnchorLeft - (AnchorWidth /2)
Top = AnchorTop - (AnchorHeight /2)
Width = AnchorWidth * 2
Height = AnchorHeight *2

Of course the above is subject to change depending on your anchor in your form, which you would know better.

I hope this helps.

Best Regards,
Sami

wpn
Posts: 9
Joined: Wed Mar 02, 2011 1:01 am

Re: Info

Post by wpn » Wed Sep 25, 2013 11:44 am

Hello Sami,

So, during development I design a form, scan it and find the coordinates of a rectangle that contains the anchor. Then I use the 'CreateAnchorTemplate' to create the anchor. Is it possible to save that information in binary form or something so that I can include it in my program. Now I have to include the tiff file with the template and save the needed coordinates. When the user starts scanning, my program must load the tiff file and use the 'CreateAnchorTemplate' method to create the anchor again. Is this correct?

If I could save the binary info of the anchor then I do not need to distribute the tiff file.

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Info

Post by SamiKharma » Wed Sep 25, 2013 2:05 pm

Hi,

Unfortunately we do not have the option of saving the anchor yet. However, you can request it through:
viewforum.php?f=28

Best,
Sami

wpn
Posts: 9
Joined: Wed Mar 02, 2011 1:01 am

Re: Info

Post by wpn » Wed Sep 25, 2013 2:18 pm

Ok, done. Thanks

wpn
Posts: 9
Joined: Wed Mar 02, 2011 1:01 am

Re: Info

Post by wpn » Wed Oct 02, 2013 10:42 am

Hello Sami,
Do you have guidelines for marking the anchor and answer boxes? When I mark an answerbox should I include some blank space around it? If I include an anchor on a form should it be round or square or .....

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Info

Post by SamiKharma » Thu Oct 03, 2013 1:22 pm

Hi,

>>Do you have guidelines for marking the anchor and answer boxes?
Yes. In general they should contain more black pixels than white (more content). The rectangle of the anchor should be perfecty surrounding the object, or there will be extra white space.

>>When I mark an answerbox should I include some blank space around it? If I include an anchor on a form should it be round or square or .....
You surround the anchor with a rectangle, but the anchor itself could be anything. Now squares tend to yield better results (in all APIs and documents), because they scan better and there is less variation when the documents are being "quantized" by the scanners.

Best,
Sami

wpn
Posts: 9
Joined: Wed Mar 02, 2011 1:01 am

Re: Info

Post by wpn » Thu Oct 03, 2013 1:36 pm

How about marking the answerboxes, you explained about the anchors, not about the answerboxes.

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Info

Post by SamiKharma » Thu Oct 03, 2013 11:20 pm

Hi,

>>When I mark an answerbox should I include some blank space around it?
The answer lies in the documentation of the OMR functions:
"
All Rectangles sent to the function via array Areas can be of any size or location, as long as they:
Surround the OMR Field completely.
Do not intersect with borders of OMR field.
Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
"

Best,
Sami

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest