Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add NFIR package #26698

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions recipes/nfir/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sources:
"0.2.0.cci.20241122":
url: "https://github.com/usnistgov/NFIR/archive/b670b673f8c397f37b231d16bc8b41f934d05841.tar.gz"
sha256: "0bce5cd844560f82968540b0ae27248973bc1f3bfccadfc80e687f129a5588e8"
patches:
"0.2.0.cci.20241122":
- patch_file: "patches/0001-enable-cmake-install.patch"
- patch_file: "patches/0002-fix-missing-include-vector-in-nfir_lib.h.patch"
- patch_file: "patches/0003-fix-finding-opencv.patch"
- patch_file: "patches/0004-fix-build-issues-in-conan-CI.patch"
53 changes: 53 additions & 0 deletions recipes/nfir/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from conan import ConanFile
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
from conan.tools.files import get
from conan.tools.files import apply_conandata_patches, export_conandata_patches
from os import path

class NFIRConan(ConanFile):
name = "nfir"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/usnistgov/NFIR"
topics = ("NIST", "NFIR")
license = "NIST-PD"
description = "The NIST Fingerprint Image Resampler NFIR is a library capable of upsampling or downsampling fingerprint images."
settings = "os", "compiler", "build_type", "arch"
options = { "shared": [True, False], "fPIC": [True, False] }
default_options = { "shared": False, "fPIC": True }
generators = "CMakeDeps"
package_type = "library"
implements = ["auto_shared_fpic"]

def export_sources(self):
export_conandata_patches(self)

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("opencv/4.10.0")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["USE_NFIMM"] = False
tc.variables["_WIN32_64"] = self.settings.os == "Windows"
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["NFIR_ITL"]
self.cpp_info.set_property("cmake_file_name", "NFIR")
self.cpp_info.set_property("cmake_target_name", "NFIR::NFIR")
self.runenv_info.append_path("PATH", path.join(self.package_folder, "bin"))
34 changes: 34 additions & 0 deletions recipes/nfir/all/patches/0001-enable-cmake-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 971888942ec4ac37406ab7c17ba9daf5620c3b41 Mon Sep 17 00:00:00 2001
From: Tomas Krupa <[email protected]>
Date: Wed, 26 Feb 2025 15:13:14 +0100
Subject: [PATCH] enable cmake install

---
CMakeLists.txt | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2fb3e93..a89934d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,3 +27,16 @@ message(STATUS "PROJECT_NAME: ${PROJECT_NAME}")
# Pick up the library and binary
add_subdirectory(src/lib)
add_subdirectory(src/bin)
+
+install(DIRECTORY src/include/
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/NFIR
+ FILES_MATCHING PATTERN "*.h*")
+
+install(TARGETS ${PROJECT_NAME}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+install(PROGRAMS ${CMAKE_BINARY_DIR}/src/bin/NFIR_bin
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
+ RENAME NFIR)
\ No newline at end of file
--
2.34.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 6b5c15a98860b61bdf6545ece0e087f6f8c802ef Mon Sep 17 00:00:00 2001
From: Tomas Krupa <[email protected]>
Date: Wed, 26 Feb 2025 15:36:13 +0100
Subject: [PATCH] fix missing include <vector> in nfir_lib.h

---
src/include/nfir_lib.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/include/nfir_lib.h b/src/include/nfir_lib.h
index 9c2d6f5..39ca31d 100644
--- a/src/include/nfir_lib.h
+++ b/src/include/nfir_lib.h
@@ -31,6 +31,7 @@ identified are necessarily the best available for the purpose.
#include "exceptions.h"

#include <string>
+#include <vector>

#define NFIR_VERSION "0.2.0"

--
2.34.1

44 changes: 44 additions & 0 deletions recipes/nfir/all/patches/0003-fix-finding-opencv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From d85f484c4393dd31787e66018b11dff8642c4c82 Mon Sep 17 00:00:00 2001
From: Tomas Krupa <[email protected]>
Date: Wed, 26 Feb 2025 22:23:28 +0100
Subject: [PATCH] fix finding opencv

---
src/lib/CMakeLists.txt | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 12b3047..0a93f56 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -15,12 +15,15 @@ add_library( ${PROJECT_NAME} ${sources} )
# )


+find_package(OpenCV REQUIRED)
+target_link_libraries(${PROJECT_NAME} opencv::opencv)
+
if(_WIN32_64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
message(STATUS "LIB: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")

# To access OpenCV, use either these two lines below:
- include(D:/OpenCV/opencv-4.5.0/build/x64/vc15/lib/OpenCVConfig.cmake)
+ #include(D:/OpenCV/opencv-4.5.0/build/x64/vc15/lib/OpenCVConfig.cmake)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

# Or to access OpenCV, use these two lines below:
@@ -42,8 +45,8 @@ if(_WIN32_64)

else()
message(STATUS "LIB: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(OPENCV REQUIRED opencv4)
+ # find_package(PkgConfig REQUIRED)
+ # pkg_check_modules(OPENCV REQUIRED opencv4)
target_link_libraries(${PROJECT_NAME} ${OPENCV_LINK_LIBRARIES})
target_include_directories(${PROJECT_NAME} PUBLIC ${OPENCV_INCLUDE_DIRS})
target_compile_options(${PROJECT_NAME} PUBLIC ${OPENCV_CFLAGS_OTHER})
--
2.34.1

25 changes: 25 additions & 0 deletions recipes/nfir/all/patches/0004-fix-build-issues-in-conan-CI.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 26faac7eae45254c780d6d1a43c6d5ae6482c05d Mon Sep 17 00:00:00 2001
From: Tomas Krupa <[email protected]>
Date: Wed, 26 Feb 2025 17:30:18 +0100
Subject: [PATCH] fix build issues in conan CI

---
src/bin/nfir.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/nfir.cpp b/src/bin/nfir.cpp
index 9000cb6..d1cf266 100644
--- a/src/bin/nfir.cpp
+++ b/src/bin/nfir.cpp
@@ -350,7 +350,7 @@ int main(int argc, char** argv)
NFIR::resample( srcImageAry, tgtImageAry,
srcSampleRate, tgtSampleRate, "inch",
interpolationMethod, filterType,
- &imageWidth, &imageHeight, &lenSrcFileBlock,
+ &imageWidth, &imageHeight, reinterpret_cast<size_t*>(&lenSrcFileBlock),
srcImageFormat, tgtImageFormat, vecPngTextChunk,
logRuntime );
// Note: lenSrcFileBlock contains length of the generated, target
--
2.34.1

8 changes: 8 additions & 0 deletions recipes/nfir/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)

project(test_package CXX)

find_package(NFIR REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE NFIR::NFIR)
26 changes: 26 additions & 0 deletions recipes/nfir/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
from os import path

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
self.run(path.join(self.cpp.build.bindir, "test_package"), env="conanrun")
ext = ".exe" if self.settings.os == "Windows" else ""
self.run(f"NFIR{ext} --version", env="conanrun")
10 changes: 10 additions & 0 deletions recipes/nfir/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <iostream>

#include <NFIR/nfir_lib.h>

int main()
{
std::cout << NFIR::printVersion() << std::endl;

return 0;
}
3 changes: 3 additions & 0 deletions recipes/nfir/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.2.0.cci.20241122":
folder: all