-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.cpp
More file actions
42 lines (34 loc) · 1.97 KB
/
Copy pathquickstart.cpp
File metadata and controls
42 lines (34 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "CelanturDetection.h"
#include "CelanturSDKInterface.h"
#include "CommonParameters.h"
#include "example_common.h"
#include <opencv2/opencv.hpp>
/**
The purpose of this example is to show the quickest way to anonymise an image on the CPU using
the ONNX inference engine, including how to inspect and adjust inference engine settings.
Some of the settings might be internal and therefore not documented.
*/
int main(int argc, char** argv) {
// Build the shared processor configuration for the CPU (ONNX) inference plugin
celantur::ProcessorParams params = example::make_processor_params(example::onnx_plugin);
std::cout << "Looking for license at " << example::license_file << std::endl;
// Start the processor with given parameters and license file
CelanturSDK::Processor processor(params, example::license_file);
// Get the available inference engine settings and their default values
celantur::InferenceEnginePluginSettings settings = processor.get_inference_settings(example::model_path);
std::cout << "Inference engine parameters:" << std::endl;
for (const std::pair<std::string, std::any>& pair : settings) {
std::cout << pair.first << std::endl;
}
// set the number of inference threads to 1 to limit inference engine to work with only one thread; value of 0 means that the engine will use all available threads
settings["n_intra_threads"] = 1;
settings["n_outer_threads"] = 1;
// set the optimisation level of the model to the highest (Already set by default)
settings["optimisation_level"] = celantur::OptimisationLevel::Full;
// Load the inference model. Should be provided by Celantur; the settings are provided to the load_inference_model function
std::cout << "load model from " << example::model_path << std::endl;
processor.load_inference_model(settings);
// Process the shared example image and save the result
example::process_image(processor, "quickstart.jpg");
return 0;
}