Giter Site home page Giter Site logo

leosocy / edcc-palmprint-recognition Goto Github PK

View Code? Open in Web Editor NEW
142.0 8.0 50.0 180 KB

EDCC: An efficient and accurate algorithm for palmprint recognition.

Home Page: https://blog.leosocy.top/posts/4354/

License: MIT License

C++ 59.27% CMake 12.53% Python 15.21% Shell 8.92% C 4.07%
palmprint-recognition biometrics competition-code palmprint palm palmid palmprintid palm-print palm-recognition accurate-algorithm

edcc-palmprint-recognition's Introduction

EDCC: An efficient and accurate algorithm for palmprint-recognition

Build Status codecov MIT licensed

EDCC(Enhanced and Discriminative Competitive Code), which is used for palmprint-recognition.

Use the EDCC algorithm with default config to validate on several published palmprint databases(multispectral, tongji), the first N(N = 2, 4, 6, 8) palmprint images of each palm are employed as training samples and the remaining palmprint images form the test sample set. Each sample in the test sample set is compared with all samples of each class in the training set to calculate the matching score. The class that produces the highest matching score is treated as the class of the test sample.

Database N=2 N=4 N=6 N=8
Multispectral_B 98.6800% 99.8750% 99.9667% 99.9800%
Multispectral_G 98.8400% 99.8500% 99.9333% 99.9500%
Multispectral_I 98.9200% 99.9000% 99.9000% 99.9000%
Multispectral_R 98.8400% 99.7500% 99.8667% 99.9000%
Tongji 98.8056% 99.6979% 99.9881% 99.9861%

Advantages of EDCC algorithm:

  1. Less training samples.
  2. Faster recognition speed.
  3. Higher recognition accuracy.

More details about EDCC

Installation

Install library

There are some requirements if you want to install EDCC library:

Steps:

  1. git clone https://github.com/Leosocy/EDCC-Palmprint-Recognition.git
  2. cd EDCC-Palmprint-Recognition && mkdir -p build && cd build
  3. cmake .. && sudo make install

Install Python Package

Please make sure that the edcc library has been successfully installed by following the steps above.

Python3.x required.

Steps:

  1. cd pypackage
  2. python setup.py install

QuickStart

The project provides a Docker container runtime environment with edcc library and python package installed.

You can quick start accord to the following commands:

# bootstrap a docker container with edcc library installed
./manage.sh env

# run c example
cd /app/examples/c_example && mkdir -p build && cd build && cmake .. && make && ./run_c_sample

# run cpp example
cd /app/examples/cpp_example && mkdir -p build && cd build && cmake .. && make && ./run_cpp_sample

# run python example
cd /app/examples/py_example && python example.py

Usage

Make sure you have installed library and Python package before using edcc.

And you can see more usage details under examples directory about usage.

C/C++

In your CMakeLists.txt, add these lines:

find_package(edcc REQUIRED)
include_directories(${EDCC_INCLUDE_DIR})
...
add_dependencies(${YOUR_PROJECT} ${EDCC_LIBRARIES})
target_link_libraries(${YOUR_PROJECT} ${EDCC_LIBRARIES})

Then you can use it in your source code(C or C++) like this:

C

#include <edcc/c_api.h>

#define ASSERT_STATUS_OK(s) \
  do {                      \
    if (s[0] != '\0') {     \
      perror(s + 1);        \
      return -1;            \
    }                       \
  } while (0)

int main() {
  // create a new encoder.
  char status[128];
  int encoder_id = new_encoder_with_config(29, 5, 5, 10, status);
  ASSERT_STATUS_OK(status);
  // encode palmprints to code buffer.
  unsigned long buffer_size = get_size_of_code_buffer_required(encoder_id);
  char* code_buffer_one = (char*)malloc(buffer_size);
  char* code_buffer_another = (char*)malloc(buffer_size);
  encode_palmprint_using_file(encoder_id, one_image_file_path, code_buffer_one, buffer_size, status);
  ASSERT_STATUS_OK(status);
  encode_palmprint_using_file(encoder_id, another_image_file_path, code_buffer_another, buffer_size, status);
  ASSERT_STATUS_OK(status);
  // calculate the similarity score of two codes.
  double score = calculate_codes_similarity(code_buffer_one, code_buffer_another, status);
  ASSERT_STATUS_OK(status);
  return 0;
}

C++

#include <edcc/facade.h>
#include <edcc/status.h>

#define ASSERT_STATUS_OK(s) \
  do {                      \
    if (!s.IsOk()) {        \
      perror(s.msg());      \
      return -1;            \
    }                       \
  } while (0)

using edcc::EdccFacade;
using edcc::Status;

