I am new to the forum and I'm not sure if this question has been asked before. But here goes.
I am exploring the possibility of using the Sourceafis as a WCF service whereby passing
the complete 'Person' object with the collection of Fingerprints to the server from client, for matching.
However when passing the 'Person' class there is a restriction on WCF, in that a multi dimensional array cannot be passed. Now since the fingerprint class contained in 'person', contains such a two dimensional image array, the process raises an exception referring to the 2D array.
I have also tried to serialize this 'Person' class using a BinaryFormatter, and then deserialize the resulting byte array, on the server side to recreate the Person class.
This leads to another shortfall whereby the deserialization requires the assembly that created
the serialized array to begin(Which in my case was the client).Kind of like a catch 22.
So my question is. Has anybody else found a way to pass the person 'class' from client to server using WFC? If so, how did you achieve this? Or is there a better approach?
serialization options have been already discussed here:
SourceAFIS wasn't designed nor tested to work with WCF. I am not surprised the Person object is not being serialized. I recommend sending the native compact template as described in the linked thread.
I managed to solve the serialization issue.
I have two lines of code below which give different results when identifying a Person . The first returns a match , the second returns null .Both are searching through the same database , i'm not sure why, what am I missing?
MyPerson match = Afisengine.Identify(Probe, Database).FirstOrDefault() as MyPerson;
List \<MyPerson> Candidates = Afisengine.Identify(Probe, Database) as List \<MyPerson>;
I assume you are using an older version of SourceAFIS that returns only one match. In that case the second form understandably fails. If you need multiple matches, upgrade to latest SourceAFIS and perform the call like this:
List<MyPerson> matches = AfisEngine.Identify(Probe, Database)
Thank you, works perfectly, I was using the correct version, but my call was not correct as you pointed out above. My knowledge on IEnumerable class is a bit rusty.
I am looking for a more detailed explanation regarding the verify score for 2 persons.
Specifically when the 2 persons objects contains more than one finger.
How does the score get calculated if say only 2 or 3 of the fingers are "similar" out of the total 10 fingers.(When the finger number is not specified in the person objects fingerprint lists)
Same as question 1 but with the finger numbers specified within the persons object?
When no finger position is specified, SourceAFIS compares every probe fingerprint to every candidate fingerprint and just picks the highest score.
When finger position is specified, then comparisons are limited to fingerprints with the same finger position.
One more question.
When doing extraction of Person object, the IsoTemplate , xmltemplate as well as your template is generated.
When you do identification or verification I assume you use your template for matching algorithm? Is this correct?
Is it possible to preset which template 'set' to use for matching, or is this hard coded?
SourceAFIS generates only one internal template format and then performs conversion when other formats are requested. Internal format is not visible in Fingerprint properties. It's an in-memory format. All the exposed formats are intended for serialization.
I am not sure if I understand your response correctly. Perhaps you can clarify with these questions.
"SourceAFIS generates only one internal template format and then performs conversion when other formats are requested"
I have found that ,when adding an image to the person and then performing an extraction , the ISO,XML and 'internal' Template are automatically generated, without requesting them individually? This seems to contradict your sentence above?
Can one use Afis.Identify() with a list of persons , only containing Iso templates.
i.e. without having the 'internal' Templates extracted from an image? I know this is possible with Afis.verify() from your FVCISO example.
the conversion happens inside property getter automatically. That's why you see it already generated in debugger (which calls the getter) or when you read the property in code. If the getter is not called, serialized template format is never generated.
Both Verify and Identify methods require Person objects and in turn Fingerprint objects, which always contain templates in the internal in-memory format. Conversion in this case happens inside ISO template property setter when you create your Fingerprint objects.
That said, you can use ISO templates for identification. Just create Fingerprint/Person objects from them and pass them to Identify method.
I am using the Sourceafis dll for matching against a Person List in memory, which works fine.
However a Person object can get rather large ( > 1 MB) when loading images for all 10 fingers.
So one creates a rather large List in memory when adding many ( ~ 1000 ) sets of prints.
The Binary serializing of the List to a file on disk can take a few minutes when the list reaches ~ 50 MB or more. And the deserializing of the file back to the list takes even longer.
Is there a quicker way to handle these lists in memory when one needs to save updates to the List to a file on disk.
I have tried reducing the list size by only loading templates. I also reduced the uploading the Binary file to once (on form load) and saving the List back to Binary format (on form closing). However if the File grows larger , which it will when adding prints, it could take minutes for the binaryformatter to upload the List into memory and save it back to List.
Is there a better way to handle these large Lists?
This is out of scope for SourceAFIS. You need a database to handle incremental updates. Alternatively you can store every template and every image in separate file.
BTW it looks like you are serializing image-less Fingerprint objects instead of templates. Template is in Fingerprint.Template property. Serializing templates only should shrink the file to something like 2.5MB.
Just to confirm we have loaded only templates( no images ).
With approximately 8000 templates we are getting a file of approx. 15 MB. There is some overhead for a string Name and surname in every person object.
To binary deserialize such a file from disk to a List in memory takes about 40 seconds on a dell 1520 laptop , and 25 seconds on a Intel Xeon 3.1 ghz 64 bit CPU
Are these times in line with other findings that you have experienced.
IMO binary serializer is pretty slow. I would just write the byte array from Fingerprint.Template directly to file stream. You would need to manage file structure yourself in that case though. You could use SQLite to manage the file structure for you.
You are storing approximately 2KB per fingerprint. When you use binary serializer, templates are serialized in their decoded form. That's why they take up so much space. If you just save Fingerprint.Template, the templates will be around 0.25KB.
"I would just write the byte array from Fingerprint. Template directly to file stream'
Yes I think this may be the quickest however, there would be a tradeoff, because of the following.
When recreating the Persons list ( to do identification) , one would have to recreate each person object from the templates list , and this may take longer than deserializing a full list of persons objects. but I will still need to do these comparisons and evaluations. I am currently working with a list of 10000 prints representing 1000 persons.
It's the opposite. Recreating the Person list by assigning to Fingerprint.Template property is much faster than using the builtin .NET serialization. Fingerprint.Template is very lightweight.
Ok thanks Robert.
Will go the way you suggest. Saved me some work.
Log in to post a comment.