Main fuction is used to parse command line arguments.
67 {
68
69 {
70
71 std::unordered_map<std::string, std::string> args;
72
73
74 for (int i = 1; i < argc; ++i) {
75 std::string arg = argv[i];
76 if (arg[0] == '-') {
77 if (arg == "-h") {
79 return 0;
80 }
81
82 if (i + 1 < argc && argv[i + 1][0] != '-') {
83 args[arg] = argv[++i];
84 } else {
85 std::cerr << "Option " << arg << " requires a value." << std::endl;
86 return 1;
87 }
88 } else {
89 std::cerr << "Unknown option: " << arg << std::endl;
90 return 1;
91 }
92 }
93
94
95 if (args.count("-p"))
97 if (args.count("-d"))
99 if (args.count("-i"))
101 if (args.count("-t"))
103
104 utils::printFormatted("PARAMETERS");
105
106 std::cout <<
"Probe image: " <<
image_probe << std::endl;
107
108
110 std::cout << "Palm attributes solver: "
112 << std::endl;
113
114
116 }
117
118 utils::printToolkitInfo();
119
121
124 {
125 utils::printFormatted("LOADING solvers");
126
130 utils::checkError(error);
131 }
132
135 {
136
137 utils::printFormatted("PALM DETECTION");
139
141
142
143 error =
sfeImageDecode(image_data.data(), image_data.size(), &image);
144 utils::checkError(error);
146 }
149 {
150 size_t detection_count = 1;
151
153 &detected_palm, &detection_count);
154 utils::checkError(error);
155
156 if (detection_count == 0) {
157 std::cout << "No palm detected in the probe image." << std::endl;
158 return 0;
159 } else {
160 std::cout << "Found " << detection_count
161 << " palm(s) in the probe image. Using the palm with highest "
162 "confidence."
163 << std::endl;
164 }
165 }
167
170 {
171 utils::printFormatted("LANDMARKS");
172
173 error =
sfePalmLandmarks(detector_solver, image, &detected_palm, &landmarks);
174 utils::checkError(error);
175 }
177
181
185 utils::checkError(error);
186
188 utils::printFormatted("ATTRIBUTES");
191 &attributes);
192 utils::checkError(error);
194
196 std::cout <<
"Hand orientation " << attributes.
hand_orientation << std::endl;
197 std::cout <<
"Hand position " << attributes.
hand_position << std::endl;
198 std::cout <<
"Quality " << attributes.
quality << std::endl;
199 } else {
201 std::cout << "Palm attributes solver not specified, skipping attributes analysis." << std::endl;
202 }
203
204 utils::printFormatted("FINISHED");
205}
float detection_threshold
const auto SOLVER_PARAMETERS
std::optional< std::string > solver_palm_attributes
std::string solver_palm_detect
Solvers to use in example, the defaults are filled in by CMake.
void printPalmDetectionInfo(SFEDetection &detected_palm)
void sfeSolverFree(SFESolver solver)
Free memory associated with SFESolver.
void * SFESolver
Solver provides an abstract interface over inference models and engines.
void * SFEError
Error type used to hold optional error message.
void sfeImageFree(SFEImage image)
Free memory associated with SFEImage.
SFEError sfeSolverCreate(const char *solver_file, const SFESolverParameter *solver_parameters, size_t solver_parameters_count, SFESolver *out_solver)
Create new solver from solver file.
SFEError sfeImageDecode(const unsigned char *data, size_t data_len, SFEImage *out_image)
Decode SFEImage from raw image data of various formats. Eg. PNG, JPEG ..
SFEError sfeDetect(SFESolver solver, SFEImageView image, float threshold, SFEDetection *out_detections, size_t *in_out_detection_count)
Detect objects in the source image using unified detection API.
SFEError sfePalmLandmarks(SFESolver solver, SFEImageView image, const SFEDetection *detection, SFEPalmLandmarks *out_landmarks)
Calculate palm landmarks from given source image and palm detection.
SFEError sfePalmAttributes(SFESolver solver, SFEImageView image, const SFEPalmLandmarks *landmarks, SFEPalmAttributes *out_attributes)
Calculate palm image quality attributes from given source image and palm detection.
Core detection - tagged union containing all detection types.
Raw owned raster image representation, HWC|BGR order.
float quality
Range <0, 1>. The recommended threshold for further palm processing is 0.6.
Palm landmarks (keypoints, hand position, orientation, confidence)