brianrho / FPM

Arduino library for the R30x/ZFMxx/FPMxx optical fingerprint sensors
104 stars 41 forks source link

R551 sensor does not get right image imgae_to_pc #11

Closed baku-hatsu closed 5 years ago

baku-hatsu commented 5 years ago

python output: ----------Extract Fingerprint Image------------

Options: Press 1 to enter serial port settings Press 2 to scan a fingerprint and save the image Press 3 to view help Press 4 to exit

1

Enter Arduino serial port number: COM3 Enter serial port baud rate: 57600

Options: Press 1 to enter serial port settings Press 2 to scan a fingerprint and save the image Press 3 to view help Press 4 to exit

2

Enter filename/path of output file (without extension): asd SEND IMAGE TO PC test

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 1 0 [+]Read complete

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 17 0 0 0 0 0 1 F4 0 3 FF FF FF FF 0 2 0 6 [+]Read complete

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 17 0 0 0 0 0 1 F4 0 3 FF FF FF FF 0 2 0 6 [+]Read complete Found fingerprint sensor! Capacity: 500 Packet length: 128

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 1 0 [+]Read complete

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 17 0 0 0 0 0 1 F4 0 3 FF FF FF FF 0 2 0 6 [+]Read complete Packet length set to 128 bytes Waiting for a finger...

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 1 2 [+]Read complete

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 1 0 [+]Read complete Image taken

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x7 [+]Length: 1 0 [+]Read complete Starting image stream... Image saved as asd.bmp FF FF FF FF FF FF FF FF FF FF FF FF FF EF 1 FF FF FF FF 2 0 82 FF FF FF FF

Picture is this:

asd

