Fingerprint question

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Fingerprint question

Post by adafruit_support_rick »

Fingerprint matching doesn't work that way. The two templates will not be the same, so you won't be able to do a simple compare to determine if the fingerprints match. You need to let the sensor do the fingerprint matching.

User avatar
Don_Jeronimo
 
Posts: 26
Joined: Sun Jan 11, 2015 6:39 am

Re: Fingerprint question

Post by Don_Jeronimo »

Hi,

I've been looking for a way to do this too. Mainly so I can use multiple scanners and enroll only once (and play with access profiles and such). I'm not the best coder in the world, however looking at the datasheet it seems possible using a combination of the DownChar, UpChar, GenImg and Match functionality.

E.g.
Storing:
- Do usual stuff...
- Use Upchar to store the character file in an external database (where you can have fun coupling extra data like personal data, time stamps, have some more direct admin capabilities etc.).

Matching:
- Use GenImg to put a template (finger to find) in Character Buffer 1
- Use Downchar to upload the character files (on by one) from the database in Character Buffer 2
- Then use Match to find a match (filling Character Buffer 2 by looping through the database entries until a match is found or end of recordset)

As I see it, this way, all data would be stored externally, but the matching is still done by the scanner.
As I said, I'm not the greatest coder, actually I'm terrible... So before wrecking my brain trying to make this work. I'd like your opinion on feasibility, if feasible at all.

Regs,
J

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Fingerprint question

Post by adafruit_support_rick »

What you describe sounds like it should work. But nobody here has tried to do that, so I can't guarantee it will work.

User avatar
Don_Jeronimo
 
Posts: 26
Joined: Sun Jan 11, 2015 6:39 am

Re: Fingerprint question

Post by Don_Jeronimo »

Ok thanks for the quick reply, I guess I'll give it a go.
So far I added the Match (and buffer 2) function to the library and ran a test using templates stored in the sensor...

Judging from a test I ran loading the templates from the scanner into the buffers and using Match (took around 4-5 seconds to match 16 templates). It'll be pretty slow, if it works at all (I won't be loading two templates at a time and won't be printing every line to the serial, but I guess loading from an external source would be even slower so that will probably even out)

Anyway, if I get it to work I'll post the code (crappy as it may be).

Regs,
J

User avatar
Don_Jeronimo
 
Posts: 26
Joined: Sun Jan 11, 2015 6:39 am

Re: Fingerprint question

Post by Don_Jeronimo »

Oeps, had a delay in there now runs super fast.. sorry for spamming.

User avatar
sercanaygun
 
Posts: 9
Joined: Thu Jul 17, 2014 9:08 pm

Re: Fingerprint question

Post by sercanaygun »