int main() {
  Status s;
  // create a new encoder.
  auto inst = EdccFacade::Instance();
  auto encoder_id = inst->NewEncoderWithConfig(29, 5, 5, 10, &s);
  ASSERT_STATUS_OK(s);
  // encode palmprints to code buffer.
  size_t buffer_size = inst->GetSizeOfCodeBufferRequired(encoder_id);
  char* code_buffer_one = new char[buffer_size];
  char* code_buffer_another = new char[buffer_size];
  inst->EncodePalmprint(encoder_id, one_image_file_path, code_buffer_one, buffer_size, &s);
  ASSERT_STATUS_OK(s);
  inst->EncodePalmprint(encoder_id, another_image_file_path, code_buffer_another, buffer_size, &s);
  ASSERT_STATUS_OK(s);
  // calculate the similarity score of two codes.
  double score = inst->CalcCodeSimilarity(code_buffer_one, code_buffer_another, &s);
  ASSERT_STATUS_OK(s);
  return 0;
}

Python

import edcc

config  = edcc.EncoderConfig(29, 5, 5 ,10)
encoder = edcc.create_encoder(config)
one_palmprint_code = encoder.encode_using_filename("./palmprint_one.bmp")
another_palmprint_code = encoder.encode_using_filename("./palmprint_another.bmp")
similarity_score = one_palmprint_code.compare_to(another_palmprint_code)

Contributing

Please see CONTRIBUTING.md

edcc-palmprint-recognition's People

Contributors

leosocy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edcc-palmprint-recognition's Issues

没有规则可制作目标"......opencv-4.5.0/release/lib/libopencv_dnn.so.4.5.0"

EDCC-Palmprint-Recognition/build$ cmake .. && sudo make install
CMake Warning (dev) at CMakeLists.txt:7 (PROJECT):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    CMAKE_PROJECT_VERSION
    CMAKE_PROJECT_VERSION_MAJOR
    CMAKE_PROJECT_VERSION_MINOR
    CMAKE_PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/zuoqiuyingyi/软件/EDCC-Palmprint-Recognition/build/googletest-download
[ 11%] Performing update step for 'googletest'
当前分支 master 是最新的。
[ 22%] No configure step for 'googletest'
[ 33%] No build step for 'googletest'
[ 44%] No install step for 'googletest'
[ 55%] No test step for 'googletest'
[ 66%] Completed 'googletest'
[100%] Built target googletest
Downloading https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/a_01.bmp......
Download https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/a_01.bmp success!
Downloading https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/a_02.bmp......
Download https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/a_02.bmp success!
Downloading https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/b_01.bmp......
Download https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/b_01.bmp success!
Downloading https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/b_02.bmp......
Download https://blog-images-1257621236.cos.ap-shanghai.myqcloud.com/edcc_data/for_test_and_example/b_02.bmp success!
CMake Warning (dev) at build/edcc-config.cmake:11 (INCLUDE):
  Policy CMP0024 is not set: Disallow include export result.  Run "cmake
  --help-policy CMP0024" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  The file

    /home/zuoqiuyingyi/软件/EDCC-Palmprint-Recognition/build/edcc-targets.cmake

  was generated by the export() command.  It should not be used as the
  argument to the include() command.  Use ALIAS targets instead to refer to
  targets by alternative names.