Arduino seriam monitor shows this: [+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x2 [+]Length: 128 ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮FF ⸮EF 1 ⸮FF ⸮FF ⸮FF ⸮FF 2 Read data failed: -1

Error receiving packet 67

brianrho commented 5 years ago

No, I said to provide a screenshot of the python console itself after the image is done being transferred. Dont paste the text. Upload an image of the console.

brianrho commented 5 years ago

Also turn off debug, when you do this

baku-hatsu commented 5 years ago

When i turn off debuging the python exe doesnt work: image it creates blank image, with no content.

With debugging is open, i get this: image This creates image as seen in above comments

brianrho commented 5 years ago

Okay. So this is the latest version of the library, right? And in the first case, you get "Timeout!" after waiting for a few seconds?

brianrho commented 5 years ago

The "Timeout!" doesn't show immediately the image stream begins?

baku-hatsu commented 5 years ago

Yes it dosnt show immediately, it takes like 10 or little more seconds. And this is latest version of library, with R551 uncommented line

brianrho commented 5 years ago

It seems your module has a different image size of 192x192. I've pushed a change to the python script. Assign True to FPM_R551_MODULE at the top and run it. Let me know how it works out

brianrho commented 5 years ago

It's important that debugging is turned off for this sketch because the debug messages go through the same Serial port as the image stream, so all those debug strings end up getting written to the bmp file, which isnt what you want.

baku-hatsu commented 5 years ago

I get same error: image Did you recompiled python exe or it read from that file?

brianrho commented 5 years ago

No I haven't rebuilt the exe. Can you run the python script?

baku-hatsu commented 5 years ago

I edite phyton file, but i dont see changes, so i assume your changes is only on file, not on .exe, to build exe from python file i cant yet, i had lots of trouble with python on Windows 10, would be good if you could build it

baku-hatsu commented 5 years ago

Ok nevermond, i did run python file, and i got image however it doesnt look as expected either: test

brianrho commented 5 years ago

Let me see the console output.

baku-hatsu commented 5 years ago

image

baku-hatsu commented 5 years ago

According to documentation image buffer size can be 192x192 with depth of 8 image

brianrho commented 5 years ago

Yeah, made a mistake. In the python code, change the WIDTH = 96 to 192.

baku-hatsu commented 5 years ago

I tried that myself, i still get error. Console looks like this: image Image looks like this: othertest

brianrho commented 5 years ago

That looks like the very last packet. Can you try running it again? I want to see if the failure is consistent

brianrho commented 5 years ago

I think you didnt change this line FPM_R551_MODULE = False to True like I said. The arduino ends up waiting forever for another packet, when the image stream is already completed.

baku-hatsu commented 5 years ago

Two tries out of five did not gave error message, however rest of the tries gave same error message. All scanned images was same size. Code is: image

brianrho commented 5 years ago

What is the exact size? Check the properties of the generated image and send a screenshot of that. Also a screenshot of the console output when there was no error.

baku-hatsu commented 5 years ago

Scanned image size is 192x192 pixels Console look like this: port is COM3 and bound is 57600 image

baku-hatsu commented 5 years ago

As well im using python -m pip install pyserial as for serial import for python, that maybe be other kind of serial?

brianrho commented 5 years ago

No, its fine. Run the sketch, but use the serial monitor instead.

brianrho commented 5 years ago

Looks like the problem isnt with the script, its with the module not sending FPM_ENDDATAPACKET to show that its done.

brianrho commented 5 years ago

You haven't made any changes to the image_to_pc sketch, right?

baku-hatsu commented 5 years ago

No, i havent, only to FPM.h library, where i uncommented one line of code / R551 is different in a few ways (no high-speed search, off-by-one template indices) uncomment this line if you have one of those /

define FPM_R551_MODULE

brianrho commented 5 years ago

Okay. Comment out line 663 outStream->write(byte); in FPM.cpp. Enable debugging. Then run the sketch with the serial monitor alone. Let me see what is printed in the last few packets of the image, before the error shows up.

baku-hatsu commented 5 years ago

[+]Got header [+]Address: 0xFFFFFFFF [+]PID: 0x2 [+]Length: 128 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 80 EF 1 FF FF FF FF 8 0 82 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF Read data failed: -1

Error receiving packet 80

And this is like 1/3 shorter than rest

baku-hatsu commented 5 years ago

At beginning it seems to get normal packages but on the end only FF's appear

brianrho commented 5 years ago

The FFs arent a problem, they just show that most of the image is white pixels as expected. Comment out these debug lines in the code:

[+]Got header
[+]Address: 0xFFFFFFFF

As well as line 670: FPM_DEBUG_HEX(byte); FPM_DEBUG_PRINT(" ");

I want only the PID and length to be printed.

baku-hatsu commented 5 years ago

Before stream: [+]PID: 0x7 [+]Length: 1

On the stream: [+]PID: 0x2 [+]Length: 128 Read data failed: -1

Error receiving packet 144

brianrho commented 5 years ago

Run it a few more times, check that it gives the same result and stops at the same packet

baku-hatsu commented 5 years ago

Yes its always same packet

brianrho commented 5 years ago

And this is the very last packet always:

[+]PID: 0x2
[+]Length: 128

Can you check if any packet has a PID of 0x8?

baku-hatsu commented 5 years ago

There is no packet with PID 0x8

brianrho commented 5 years ago

At line 662 in FPM.cpp, change this:

if (outStream != NULL) {
      outStream->write(byte);
}

to

if (outStream != NULL) {
      outStream->write(byte);
      chksum += byte;
}

and this at 684: if (outStream == NULL && to_check != chksum) to: if (to_check != chksum)

brianrho commented 5 years ago

Let me know if it prints "Wrong chksum" for any packet.

brianrho commented 5 years ago

outStream->write(byte); should still be commented out as before.

baku-hatsu commented 5 years ago

It prints that for every stream packet

[+]Wrong chksum

Read data failed: -1

Error receiving packet 0

brianrho commented 5 years ago

What of the PID and length? There was no wrong chksum in the earlier commands, right?

baku-hatsu commented 5 years ago

[+]Wrong chksum [+]PID: 0x2 [+]Length: 128

[+]Wrong chksum

Read data failed: -1

Error receiving packet 0

It was all the time while stream begin, before stream, there there was this: [+]Length: 1 [+]PID: 0x7

brianrho commented 5 years ago

You mean, there was no "wrong chksum" before the stream began, but then after that, each packet has a wrong chksum? ALL the packets with wrong chksums have a PID of 0x2?

baku-hatsu commented 5 years ago

Yes

brianrho commented 5 years ago

Uncomment line 670: FPM_DEBUG_HEX(byte); FPM_DEBUG_PRINT(" "); and the other debug lines (Header and address only). I want to see the entire packet as its printed. Use pastebin.com to send a dump of everything printed in the serial monitor.

brianrho commented 5 years ago

Also send a copy of your FPM.cpp in another paste.

baku-hatsu commented 5 years ago

https://pastebin.com/Xcpz16Vv the serial monitor https://pastebin.com/vZpz5D75 fpm.cpp file

brianrho commented 5 years ago

Have you restarted the module, since you started using it to get images?

brianrho commented 5 years ago

The packet length setting is being ignored for some reason and it could be because it hasn't taken hold yet.

baku-hatsu commented 5 years ago

Probably not, how do i reset it? using reset pin or just unplug?