Getting face details from file

General information about Neurotechnology and its software

Getting face details from file

Postby dngeorgiev » Dec 07, 2018 08:00

Hello,

First of all, I would like to thank you for creating everything you did and for the quick and detailed responses you give to everyone.

I have a few template files (.dat) and every single one contains only a single face (although I don't think it's possible for a template to contain two faces) and my question is the following: When using NSubject.FromFile(pathToTemplate), I saw that in the subject the face in the template is contained in the Faces collection, is there a possibility to somehow detect the features of that face (Age, Gender, Expression and so on) and get the image for the detected face (or a thumbnail - for that, I saw that the biometric client has a "FacesCreateThumbnailimage", but I dont think it helps in this case)?

EDIT: I tried using the tutorial "DetectFacialFeatures". I get the subject for the identified face and then use the PerformTask() method, but sadly the status of the task stays as "None".

Thank you in advance.

Best Regards,
Dani Nedelchev
dngeorgiev
 
Posts: 8
Joined: Aug 31, 2018 07:39

Re: Getting face details from file

Postby Martynas » Dec 07, 2018 08:55

Hello,

NTemplate can contain multiple face records (NLRecords), but the template does no contain additional face features, such as age, emotions, face properties and etc. Also it does not contain the face image.
So if you need to keep these details too, then you should consider to save them separately. NBiometricClient allows to save additional/custom data in separate columns of the database. You can find more information on this in documentation of the SDK, section "4.1.1.3 Biographic and Custom Data Support".
Best regards,

Martynas
Software Consultant
Neurotechnology
Martynas
Neurotechnology
 
Posts: 2243
Joined: Sep 19, 2008 10:02
Location: Vilnius, Lithuania

Re: Getting face details from file

Postby dngeorgiev » Dec 07, 2018 09:15

Hello,

Thank you again for your quick response.

If I understand correctly, I have to create an object of type NBiographicDataSchema and since it is a collection, I have to add elements of type NBiographicDataElement to it, but after I created a new NBiographicDataSchema, there is no Add() method or Push() or something similliar. I only saw the Elements collection, which I suppose keeps the elements, but there is only a getter for that. Also, does this mean I'm gonna have to use a database to keep this information? At this stage of our development we are still not using any kind of database, is it possible to keep the data in files instead?

Thank you once again.

Best Regards,
Dani Nedelchev
dngeorgiev
 
Posts: 8
Joined: Aug 31, 2018 07:39

Re: Getting face details from file

Postby Martynas » Dec 07, 2018 10:54

Hello,

you need to use NBiographicSchema.Elements.Add() method to add new elements into schema.
If you do not have a database, then you will need to keep all the same information in other structures of your own (i.e. files), and then you will need to use that information to construct the NSubject with required properties and enroll them into NBiometricClient each time your application is started.
In case of the database and/or NServer, these values are saved in the database and loaded by the NBiometricClient automatically during initialization.
Best regards,

Martynas
Software Consultant
Neurotechnology
Martynas
Neurotechnology
 
Posts: 2243
Joined: Sep 19, 2008 10:02
Location: Vilnius, Lithuania

Re: Getting face details from file

Postby dngeorgiev » Dec 07, 2018 11:58

Hello,

Alright, I started using SQLite, the configuration seemed simple enough. I am now saving the templates in the database. I've seen that it saves all my additional properties as it should (plus the Id, and the template itself). The identifying works as well, but I still don't see the properties, saved from the database. Maybe I am doing something wrong, but your documentation is quite detailed and I still haven't figured out some things from your library.

So, I have saved everything correctly in the database, the IdentifyTask continues to work normally, but I am unaware of how to get the additional properties that I have saved in the database. NMatchingResult seems to return only the Id and the Score of the matching. I want to get also the data from the database for each matched result. Is this even possible?

Best Regards,
Dani Nedelchev
dngeorgiev
 
Posts: 8
Joined: Aug 31, 2018 07:39

Re: Getting face details from file

Postby MartynasV » Dec 07, 2018 13:27

dngeorgiev wrote:Hello,

Alright, I started using SQLite, the configuration seemed simple enough. I am now saving the templates in the database. I've seen that it saves all my additional properties as it should (plus the Id, and the template itself). The identifying works as well, but I still don't see the properties, saved from the database. Maybe I am doing something wrong, but your documentation is quite detailed and I still haven't figured out some things from your library.

So, I have saved everything correctly in the database, the IdentifyTask continues to work normally, but I am unaware of how to get the additional properties that I have saved in the database. NMatchingResult seems to return only the Id and the Score of the matching. I want to get also the data from the database for each matched result. Is this even possible?

Best Regards,
Dani Nedelchev

Hello Dani,

Yes. Take Id value of the matched subject(from matching results) and set it to newly created, empty NSubject object, then call nBiometricClient.Get(subject) method - it will retrieve all data for that subject Id from database including all additional data/properties, they will be stored to that "subject" empty object.
Martynas V
Neurotechnology
MartynasV
Neurotechnology
 
Posts: 460
Joined: Feb 27, 2015 11:24
Location: Vilnius, Lithuania

Re: Getting face details from file

Postby dngeorgiev » Dec 07, 2018 13:31

Hello again,

I have already done that (I found another topic for similliar issue), but I am not sure it works correctly or if I am using it correctly. So, I created a temporary new subject and set its id to the identified id and I used the .Get() method of the NBiometricClient, but the "Properties" seems to be empty. Is that not where all data should be filled?

I am sorry for taking so much of your time and your help and support are deeply appreciated!

Best Regards,
Dani Nedelchev
dngeorgiev
 
Posts: 8
Joined: Aug 31, 2018 07:39

Re: Getting face details from file

Postby MartynasV » Dec 07, 2018 14:14

