Skip to content

Commit 9175f22

Browse files
committed
use unzip include folder instead of zip file as zip could not be unzip on docs.rs
1 parent 15b1a86 commit 9175f22

34 files changed

Lines changed: 4605 additions & 13 deletions

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
rustflags = ["-C", "link-arg=-Wl,-rpath,@executable_path/../lib"]
33

44
[env]
5-
INSIGHTFACE_PATH = "/Users/marcintha/workspace/baklava/insightface/cpp-package/inspireface/build/inspireface-macos/InspireFace"
5+
INSIGHTFACE_PATH = "/Users/marcinthaamnouay/workspace/baklava/insightface/cpp-package/inspireface/build/inspireface-macos/InspireFace"
66
# Enable the setting below to generate documentation locally
77
# DOCS_RS = "true"

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "baklava"
33
description = "A rust wrapper around the InsightFace library to perform face comparison"
4-
version = "0.1.3"
4+
version = "0.1.4"
55
edition = "2021"
66
authors = ["Marc Intha-amnouay <marc.inthaamnouay@gmail.com>"]
77
keywords = ["insightface", "face-comparison", "inspireface"]

build.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
use std::env;
22
use std::path::PathBuf;
3-
use std::process::Command;
43

54
fn main() {
65
let lib_path = match env::var("INSIGHTFACE_PATH") {
76
Ok(path) => PathBuf::from(path),
87
Err(_) => {
98
let current_dir = env::current_dir().unwrap();
109
match env::var("DOCS_RS").is_ok() {
11-
true => {
12-
// The headers can be passed from the "zipped" file "insightface_headers.zip"
13-
Command::new("unzip")
14-
.arg("insightface_headers.zip")
15-
.spawn()
16-
.expect("Expect unzip command to work");
17-
18-
current_dir
19-
}
10+
// Use the curent_directory which include the "include" directory.
11+
true => current_dir,
2012
false => {
2113
let local_path = format!(
2214
"insightface/cpp-package/inspireface/build/inspireface-{}/InspireFace",

include/herror.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Created by Jingyu Yan
3+
* @date 2024-10-01
4+
*/
5+
6+
#ifndef INSPIRE_FACE_HERROR_H
7+
#define INSPIRE_FACE_HERROR_H
8+
9+
// [Anchor-Begin]
10+
11+
#define HSUCCEED (0) // Success
12+
#define HERR_BASIC_BASE 0X0001 // Basic error types
13+
#define HERR_UNKNOWN HERR_BASIC_BASE // Unknown error
14+
#define HERR_INVALID_PARAM (HERR_BASIC_BASE + 1) // Invalid parameter
15+
#define HERR_INVALID_IMAGE_STREAM_HANDLE (HERR_BASIC_BASE + 24) // Invalid image stream handle
16+
#define HERR_INVALID_CONTEXT_HANDLE (HERR_BASIC_BASE + 25) // Invalid context handle
17+
#define HERR_INVALID_FACE_TOKEN (HERR_BASIC_BASE + 30) // Invalid face token
18+
#define HERR_INVALID_FACE_FEATURE (HERR_BASIC_BASE + 31) // Invalid face feature
19+
#define HERR_INVALID_FACE_LIST (HERR_BASIC_BASE + 32) // Invalid face feature list
20+
#define HERR_INVALID_BUFFER_SIZE (HERR_BASIC_BASE + 33) // Invalid copy token
21+
#define HERR_INVALID_IMAGE_STREAM_PARAM (HERR_BASIC_BASE + 34) // Invalid image param
22+
#define HERR_INVALID_SERIALIZATION_FAILED (HERR_BASIC_BASE + 35) // Invalid face serialization failed
23+
#define HERR_INVALID_DETECTION_INPUT (HERR_BASIC_BASE + 36) // Failed to modify detector input size
24+
#define HERR_INVALID_IMAGE_BITMAP_HANDLE (HERR_BASIC_BASE + 37) // Invalid image bitmap handle
25+
26+
#define HERR_SESS_BASE 0X500 // Session error types
27+
#define HERR_SESS_FUNCTION_UNUSABLE (HERR_SESS_BASE + 2) // Function not usable
28+
#define HERR_SESS_TRACKER_FAILURE (HERR_SESS_BASE + 3) // Tracker module not initialized
29+
#define HERR_SESS_INVALID_RESOURCE (HERR_SESS_BASE + 10) // Invalid static resource
30+
#define HERR_SESS_NUM_OF_MODELS_NOT_MATCH (HERR_SESS_BASE + 11) // Number of models does not match
31+
#define HERR_SESS_LANDMARK_NUM_NOT_MATCH (HERR_SESS_BASE + 20) // The number of input landmark points does not match
32+
#define HERR_SESS_LANDMARK_NOT_ENABLE (HERR_SESS_BASE + 21) // The number of input landmark points does not match
33+
#define HERR_SESS_KEY_POINT_NUM_NOT_MATCH (HERR_SESS_BASE + 22) // The number of input key points does not match
34+
35+
#define HERR_SESS_PIPELINE_FAILURE (HERR_SESS_BASE + 8) // Pipeline module not initialized
36+
37+
#define HERR_SESS_REC_EXTRACT_FAILURE (HERR_SESS_BASE + 15) // Face feature extraction not registered
38+
#define HERR_SESS_REC_DEL_FAILURE (HERR_SESS_BASE + 16) // Face feature deletion failed due to out of range index
39+
#define HERR_SESS_REC_UPDATE_FAILURE (HERR_SESS_BASE + 17) // Face feature update failed due to out of range index
40+
#define HERR_SESS_REC_ADD_FEAT_EMPTY (HERR_SESS_BASE + 18) // Feature vector for registration cannot be empty
41+
#define HERR_SESS_REC_FEAT_SIZE_ERR (HERR_SESS_BASE + 19) // Incorrect length of feature vector for registration
42+
#define HERR_SESS_REC_INVALID_INDEX (HERR_SESS_BASE + 20) // Invalid index number
43+
#define HERR_SESS_REC_CONTRAST_FEAT_ERR (HERR_SESS_BASE + 23) // Incorrect length of feature vector for comparison
44+
#define HERR_SESS_REC_BLOCK_FULL (HERR_SESS_BASE + 24) // Feature vector block full
45+
#define HERR_SESS_REC_BLOCK_DEL_FAILURE (HERR_SESS_BASE + 25) // Deletion failed
46+
#define HERR_SESS_REC_BLOCK_UPDATE_FAILURE (HERR_SESS_BASE + 26) // Update failed
47+
#define HERR_SESS_REC_ID_ALREADY_EXIST (HERR_SESS_BASE + 27) // ID already exists
48+
49+
#define HERR_SESS_FACE_DATA_ERROR (HERR_SESS_BASE + 30) // Face data parsing
50+
51+
#define HERR_SESS_FACE_REC_OPTION_ERROR (HERR_SESS_BASE + 40) // An optional parameter is incorrect
52+
53+
#define HERR_FT_HUB_DISABLE (HERR_SESS_BASE + 49) // FeatureHub is disabled
54+
#define HERR_FT_HUB_OPEN_ERROR (HERR_SESS_BASE + 50) // Database open error
55+
#define HERR_FT_HUB_NOT_OPENED (HERR_SESS_BASE + 51) // Database not opened
56+
#define HERR_FT_HUB_NO_RECORD_FOUND (HERR_SESS_BASE + 52) // No record found
57+
#define HERR_FT_HUB_CHECK_TABLE_ERROR (HERR_SESS_BASE + 53) // Data table check error
58+
#define HERR_FT_HUB_INSERT_FAILURE (HERR_SESS_BASE + 54) // Data insertion error
59+
#define HERR_FT_HUB_PREPARING_FAILURE (HERR_SESS_BASE + 55) // Data preparation error
60+
#define HERR_FT_HUB_EXECUTING_FAILURE (HERR_SESS_BASE + 56) // SQL execution error
61+
#define HERR_FT_HUB_NOT_VALID_FOLDER_PATH (HERR_SESS_BASE + 57) // Invalid folder path
62+
#define HERR_FT_HUB_ENABLE_REPETITION (HERR_SESS_BASE + 58) // Enable db function repeatedly
63+
#define HERR_FT_HUB_DISABLE_REPETITION (HERR_SESS_BASE + 59) // Disable db function repeatedly
64+
#define HERR_FT_HUB_NOT_FOUND_FEATURE (HERR_SESS_BASE + 60) // Get face feature error
65+
66+
#define HERR_ARCHIVE_LOAD_FAILURE (HERR_SESS_BASE + 80) // Archive load failure
67+
#define HERR_ARCHIVE_LOAD_MODEL_FAILURE (HERR_SESS_BASE + 81) // Model load failure
68+
#define HERR_ARCHIVE_FILE_FORMAT_ERROR (HERR_SESS_BASE + 82) // The archive format is incorrect
69+
#define HERR_ARCHIVE_REPETITION_LOAD (HERR_SESS_BASE + 83) // Do not reload the model
70+
#define HERR_ARCHIVE_NOT_LOAD (HERR_SESS_BASE + 84) // Model not loaded
71+
72+
#define HERR_DEVICE_BASE 0X900 // hardware error
73+
#define HERR_DEVICE_CUDA_NOT_SUPPORT (HERR_DEVICE_BASE + 1) // CUDA not supported
74+
#define HERR_DEVICE_CUDA_TENSORRT_NOT_SUPPORT (HERR_DEVICE_BASE + 2) // CUDA TensorRT not supported
75+
#define HERR_DEVICE_CUDA_UNKNOWN_ERROR (HERR_DEVICE_BASE + 20) // CUDA unknown error
76+
#define HERR_DEVICE_CUDA_DISABLE (HERR_DEVICE_BASE + 21) // CUDA support is disabled
77+
// [Anchor-End]
78+
79+
#endif // INSPIRE_FACE_HERROR_H

include/inspirecv/check.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef INSPIRECV_CHECK_H_
2+
#define INSPIRECV_CHECK_H_
3+
#include "logging.h"
4+
5+
#define INSPIRECV_RETURN_IF_ERROR(...) \
6+
do { \
7+
const okcv::Status _status = (__VA_ARGS__); \
8+
if (!_status.ok()) { \
9+
INSPIRECV_LOG(ERROR) << _status.message(); \
10+
return _status; \
11+
} \
12+
} while (0)
13+
14+
#define INSPIRECV_LOG_IF(severity, condition) \
15+
if (condition) \
16+
INSPIRECV_LOG(severity)
17+
18+
#define INSPIRECV_CHECK(condition) \
19+
INSPIRECV_LOG_IF(FATAL, !(condition)) << "Check failed: (" #condition ") "
20+
21+
#define INSPIRECV_CHECK_EQ(a, b) INSPIRECV_CHECK((a) == (b))
22+
#define INSPIRECV_CHECK_NE(a, b) INSPIRECV_CHECK((a) != (b))
23+
#define INSPIRECV_CHECK_LE(a, b) INSPIRECV_CHECK((a) <= (b))
24+
#define INSPIRECV_CHECK_LT(a, b) INSPIRECV_CHECK((a) < (b))
25+
#define INSPIRECV_CHECK_GE(a, b) INSPIRECV_CHECK((a) >= (b))
26+
#define INSPIRECV_CHECK_GT(a, b) INSPIRECV_CHECK((a) > (b))
27+
28+
#endif // INSPIRECV_CHECK_H_

include/inspirecv/core/color.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef INSPIRECV_CORE_COLOR_H
2+
#define INSPIRECV_CORE_COLOR_H
3+
4+
#include <vector>
5+
6+
namespace inspirecv {
7+
8+
namespace Color {
9+
10+
const std::vector<double> Red = {0.0, 0.0, 255.0};
11+
const std::vector<double> Green = {0.0, 255.0, 0.0};
12+
const std::vector<double> Blue = {255.0, 0.0, 0.0};
13+
const std::vector<double> Black = {0.0, 0.0, 0.0};
14+
const std::vector<double> White = {255.0, 255.0, 255.0};
15+
const std::vector<double> Yellow = {0.0, 255.0, 255.0};
16+
const std::vector<double> Magenta = {255.0, 0.0, 255.0};
17+
const std::vector<double> Cyan = {255.0, 255.0, 0.0};
18+
const std::vector<double> Gray = {128.0, 128.0, 128.0};
19+
const std::vector<double> Orange = {0.0, 128.0, 255.0};
20+
const std::vector<double> Purple = {128.0, 0.0, 128.0};
21+
const std::vector<double> Brown = {42.0, 42.0, 165.0};
22+
const std::vector<double> Pink = {147.0, 20.0, 255.0};
23+
24+
} // namespace Color
25+
26+
} // namespace inspirecv
27+
28+
#endif // INSPIRECV_CORE_COLOR_H

include/inspirecv/core/define.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef INSPIRECV_DEFINE_H
2+
#define INSPIRECV_DEFINE_H
3+
4+
#include <array>
5+
6+
#ifndef INSPIRECV_API
7+
#define INSPIRECV_API
8+
#endif
9+
10+
namespace inspirecv {
11+
12+
template <typename T, size_t N>
13+
using Vec = std::array<T, N>;
14+
15+
template <typename T>
16+
using Vec2 = Vec<T, 2>;
17+
template <typename T>
18+
using Vec3 = Vec<T, 3>;
19+
template <typename T>
20+
using Vec4 = Vec<T, 4>;
21+
22+
// Float vectors
23+
using Vec2f = Vec<float, 2>;
24+
using Vec3f = Vec<float, 3>;
25+
using Vec4f = Vec<float, 4>;
26+
27+
// Double vectors
28+
using Vec2d = Vec<double, 2>;
29+
using Vec3d = Vec<double, 3>;
30+
using Vec4d = Vec<double, 4>;
31+
32+
// Integer vectors
33+
using Vec2i = Vec<int, 2>;
34+
using Vec3i = Vec<int, 3>;
35+
using Vec4i = Vec<int, 4>;
36+
37+
} // namespace inspirecv
38+
39+
#endif // INSPIRECV_DEFINE_H

0 commit comments

Comments
 (0)