SmartFace Embedded Toolkit  4.2.1
Loading...
Searching...
No Matches
example_person_detect.cpp File Reference
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sfe_toolkit/sfe_core.h>
#include <sfe_toolkit/sfe_person.h>
#include "utils.hpp"
#include "solvers.h"
#include "annotate.hpp"
#include "strings.hpp"

Go to the source code of this file.

Functions

int main ()
 

Variables

const auto SOLVER_PARAMETERS
 
std::string image_path = "assets/person/person_detect_fisheye.jpg"
 
std::string solver_detect = SOLVER_PERSON_DETECT
 

Function Documentation

◆ main()

int main ( )
Examples
example_face_demographic_attributes.cpp, example_face_identify.cpp, example_face_identify_entity.cpp, example_face_liveness.cpp, example_face_track.cpp, example_iris_identify.cpp, example_palm_attributes.cpp, example_palm_identify.cpp, and example_palm_liveness.cpp.

Definition at line 22 of file example_person_detect.cpp.

22 {
23 SFEError error;
24
25 SFEImage image{};
26 DEFER(sfeImageFree(image));
27 { // STAGE 1: Load Image
28 auto encoded_image = utils::readFile(image_path);
29 error = sfeImageDecode(encoded_image.data(), encoded_image.size(), &image);
30 utils::checkError(error);
31
32 std::cout << "Image size: " << image.width << "x" << image.height << std::endl;
33 }
34
35 std::vector<SFEDetection> detections(10);
36 { // STAGE 2: Run person detection
37 // Initialize detection solver
38 SFESolver detection_solver{};
39 DEFER(sfeSolverFree(detection_solver));
40 error = sfeSolverCreate(solver_detect.c_str(), SOLVER_PARAMETERS.data(), SOLVER_PARAMETERS.size(), &detection_solver);
41 utils::checkError(error);
42
43 // Run detection for up to 10 persons
44 size_t detection_count = detections.size();
45 float detection_threshold = 0.3;
46 error = sfeDetect(detection_solver,
47 image,
49 detections.data(), &detection_count);
50 utils::checkError(error);
51 detections.resize(detection_count);
52
53 std::cout << "Detected " << detection_count << " persons" << std::endl;
54 }
55}
float detection_threshold
std::string solver_detect
const auto SOLVER_PARAMETERS
std::string image_path
void sfeSolverFree(SFESolver solver)
Free memory associated with SFESolver.
void * SFESolver
Solver provides an abstract interface over inference models and engines.
Definition sfe_core.h:102
void * SFEError
Error type used to hold optional error message.
Definition sfe_core.h:97
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.
Raw owned raster image representation, HWC|BGR order.
Definition sfe_core.h:70

Variable Documentation

◆ image_path

std::string image_path = "assets/person/person_detect_fisheye.jpg"

◆ solver_detect

std::string solver_detect = SOLVER_PERSON_DETECT

Definition at line 20 of file example_person_detect.cpp.

◆ SOLVER_PARAMETERS

const auto SOLVER_PARAMETERS
Initial value:
= std::vector<SFESolverParameter>{
SFESolverParameter { "intra_threads", "4" },
}
Solver parameter used to configure solvers.
Definition sfe_core.h:105

Definition at line 15 of file example_person_detect.cpp.