dngeorgiev wrote:Hello again,

I have already done that (I found another topic for similliar issue), but I am not sure it works correctly or if I am using it correctly. So, I created a temporary new subject and set its id to the identified id and I used the .Get() method of the NBiometricClient, but the "Properties" seems to be empty. Is that not where all data should be filled?

I am sorry for taking so much of your time and your help and support are deeply appreciated!

Best Regards,
Dani Nedelchev

Hello,

I attached file containing CSharp snippets of code showing how to set and get those properties(biographic and custom data).
Attachments
BiographicQueryTest.cs
Examples of biographic and custom data in C#.
(3.85 KiB) Downloaded 79 times
Martynas V
Neurotechnology
MartynasV
Neurotechnology
 
Posts: 460
Joined: Feb 27, 2015 11:24
Location: Vilnius, Lithuania

Re: Getting face details from file

Postby dngeorgiev » Dec 07, 2018 14:23

Hello,

Thanks a bunch for all the support and help provided! Everything works as a charm now!!

Have a nice and wonderful weekend!

Best Regards,
Dani Nedelchev
dngeorgiev
 
Posts: 8
Joined: Aug 31, 2018 07:39

Re: Getting face details from file

Postby dngeorgiev » Dec 10, 2018 13:18

Hello again,

It seems like I was wrong.There are still some issues (probably from my code) - So, it detects multiple faces, but when I show the "image" of each face (getting them from the database) - it shows the same image for each face.

Here is how I'm getting them:

Code: Select all
NSubject tmpSubject = new NSubject();
                    foreach (var matchingResult in currentSubject.MatchingResults)
                    {

                        var imageBytes = NBuffer.Empty;
                        tmpSubject.Id = matchingResult.Id;

                        currentBiometricClient.Get(tmpSubject);

                        imageBytes = (NBuffer)tmpSubject.Properties["Image"];
                        NImage faceImage = NImage.FromMemory(imageBytes);
                        Bitmap bitmapImage = faceImage.ToBitmap();
                        DetectedFace detectedFace = new DetectedFace()
                        {
                            name = matchingResult.Id,
                            gender = tmpSubject.Properties["Gender"].ToString() ,
                            age = int.Parse(tmpSubject.Properties["Age"].ToString()),
                            image = bitmapImage
                        };
                        _DetectedFaces.Add(detectedFace);
                    }


Could you help me with that?

Thank you in advance.

Best Regards,
Dani Nedelchev
dngeorgiev
 
Posts: 8
Joined: Aug 31, 2018 07:39

Re: Getting face details from file

Postby MartynasV » Dec 10, 2018 13:46

dngeorgiev wrote:Hello again,

It seems like I was wrong.There are still some issues (probably from my code) - So, it detects multiple faces, but when I show the "image" of each face (getting them from the database) - it shows the same image for each face.

Here is how I'm getting them:

Code: Select all
NSubject tmpSubject = new NSubject();
                    foreach (var matchingResult in currentSubject.MatchingResults)
                    {

                        var imageBytes = NBuffer.Empty;
                        tmpSubject.Id = matchingResult.Id;

                        currentBiometricClient.Get(tmpSubject);

                        imageBytes = (NBuffer)tmpSubject.Properties["Image"];
                        NImage faceImage = NImage.FromMemory(imageBytes);
                        Bitmap bitmapImage = faceImage.ToBitmap();
                        DetectedFace detectedFace = new DetectedFace()
                        {
                            name = matchingResult.Id,
                            gender = tmpSubject.Properties["Gender"].ToString() ,
                            age = int.Parse(tmpSubject.Properties["Age"].ToString()),
                            image = bitmapImage
                        };
                        _DetectedFaces.Add(detectedFace);
                    }


Could you help me with that?

Thank you in advance.

Best Regards,
Dani Nedelchev

Hello Dani,

It returns image which was set and enrolled to database, please check what image is saved in your database.
Martynas V
Neurotechnology
MartynasV
Neurotechnology
 
Posts: 460
Joined: Feb 27, 2015 11:24
Location: Vilnius, Lithuania

Re: Getting face details from file

Postby dngeorgiev » Dec 10, 2018 13:52

Hello,

Thanks for your reply. How can I check the images? It seems like they are saved in NBuffer (because in the CustomDataSchema I set the Type to "Blob") and I'm not sure how to test the images. But when two (or more) faces appear on the camera, EACH face gets the "first" detected face, if that makes any sense. So, it looks like the images are saved correctly, because if only a single person appears in front of the camera, it shows the correct image, but when there are more than one - the issue shows up. Could it be something from the memory? Maybe some data gets stuck and does not get cleared?

Best Regards,
Dani Nedelchev
dngeorgiev
 
Posts: 8
Joined: Aug 31, 2018 07:39

Re: Getting face details from file

Postby MartynasV » Dec 10, 2018 14:38

dngeorgiev wrote:Hello,

Thanks for your reply. How can I check the images? It seems like they are saved in NBuffer (because in the CustomDataSchema I set the Type to "Blob") and I'm not sure how to test the images. But when two (or more) faces appear on the camera, EACH face gets the "first" detected face, if that makes any sense. So, it looks like the images are saved correctly, because if only a single person appears in front of the camera, it shows the correct image, but when there are more than one - the issue shows up. Could it be something from the memory? Maybe some data gets stuck and does not get cleared?

Best Regards,
Dani Nedelchev

Ok, I'm guessing that you expect that faces will be cropped, but they are not. It is not a bug or error, it works as intended.
Martynas V
Neurotechnology
MartynasV
Neurotechnology
 
Posts: 460
Joined: Feb 27, 2015 11:24
Location: Vilnius, Lithuania


Return to Public

Who is online

Users browsing this forum: No registered users and 4 guests

cron