Fingerprint in python with opencv

Sir this is my code


import glob
import cv2
import numpy as np
import os
fingerprint_test = cv2.imread("D:/mfapython/muhammadisthebest.tif")
cv2.imshow("Original", cv2.resize(fingerprint_test, None, fx=1, fy=1))
cv2.waitKey(0)
cv2.destroyAllWindows()

for file in [file for file in os. listdir("d:/mfapython/fingerprintdatabase/*.tif")]:
    fingerprint_database_image = cv2.imread("./database/"+file)
    fingerprint_database_image = [cv2.imread(file) for file in glob.glob("d:/mfapython/fingerprintdatabase/*.tif")]
    sift = cv2.SIFT_create()
    keypoints_1, descriptors_1 = sift.detectAndCompute(fingerprint_test, None)
    keypoints_2, descriptors_2 = sift.detectAndCompute(fingerprint_database_image, None)

see error


cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\features2d\src\sift.dispatch.cpp:512: error: (-5:Bad argument) image is empty or has incorrect depth (!=CV_8U) in function 'cv::SIFT_Impl::detectAn
computer
image is empty or has incorrect depth (!=CV_8U) in function 'cv::SIFT_Impl::detectAn

this line gives me the error

please guide me on how to resolve this error

Regard’s

what do you want to do here ?
why do you assign twice to fingerprint_database_image ?
why an image list ?

sir sir, you are right now this is my code, and faced a new error in the last line

import glob
import cv2
import numpy as np
import os
fingerprint_test = cv2.imread(“e:/21cccc/mfaamir.tif”)
cv2.imshow(“Original”, cv2.resize(fingerprint_test, None, fx=1, fy=1))
cv2.waitKey(0)
cv2.destroyAllWindows()
#for file in [file for file in os.listdir(“E:/21cccc/database/.tif")]:
for file in [file for file in os.listdir(“E:/21cccc/database”)]:
fingerprint_database_image = [cv2.imread(file) for file in glob.glob("E:/21cccc/database/
.tif”)]
sift = cv2.SIFT_create()
keypoints_1, descriptors_1 = sift.detectAndCompute(fingerprint_test, None)
keypoints_2, descriptors_2 = sift.detectAndCompute(fingerprint_database_image, None)

see error

Traceback (most recent call last):
File “e:\py\newfortest.py”, line 15, in
keypoints_2, descriptors_2 = sift.detectAndCompute(fingerprint_database_image, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function ‘detectAndCompute’

Overload resolution failed:

  • image is not a numpy array, neither a scalar
  • Expected Ptrcv::UMat for argument ‘image’

thank’s in advance for your valuable reply
regard’s

it does not expect a list of images (again !)

then, please, you MUST CHECK the outcome of imread() !
you MUST !!! ALWAYS !!!
if it does not load, you produce errors way down later in your code, and you dont know why …

sorry sir I disturb you again and again
Please send me the sample code for how to load the fingerprint image
and compare it with the current image

please send me the sample code

thank you in advance for your help

regards

no i won’t

maybe you can read a bit here (ch 6)

but in the end, you will need actual programming & research skills to achieve something, that’s SOTA.