Skip to main content
Version: 3.24.1 (latest)

Converting RawSample to Context

Using detectors from Legacy API

You can convert RawSample (legacy API) to Context (processing block API) in C++, Python, Flutter, C#. This can be useful if you want to use the validated Capturer from the old API and some new processing blocks like Age Estimator, Quality Assessment Estimator or Liveness Estimator. To do this, call the toContext() method of the RawSample object.

pbio::Capturer::Ptr capturer = service->createCapturer("common_capturer_refa_fda_a.xml");

cv::Mat image = cv::imread(input_image_path);
auto ioData = service->createContext();

pbio::RawImage rawImage(image.cols, image.rows, pbio::RawImage::Format::FORMAT_BGR, image.data);

// Face Detection
std::vector<pbio::RawSample::Ptr> samples = capturer->capture(rawImage);

auto objects = ioData["objects"];
auto imageContext = ioData["image"];

pbio::context_utils::putImage(imageContext, rawImage);

for (const auto& sample : samples)
{
// convert RawSample to Context
objects.push_back(sample->toContext());
}

auto configContext = service->createContext();

configContext["unit_type"] = "AGE_ESTIMATOR";
pbio::ProcessingBlock processing_block = service->createProcessingBlock(configContext);

processing_block(ioData);

note

The toContext method can only be called for RawSample received from a capture of type *_fda.

Parameters of uld detectors

The min_size parameter from uld configuration files now corresponds to the precision_level parameter

  • 150 <= min_size - precision_level = 1
  • 50 < min_size < 150 - precision_level = 2
  • 50 <= min_size - precision_level = 3

Biometric face template compatibility

Method 12 versions of Legacy API now match the first versions of the corresponding modifications of the Face template extractor.