Hello everyone,
Previously I had asked about getting image directly on my desktop or any external file in my pc as char based file. As you all underlined the functions UpImage and DownImage, I tried to understand and tried some coding. But these instructions just say to sensor "upload", but where? no path, no file, or even after reply from sensor as ACK no returned data pack to get image. I really got lost. Please help me :( .

P.S: I also tried for ReadNotepad etc. sensor giving no reply for this.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Fingerprint question

Post by adafruit_support_rick »

Have you tried the SFGDemo program? That allows you to save the raw image to disk, I believe

User avatar
sercanaygun
 
Posts: 9
Joined: Thu Jul 17, 2014 9:08 pm

Re: Fingerprint question

Post by sercanaygun »

Yes I have tried it but I got an error related to password or sth. like this as everyone says. Anyway, after my message, I got a solution. Depending on your code on GitHub, (by the way you are doing your best both for support and the code) I added a new function that read the finger image immediately after scanning and putting raw data in ImageBuffer. But I no sure whether I need to make a process on it or not, because it mentions about taking 4-bit of gray values from adjacent pixels. Do you have any idea about taking the values immediately from image buffer and creating an image on MatLab to try, do you agree that I will see my finger details as a real picture? or just damaged one? If it needs a pre-process what is your recommendation?

Thank you for your reply

Best regards

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Fingerprint question

Post by adafruit_support_rick »

You will need to pre-process the image, since it is coming out with two 4-bit pixels packed into each byte. You will need a program to split that into two bytes.

User avatar
Don_Jeronimo
 
Posts: 26
Joined: Sun Jan 11, 2015 6:39 am

Re: Fingerprint question

Post by Don_Jeronimo »

Hi,

As mentioned before I'm trying to push templates from a DB to the sensor for matching using the match function.
For testing purposes, I'm using the adafruit getModel script to get the templates out, but it seems I'm not getting the full template. Increasing the serial baudrate a bit did get me some extra bytes, looking at the packet raises some questions though. This is what I'm getting:

0xEF, 0x1, 0xFF, 0xFF, 0xFF, 0xFF, (the address and adder)
0x2, (package identifier; data package)
0x0, 0x82, (package size?)
0x3, 0x1, (what is this, it is in every package?)
0x59, 0x1D, 0x0, 0x0, 0xFF,
0xFE, 0xFF, 0xFE, 0xF0, 0xFE, 0xE0, 0x6, 0xE0, 0x6, 0x80, 0x6, 0x80, 0x6, 0x0, 0x2, 0x0,
0x2, 0x0, 0x2, 0x0, 0x86, 0x0, 0x76, 0x0, 0x5, 0x0, 0x6, 0x0, 0xE, 0x0, 0xE, 0x0,
0x1E, 0x0, 0xFE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x80, 0x19,
0xAC, 0x95, 0x45, 0x13, 0x0, 0x0, 0x0, 0x0, 0xFE, 0x0, 0x0, 0x9E, 0xFF, 0x25, 0x1, 0x0,
0x0, 0x0, 0xFE, 0x0, (from here it starts printing the extra ff bytes, total bytes 84)

the Questions, I hope you can help me with please:

-I'm feeling I'm still not getting the whole template, could this be due to the Arduino 64 byte buffer?
-Do you think the 0x02 after the adder implies there is another package coming (e.g untill the 0x08 end package)?
-Any chance you could help me out by updating the library to print the full template ;)

Many thanks

Regs,
Jeronimo

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Fingerprint question

Post by adafruit_support_rick »

Hmmm. You're right - that's not the whole thing. I modified the show_fingerprint_templates sketch a bit, and it now seems to grab the whole thing.

That's the good news. The bad news is two-fold:
1) I can't see any real patterns in the data. You'd think there would at least be a length byte in there someplace, but I'm not seeing it
2) If you run the same dumps a second time, the data will be different. Not completely different, but there will be some differences.

Code: Select all