Call Stack (most recent call first):
  examples/c_example/CMakeLists.txt:7 (FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/zuoqiuyingyi/软件/EDCC-Palmprint-Recognition/build
[sudo] zuoqiuyingyi 的密码: 
Scanning dependencies of target edcc
[  4%] Building CXX object CMakeFiles/edcc.dir/src/config/reader.cpp.o
[  8%] Building CXX object CMakeFiles/edcc.dir/src/controller/c_api.cpp.o
[ 13%] Building CXX object CMakeFiles/edcc.dir/src/controller/facade.cpp.o
[ 17%] Building CXX object CMakeFiles/edcc.dir/src/core/comparer.cpp.o
[ 21%] Building CXX object CMakeFiles/edcc.dir/src/core/encoder.cpp.o
[ 26%] Building CXX object CMakeFiles/edcc.dir/src/core/gabor_filter.cpp.o
make[2]: *** 没有规则可制作目标“/home/zuoqiuyingyi/软件/opencv-4.5.0/release/lib/libopencv_dnn.so.4.5.0”,由“libedcc.so.0.2.0” 需求。 停止。
make[1]: *** [CMakeFiles/Makefile2:228:CMakeFiles/edcc.dir/all] 错误 2
make: *** [Makefile:130:all] 错误 2

这是否意味着该项目不支持OpenCV 4.5.0呀?

同一个人的掌纹相似度过低

./data/a_01.bmp <-> ./data/a_02.bmp similarity score:0.2390011890606421
./data/b_01.bmp <-> ./data/b_02.bmp similarity score:0.22711058263971462
demo 里边的数据的相似度 很低,是正常的吗? 实际使用需要别的配置参数?

运行命令"./manage.sh env"时报错,怎么解决

报错信息如下:
[INFO] pulling registry.cn-hangzhou.aliyuncs.com/leosocy/opencv:ci image success!
-- Configuring done
-- Generating done
-- Build files have been written to: /app/build_install/googletest-download
[ 11%] Performing download step (git clone) for 'googletest'
Cloning into 'googletest-src'...
fatal: invalid reference: master
CMake Error at googletest-download/googletest-prefix/tmp/googletest-gitclone.cmake:75 (message):
Failed to checkout tag: 'master'

make[2]: *** [CMakeFiles/googletest.dir/build.make:91: googletest-prefix/src/googletest-stamp/googletest-download] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/googletest.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
CMake Error at test/CMakeLists.txt:28 (MESSAGE):
Build step for googletest failed: 2

-- Configuring incomplete, errors occurred!
See also "/app/build_install/CMakeFiles/CMakeOutput.log".

Wrong palm print comprasion computation

while (lhs_md_cur_ptr < lhs_md_end_ptr) {
uint8_t distance = *(uint8_t*)lhs_md_cur_ptr ^ *(uint8_t*)rhs_md_cur_ptr;
if (distance == 0x00) { // same d, s.
acc += 2;
} else if (distance < 0x10) { // same d, diff s.
acc += 0;
}

Based on the matching stage's math definition
$$M\left(X,Y\right)=\frac{1}{2N^2}\sum_{i=1}^{N}\sum_{j=1}^{N}\left[\left(C_X\left(i,j\right)==C_Y\left(i,j\right)\right)+\left(C_X\left(i,j\right)==C_Y\left(i,j\right)\right)\cap\lnot\left(Cs_X\left(i,j\right)\oplus C s_Y\left(i,j\right)\right)\right]$$

When the variable $d$ is the same but the variable $s$ is different, the acc variable should be increased by 1.

In addition, if the variable $d$ is the same but the variable $s$ is different, the distance should yield a specific value of 0x10. It is not recommended to use a comparison expression for this simple operation; instead, an equality expression should be used.

[SOLVED] OSError: Library [libedcc.so] not found.

I solved this issue

This is the error I got while running python seytup.py install
and also same kind of error on Robustpalmroi
Traceback (most recent call last):
File "/home/qwickbit/Desktop/EDCC-Palmprint-Recognition/pypackage/edcc/adapter.py", line 24, in init
self._lib = ctypes.cdll.LoadLibrary(self.LIB_NAME)
File "/home/qwickbit/anaconda3/lib/python3.6/ctypes/init.py", line 426, in LoadLibrary
return self._dlltype(name)
File "/home/qwickbit/anaconda3/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libedcc.so: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 10, in
import edcc
File "/home/qwickbit/Desktop/EDCC-Palmprint-Recognition/pypackage/edcc/init.py", line 31, in
adapter = EdccAdapter()
File "/home/qwickbit/Desktop/EDCC-Palmprint-Recognition/pypackage/edcc/adapter.py", line 28, in init
self.LIB_NAME, self.LIB_INSTALLATION_URL
OSError: Library [libedcc.so] not found.
Please see https://github.com/Leosocy/EDCC-Palmprint-Recognition#install-library

Do you have so library installed?

Originally posted by @manoharsonwan in #18 (comment)

同类手掌的掌纹识别失败

您好:
同类手掌的掌纹也识别失败,,原因是待比对两张图片未校准,请问你有校准部分的代码吗?校准包括平移或者 旋转之类的;
望回复。谢谢

请教训练流程、命令

你好,我想请教一下,您的算法是如何训练的,采用的是CNN方面吗?
还有我在linux上调试的时候无法生成lib相关文件,整个流程您可以大概在跟我说一下吗?谢谢

How to save encode of palm recognition become a file

I had to save encode of palmprint become a file with pickle, but i had this error:

Traceback (most recent call last):
  File "/home/pi/Coba/PalmDetection/PalmRecognition.py", line 19, in <module>
    bytes = pickle.dumps(one_palmprint_code)
_pickle.PicklingError: Can't pickle <class 'ctypes.c_char_Array_849'>: attribute lookup c_char_Array_849 on ctypes failed

What should i do to save the encode? i need to save that because i will send this to database

thanks

not going past python setup.py install

Good day,
I am trying to test your library but cannot no go past python setup.py install.
I have successfully installed opencv 4.5 and EDCC.
This is the screenshot of my error:
image
and this is my python version
image
on ubuntu 20.04
Your quick response will be greatly appreciated

安装失败

您好,我是在Windows下装的,但是编译完发现没有edcc.lib 而且用dumpbin 到处edcc.dll 显示并没有函数,没有lib无法编译其他代码啊 ,求赐教

error of Building CXX object CMakeFiles/edcc.dir/src/core/gabor_filter.cpp.o

i have a error when i build the edcc
[ 14%] Building CXX object CMakeFiles/edcc.dir/src/core/gabor_filter.cpp.o
/Users/edward/Documents/COMP4134/comp4134 project/EDCC-Palmprint-Recognition-master/EDCC-Palmprint-Recognition/src/core/gabor_filter.cpp:54:30: error: use of undeclared identifier 'CV_BGR2GRAY'
cvtColor(resized, *result, CV_BGR2GRAY);
^
1 error generated.
make[2]: *** [CMakeFiles/edcc.dir/src/core/gabor_filter.cpp.o] Error 1
make[1]: *** [CMakeFiles/edcc.dir/all] Error 2
make: *** [all] Error 2

OSError: Library [libedcc.dylib] not found.

Hello,
my system is MacOS,when I exectue command "python3 setup.py install",error"OSError: Library [libedcc.dylib] not found.",But the file (libedcc.dylib) is in the directory(build),so ,can someone help me ?

*** No rule to make target 'run_py_sample'

Hello!

After sudo make -j run_py_sample I am getting an error:

make: *** No rule to make target 'run_py_sample'. Stop.

Linking was successful, i think:
...
[100%] Linking CXX shared library edcc_lib/libedcc.so
[100%] Built target edcc
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libedcc.so.1.1
-- Installing: /usr/local/lib/libedcc.so.1
-- Installing: /usr/local/lib/libedcc.so
-- Installing: /usr/local/include/edcc
-- Installing: /usr/local/include/edcc/edcc.h
-- Installing: /usr/local/share/edcc/ApiUsage.md
-- Installing: /usr/local/share/edcc/AboutEDCC.md
-- Installing: /usr/local/share/edcc/LICENSE
-- Installing: /usr/local/share/edcc/FindEDCC.cmake

error when python setup.py install

This is the error I got while running python seytup.py install
and also same kind of error on Robustpalmroi

Traceback (most recent call last):
File "/home/qwickbit/Desktop/EDCC-Palmprint-Recognition/pypackage/edcc/adapter.py", line 24, in init
self._lib = ctypes.cdll.LoadLibrary(self.LIB_NAME)
File "/home/qwickbit/anaconda3/lib/python3.6/ctypes/init.py", line 426, in LoadLibrary
return self._dlltype(name)
File "/home/qwickbit/anaconda3/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: libedcc.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "setup.py", line 10, in
import edcc
File "/home/qwickbit/Desktop/EDCC-Palmprint-Recognition/pypackage/edcc/init.py", line 31, in
adapter = EdccAdapter()
File "/home/qwickbit/Desktop/EDCC-Palmprint-Recognition/pypackage/edcc/adapter.py", line 28, in init
self.LIB_NAME, self.LIB_INSTALLATION_URL
OSError: Library [libedcc.so] not found.
Please see https://github.com/Leosocy/EDCC-Palmprint-Recognition#install-library

请教参数选择

您好,最近看到您的写的算法教程,我自己实现了一个,但是目前准确率只有67%,可能是我参数选择有些问题,想请问下关于gabor filter和拉普拉斯算子的参数是设的多少?

Library not loaded: @rpath/libopencv_gapi.4.2.dylib

python3 setup.py install
Traceback (most recent call last):
File "/Users/zhouchaohong/Documents/PythonProjects/EDCC-Palmprint-Recognition-master/pypackage/edcc/adapter.py", line 24, in init
self._lib = ctypes.cdll.LoadLibrary(self.LIB_NAME)
File "/opt/anaconda3/lib/python3.7/ctypes/init.py", line 442, in LoadLibrary
return self._dlltype(name)
File "/opt/anaconda3/lib/python3.7/ctypes/init.py", line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libedcc.dylib, 6): Library not loaded: @rpath/libopencv_gapi.4.2.dylib
Referenced from: /usr/local/lib/libedcc.0.2.0.dylib
Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "setup.py", line 10, in
import edcc
File "/Users/zhouchaohong/Documents/PythonProjects/EDCC-Palmprint-Recognition-master/pypackage/edcc/init.py", line 31, in
adapter = EdccAdapter()
File "/Users/zhouchaohong/Documents/PythonProjects/EDCC-Palmprint-Recognition-master/pypackage/edcc/adapter.py", line 28, in init
self.LIB_NAME, self.LIB_INSTALLATION_URL
OSError: Library [libedcc.dylib] not found.

in fact opencv4.2 is installed

edcc has no attribute 'EncoderConfig'

I am getting this error while running the example.py file

File "example.py", line 16, in
config = edcc.EncoderConfig(29, 5, 5, 10)
AttributeError: module 'edcc' has no attribute 'EncoderConfig'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.