/*************************************************** 
  This is an example sketch for our optical Fingerprint sensor

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/


#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(2, 3);


Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()  
{
  while(!Serial);
  Serial.begin(9600);
  Serial.println("finger template test");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }

  //get the templates for fingers 1 through 10
  for (int finger = 1; finger < 10; finger++)
    uploadFingerpintTemplate(finger);

}

void loop()
{

}

uint8_t uploadFingerpintTemplate(uint16_t id)
{
 uint8_t p = finger.loadModel(id);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.print("template "); Serial.print(id); Serial.println(" loaded");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    default:
      Serial.print("Unknown error "); Serial.println(p);
      return p;
  }

  // OK success!

  p = finger.getModel();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.print("template "); Serial.print(id); Serial.println(" transferring");
      break;
   default:
      Serial.print("Unknown error "); Serial.println(p);
      return p;
  }
  
  uint8_t templateBuffer[256];
  memset(templateBuffer, 0xff, 256);  //initialize template buffer
  int index=0;
  uint32_t starttime = millis();
  while ((index < 256) && ((millis() - starttime) < 1000))
  {
    if (mySerial.available())
    {
      templateBuffer[index] = mySerial.read();
      index++;
    }
  }
  
  Serial.print(index); Serial.println(" bytes read");
  
  //dump entire templateBuffer.  This prints out 16 lines of 16 bytes
  for (int count= 0; count < 16; count++)
  {
    for (int i = 0; i < 16; i++)
    {
      Serial.print("0x");
      Serial.print(templateBuffer[count*16+i], HEX);
      Serial.print(", ");
    }
    Serial.println();
  }
}


User avatar
sercanaygun
 
Posts: 9
Joined: Thu Jul 17, 2014 9:08 pm

Re: Fingerprint question

Post by sercanaygun »

Hello again,
I also try to get the raw image data in image buffer but surprisingly I get the similar sequence like in template. Are we sure that template just hold approx. 200 bytes for each finger data. Or if my code is not faulty, image data in image buffer must be much amount than following example that I get. Because it should be 256x288 pixel image. 256*288 is nearly 72000 pixels and each is a byte. But I get approx. 5000 hex value. When I try to draw its gray values in matlab, I get very small image. (code at the end, and I use the function getImageUploadComp(), with instruction code 0xAH namely UpImage)

raw image data:

Code: Select all

BANNED.............FFF...

Code: Select all

/*************************************************** 
  This is an example sketch for our optical Fingerprint sensor

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

int getFingerprintIDez();

SoftwareSerial mySerial(10, 11);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()  
{
  Serial.begin(9600);
  Serial.println("finger template test");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }


finger.getImage(); 

uint8_t pp = finger.getImageUploadComp();

delay(500);

}

void loop() {
 
  
  for(int f = 0; f<100; f++){
    
  for (int count= 0; count < 64; count++)
    {
      Serial.print( mySerial.read(), HEX);       
    }
    
  Serial.println();
  Serial.flush();
}
  
  
}
  

User avatar
dpswt
 
Posts: 5
Joined: Thu Jan 08, 2015 7:05 pm

Re: Fingerprint question

Post by dpswt »

Hi, sercanaygun, I'm also trying what you tried, but what I found (and it makes sense) is that the buffer is basically overflowing. You are correct that you should get a lot more bytes (and you probably do), but the buffer on SoftwareSeriial only handles 64 bytes before rewriting itself (as far as I know).

You can check this using the overflow() method (e.g. mySerial.overflow()).

The next step, I would guess, would be to prevent overflow although I'm not entirely sure how to accomplish this... Any help is appreciated.

User avatar
sercanaygun
 
Posts: 9
Joined: Thu Jul 17, 2014 9:08 pm

Re: Fingerprint question

Post by sercanaygun »

Dear dpswt,
First of all, thank you for your reply. I also think on that way, becuse arduino controller serial buffer has 64 bytes capacity. Then I changed my mind, becuse I get something like 5000 HEX values like EF01... again this is more than the buffer capacity of arduino, but much less than the image. if I would get like 64 bytes, maybe this would be true. Even maybe I am wrong, I am not sure. I will try to implement some other solutions using as you say .overflow() anyway. If any of us find any solution, sharing in here would be perfect. If we still do not get any solutions, maybe sending an e-mail to vendor would be good idea, becuse their PC based user interface programme seems to get image.

Best Regards

User avatar
dpswt
 
Posts: 5
Joined: Thu Jan 08, 2015 7:05 pm

Re: Fingerprint question

Post by dpswt »

Yes, I also get more than 64 bytes but thats probably because we start reading incoming bytes as we are still receiving.. basically we only have 64 bytes at a point in time but we are still receiving bytes as we are reading.. double buffering was suggested and I guess that would attenuate this problem although I'm not sure the best way to implement... Now I'm probably talking out of my ass, but my best guess is that we either are receiving bytes faster than we can read them or we start reading them too late, or maybe both, I dont really know. I haven't really checked too deeply how software serial works nor am I an expert at this so I'm probably wrong.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”