9 #ifndef __PBIO_API__PBIO__FACEREC_SERVICE_H_
10 #define __PBIO_API__PBIO__FACEREC_SERVICE_H_
23 #include "stl_wraps_impls/WrapIStreamImpl.h"
24 #include "stl_wraps_impls/WrapOStreamImpl.h"
30 #include "ComplexObject.h"
33 #include "ActiveLiveness.h"
38 #include "ExceptionCheck.h"
42 #include "RawSample.h"
43 #include "Recognizer.h"
46 #include "VideoWorker.h"
47 #include "StructStorage.h"
49 #include "ProcessingUnit.h"
51 #ifndef WITHOUT_PROCESSING_BLOCK
53 #include "ProcessingBlock.h"
73 typedef LightSmartPtr<FacerecService>::tPtr
Ptr;
200 const std::string dll_path,
201 std::string facerec_conf_dir,
202 const std::string license_dir = std::string());
238 const std::string dll_path,
239 std::string facerec_conf_dir,
247 const std::string dll_path,
248 std::string facerec_conf_dir,
249 const std::string license,
250 const bool is_license_dir);
475 const char* ini_file,
476 const bool processing =
true,
477 const bool matching =
true,
478 const bool processing_less_memory_consumption =
false)
const;
481 #ifndef WITHOUT_PROCESSING_BLOCK
483 const std::vector<pbio::ContextTemplate::Ptr>& templates,
484 const std::vector<std::string>& uuids,
541 const bool processing =
true,
542 const bool matching =
true,
543 const bool processing_less_memory_consumption =
false)
const;
623 const char* recognizer_ini_file,
624 const int streams_count,
625 const int processing_threads_count,
626 const int matching_threads_count)
const;
673 const int streams_count,
674 const int processing_threads_count,
675 const int matching_threads_count)
const;
801 pbio::stl_wraps::WrapIStream &binary_stream,
803 const double space_translation_x = 0,
804 const double space_translation_y = 0,
805 const double space_scale = 1)
const;
811 std::istream &binary_stream,
813 const double space_translation_x = 0,
814 const double space_translation_y = 0,
815 const double space_scale = 1)
const;
871 pbio::stl_wraps::WrapIStream &binary_stream,
872 const unsigned char *image_data,
874 const double space_translation_x = 0,
875 const double space_translation_y = 0,
876 const double space_scale = 1)
const;
883 std::istream &binary_stream,
884 const unsigned char *image_data,
886 const double space_translation_x = 0,
887 const double space_translation_y = 0,
888 const double space_scale = 1)
const;
935 const std::string ini_file)
const;
989 const std::string ini_file)
const;
1043 const std::string ini_file)
const;
1096 const std::string ini_file)
const;
1100 ProcessingUnit::Ptr createProcessingUnit(
1101 const int block_type,
1102 const char* serializedConfig)
const;
1104 #ifndef WITHOUT_PROCESSING_BLOCK
1113 Context createContext()
const;
1127 Context createContextFromEncodedImage(
const uint8_t* data, uint64_t dataSize)
const;
1139 Context createContextFromEncodedImage(
const std::vector<uint8_t>& data)
const;
1151 Context createContextFromEncodedImage(
const std::string& data)
const;
1153 Context createContextFromEncodedImage(
const std::vector<char>& data)
const;
1173 Context createContextFromFrame(uint8_t* data, int32_t width, int32_t height, Context::Format format = Context::Format::FORMAT_BGR, int32_t baseAngle = 0)
const;
1175 Context createContextFromJsonFile(
const char* path);
1187 Context createContextFromJsonFile(std::string path);
1340 jobject android_media_image);
1341 #endif // ifdef ANDROID
1386 const bool downscale_x2,
1387 void*
const result_buffer);
1390 void convertYUV2RGB(
1392 const bool downscale_x2,
1393 const int base_angle,
1394 void*
const result_buffer);
1397 void convertBGRA88882RGB(
1399 const bool downscale_x2,
1400 const int base_angle,
1401 void*
const result_buffer);
1406 const std::string _facerec_conf_dir;
1411 const DHPtr &dll_handle,
1412 const std::string &facerec_conf_dir,
1433 const std::string dll_path,
1434 std::string facerec_conf_dir,
1435 const std::string license_dir)
1437 return createService(NULL, dll_path, facerec_conf_dir, license_dir,
true);
1443 const std::string dll_path,
1444 std::string facerec_conf_dir,
1454 const std::string dll_path,
1455 std::string facerec_conf_dir,
1456 const std::string license,
1457 const bool is_license_dir)
1460 #ifdef __STATIC_LIBFACEREC_BUILD__
1463 const DHPtr dll_handle( DHPtr::make() );
1465 const DHPtr dll_handle( DHPtr::make(dll_path.c_str()) );
1468 if(facerec_conf_dir.empty())
1470 facerec_conf_dir =
"./";
1472 else if(facerec_conf_dir[facerec_conf_dir.length() - 1] !=
'/')
1474 facerec_conf_dir +=
'/';
1477 void* exception = NULL;
1483 the_impl = dll_handle->FacerecService_constructor3(
1485 facerec_conf_dir.c_str(),
1493 the_impl = dll_handle->FacerecService_constructor5(
1495 facerec_conf_dir.c_str(),
1501 checkException(exception, *dll_handle);
1503 return FacerecService::Ptr::make(
1511 FacerecService::FacerecService(
1512 const DHPtr &dll_handle,
1513 const std::string &facerec_conf_dir,
1515 ComplexObject(dll_handle, impl),
1516 _facerec_conf_dir(facerec_conf_dir)
1520 if (LIBFACEREC_VERSION != lib_version)
1521 std::cerr <<
"WARNING: The version in the header does not match the version in the library. Header version: "
1522 << LIBFACEREC_VERSION <<
", library version: " << lib_version << std::endl;
1529 std::ostringstream version_stream;
1530 pbio::stl_wraps::WrapOStreamImpl version_stream_wrap(version_stream);
1532 void* exception = NULL;
1534 _dll_handle->get_version(
1535 &version_stream_wrap,
1536 pbio::stl_wraps::WrapOStream::write_func,
1539 checkException(exception, *_dll_handle);
1541 return version_stream.str();
1548 void* exception = NULL;
1550 _dll_handle->FacerecService_forceOnlineLicenseUpdate(
1554 checkException(exception, *_dll_handle);
1561 const std::string file_path = _facerec_conf_dir + config.config_filepath;
1563 std::vector<char const*> overridden_keys;
1564 std::vector<double> overridden_values;
1566 config.prepare(overridden_keys, overridden_values);
1568 void* exception = NULL;
1570 pbio::facerec::CapturerImpl*
const capturer_impl =
1571 _dll_handle->FacerecService_createCapturerE(
1574 overridden_keys.size(),
1575 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
1576 overridden_values.empty() ? NULL : &(overridden_values[0]),
1579 checkException(exception, *_dll_handle);
1581 return Capturer::Ptr::make(_dll_handle, capturer_impl);
1587 const std::string file_path = _facerec_conf_dir + ini_file;
1589 void* exception = NULL;
1591 pbio::facerec::AgeGenderEstimatorImpl*
const the_impl =
1592 _dll_handle->FacerecService_createAgeGenderEstimator(
1597 checkException(exception, *_dll_handle);
1599 return AgeGenderEstimator::Ptr::make(_dll_handle, the_impl);
1606 const std::string file_path = _facerec_conf_dir + ini_file;
1608 void* exception = NULL;
1610 pbio::facerec::QualityEstimatorImpl*
const the_impl =
1611 _dll_handle->FacerecService_createQualityEstimator(
1616 checkException(exception, *_dll_handle);
1618 return QualityEstimator::Ptr::make(_dll_handle, the_impl);
1625 const std::string file_path = _facerec_conf_dir + ini_file;
1627 void* exception = NULL;
1629 pbio::facerec::FaceQualityEstimatorImpl*
const the_impl =
1630 _dll_handle->FacerecService_createFaceQualityEstimator(
1635 checkException(exception, *_dll_handle);
1637 return FaceQualityEstimator::Ptr::make(_dll_handle, the_impl);
1643 void* exception = NULL;
1645 pbio::facerec::LivenessEstimatorImpl*
const the_impl =
1646 _dll_handle->FacerecService_createLivenessEstimator(
1650 checkException(exception, *_dll_handle);
1652 return LivenessEstimator::Ptr::make(_dll_handle, the_impl);
1658 const std::string ini_file)
const
1660 const std::string file_path = _facerec_conf_dir + ini_file;
1662 void* exception = NULL;
1664 pbio::facerec::EmotionsEstimatorImpl*
const the_impl =
1665 _dll_handle->FacerecService_createEmotionsEstimator(
1670 checkException(exception, *_dll_handle);
1672 return EmotionsEstimator::Ptr::make(_dll_handle, the_impl);
1678 const char* ini_file,
1679 const bool processing,
1680 const bool matching,
1681 const bool processing_less_memory_consumption)
const
1683 const std::string file_path = _facerec_conf_dir + ini_file;
1685 void* exception = NULL;
1687 pbio::facerec::RecognizerImpl*
const recognizer_impl =
1688 _dll_handle->FacerecService_createRecognizer2(
1696 (int) processing_less_memory_consumption,
1699 checkException(exception, *_dll_handle);
1701 return Recognizer::Ptr::make(_dll_handle, recognizer_impl);
1704 #ifndef WITHOUT_PROCESSING_BLOCK
1706 const std::vector<pbio::ContextTemplate::Ptr>& templates,
1707 const std::vector<std::string>& uuids,
1711 void* exception =
nullptr;
1713 std::vector<const void*> tempTemplates;
1714 std::vector<const char*> tempUuids;
1716 tempTemplates.reserve(templates.size());
1717 tempUuids.reserve(uuids.size());
1721 templates.begin(), templates.end(), std::back_inserter(tempTemplates),
1724 std::transform(uuids.begin(), uuids.end(), std::back_inserter(tempUuids), [](
const std::string& uuid) {
return uuid.data(); });
1726 void* indexImplementation = _dll_handle->FacerecService_createDynamicTemplateIndex_1
1729 tempTemplates.data(),
1736 checkException(exception, *_dll_handle);
1738 return DynamicTemplateIndex::Ptr::make(_dll_handle, indexImplementation);
1743 void* exception =
nullptr;
1745 void* indexImplementation = _dll_handle->FacerecService_createDynamicTemplateIndex_2(_impl, config.getHandle(), &exception);
1747 checkException(exception, *_dll_handle);
1749 return DynamicTemplateIndex::Ptr::make(_dll_handle, indexImplementation);
1754 pbio::stl_wraps::WrapIStreamImpl streamWrap(stream);
1755 return loadContextTemplate(streamWrap);
1758 inline ContextTemplate::Ptr FacerecService::loadContextTemplate(pbio::stl_wraps::WrapIStream& stream)
const
1760 void* exception =
nullptr;
1761 void* templateImplementation = _dll_handle->ContextTemplate_loadTemplate(&stream, pbio::stl_wraps::WrapIStream::read_func, &exception);
1763 checkException(exception, *_dll_handle);
1765 return ContextTemplate::Ptr::make(_dll_handle, templateImplementation);
1770 void* exception =
nullptr;
1771 void* templateImplementation = _dll_handle->ContextTemplate_convert(templateContext.handle_, &exception);
1773 checkException(exception, *_dll_handle);
1775 return ContextTemplate::Ptr::make(_dll_handle, templateImplementation);
1782 const bool processing,
1783 const bool matching,
1784 const bool processing_less_memory_consumption)
const
1786 const std::string file_path = _facerec_conf_dir + recognizer_config.config_filepath;
1788 std::vector<char const*> overridden_keys;
1789 std::vector<double> overridden_values;
1791 recognizer_config.prepare(overridden_keys, overridden_values);
1793 void* exception = NULL;
1795 pbio::facerec::RecognizerImpl*
const recognizer_impl =
1796 _dll_handle->FacerecService_createRecognizer2(
1799 overridden_keys.size(),
1800 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
1801 overridden_values.empty() ? NULL : &(overridden_values[0]),
1804 (
int) processing_less_memory_consumption,
1807 checkException(exception, *_dll_handle);
1809 return Recognizer::Ptr::make(_dll_handle, recognizer_impl);
1817 const char* recognizer_ini_file,
1818 const int streams_count,
1819 const int processing_threads_count,
1820 const int matching_threads_count)
const
1824 .video_worker_config(video_worker_ini_file)
1825 .recognizer_ini_file(recognizer_ini_file)
1826 .streams_count(streams_count)
1827 .processing_threads_count(processing_threads_count)
1828 .matching_threads_count(matching_threads_count)
1836 const int streams_count,
1837 const int processing_threads_count,
1838 const int matching_threads_count)
const
1842 .video_worker_config(video_worker_ini_file)
1843 .recognizer_config(recognizer_config)
1844 .streams_count(streams_count)
1845 .processing_threads_count(processing_threads_count)
1846 .matching_threads_count(matching_threads_count)
1854 std::vector<char const*> vw_overridden_keys;
1855 std::vector<double> vw_overridden_values;
1857 params._video_worker_config.prepare(vw_overridden_keys, vw_overridden_values);
1858 std::vector<std::string> extra_over_params;
1860 if(!params._active_liveness_checks_order.empty()){
1861 bool is_unique =
true;
1862 for (
auto it = params._active_liveness_checks_order.begin(); it != params._active_liveness_checks_order.end(); ++it)
1863 if (std::find(it + 1, params._active_liveness_checks_order.end(), *it) != params._active_liveness_checks_order.end()) {
1869 "Error 0x3302330e: Set a unique order of `active_liveness_checks_order` for Active Liveness.");
1870 for (
size_t i = 0; i < params._active_liveness_checks_order.size(); i++){
1872 std::string check_str = ActiveLiveness::CheckTypeToString(check);
1873 extra_over_params.push_back(
"active_liveness.check_" + check_str);
1874 vw_overridden_keys.push_back(extra_over_params.back().c_str());
1875 vw_overridden_values.push_back(-(
double)(i+1));
1880 if (!params._recognizer_ini_file.empty() && !params._recognizer_config.config_filepath.empty())
1881 throw pbio::Error(0xb3fe4d07,
"Error: 0xed877a99 You must use either recognizer_config or recognizer_ini_file.");
1884 params._recognizer_ini_file.empty() ?
1885 params._recognizer_config :
1888 std::vector<char const*> rec_overridden_keys;
1889 std::vector<double> rec_overridden_values;
1891 recognizer_config.prepare(rec_overridden_keys, rec_overridden_values);
1893 void* exception = NULL;
1895 pbio::facerec::VideoWorkerImpl*
const vw_impl =
1896 _dll_handle->FacerecService_createVideoWorker_sti_age_gender_emotions(
1899 VideoWorker::STrackingCallback,
1900 VideoWorker::STemplateCreatedCallback,
1901 VideoWorker::SMatchFoundCallback,
1902 VideoWorker::STrackingLostCallback,
1903 VideoWorker::SStiPersonOutdatedCallback,
1905 (_facerec_conf_dir + params._video_worker_config.config_filepath).c_str(),
1906 vw_overridden_keys.size(),
1907 vw_overridden_keys.empty() ? NULL : &(vw_overridden_keys[0]),
1908 vw_overridden_values.empty() ? NULL : &(vw_overridden_values[0]),
1910 (_facerec_conf_dir + recognizer_config.config_filepath).c_str(),
1911 rec_overridden_keys.size(),
1912 rec_overridden_keys.empty() ? NULL : &(rec_overridden_keys[0]),
1913 rec_overridden_values.empty() ? NULL : &(rec_overridden_values[0]),
1915 params._streams_count,
1916 params._processing_threads_count,
1917 params._matching_threads_count,
1918 params._short_time_identification_enabled,
1919 params._short_time_identification_distance_threshold,
1920 params._short_time_identification_outdate_time_seconds,
1921 params._age_gender_estimation_threads_count,
1922 params._emotions_estimation_threads_count,
1925 checkException(exception, *_dll_handle);
1927 return VideoWorker::Ptr::make(_dll_handle, vw_impl);
1934 pbio::stl_wraps::WrapIStreamImpl binary_stream_wrap(binary_stream);
1942 void* exception = NULL;
1944 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
1945 _dll_handle->FacerecService_loadRawSample(
1948 pbio::stl_wraps::WrapIStream::read_func,
1951 checkException(exception, *_dll_handle);
1953 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
1958 pbio::stl_wraps::WrapIStream &binary_stream,
1960 const double space_translation_x,
1961 const double space_translation_y,
1962 const double space_scale)
const
1964 void* exception = NULL;
1966 const RawImage::CapiData cdata = image.makeCapiData();
1968 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
1969 _dll_handle->FacerecService_loadRawSampleWithoutImage_raw_image(
1972 pbio::stl_wraps::WrapIStream::read_func,
1979 cdata.crop_info_offset_x,
1980 cdata.crop_info_offset_y,
1981 cdata.crop_info_data_image_width,
1982 cdata.crop_info_data_image_height,
1984 space_translation_x,
1985 space_translation_y,
1990 checkException(exception, *_dll_handle);
1992 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
1997 std::istream &binary_stream,
1999 const double space_translation_x,
2000 const double space_translation_y,
2001 const double space_scale)
const
2003 pbio::stl_wraps::WrapIStreamImpl binary_stream_wrap(binary_stream);
2008 space_translation_x,
2009 space_translation_y,
2015 pbio::stl_wraps::WrapIStream &binary_stream,
2016 const unsigned char *image_data,
2017 int image_data_size,
2018 const double space_translation_x,
2019 const double space_translation_y,
2020 const double space_scale)
const
2022 void* exception = NULL;
2024 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
2025 _dll_handle->FacerecService_loadRawSampleWithoutImage_encoded_image(
2028 pbio::stl_wraps::WrapIStream::read_func,
2033 space_translation_x,
2034 space_translation_y,
2039 checkException(exception, *_dll_handle);
2041 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
2046 std::istream &binary_stream,
2047 const unsigned char *image_data,
2048 int image_data_size,
2049 const double space_translation_x,
2050 const double space_translation_y,
2051 const double space_scale)
const
2053 pbio::stl_wraps::WrapIStreamImpl binary_stream_wrap(binary_stream);
2060 space_translation_x,
2061 space_translation_y,
2069 void* exception = NULL;
2071 pbio::facerec::CameraCalibratorImpl*
const calibrator_impl =
2072 _dll_handle->FacerecService_createCameraCalibrator(
2076 checkException(exception, *_dll_handle);
2078 return CameraCalibrator::Ptr::make(_dll_handle, calibrator_impl);
2085 const std::string ini_file)
const
2087 const std::string file_path = _facerec_conf_dir + ini_file;
2089 void* exception = NULL;
2091 pbio::facerec::DepthLivenessEstimatorImpl*
const the_impl =
2092 _dll_handle->FacerecService_createDepthLivenessEstimatorE(
2100 checkException(exception, *_dll_handle);
2102 return DepthLivenessEstimator::Ptr::make(_dll_handle, the_impl);
2110 const std::string file_path = _facerec_conf_dir + config.config_filepath;
2112 std::vector<char const*> overridden_keys;
2113 std::vector<double> overridden_values;
2115 config.prepare(overridden_keys, overridden_values);
2117 void* exception = NULL;
2119 pbio::facerec::DepthLivenessEstimatorImpl*
const the_impl =
2120 _dll_handle->FacerecService_createDepthLivenessEstimatorE(
2123 overridden_keys.size(),
2124 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
2125 overridden_values.empty() ? NULL : &(overridden_values[0]),
2128 checkException(exception, *_dll_handle);
2130 return DepthLivenessEstimator::Ptr::make(_dll_handle, the_impl);
2135 const std::string ini_file)
const
2137 const std::string file_path = _facerec_conf_dir + ini_file;
2139 void* exception = NULL;
2141 pbio::facerec::IRLivenessEstimatorImpl*
const the_impl =
2142 _dll_handle->FacerecService_createIRLivenessEstimatorE(
2150 checkException(exception, *_dll_handle);
2152 return IRLivenessEstimator::Ptr::make(_dll_handle, the_impl);
2159 const std::string file_path = _facerec_conf_dir + config.config_filepath;
2161 std::vector<char const*> overridden_keys;
2162 std::vector<double> overridden_values;
2164 config.prepare(overridden_keys, overridden_values);
2166 void* exception = NULL;
2168 pbio::facerec::IRLivenessEstimatorImpl*
const the_impl =
2169 _dll_handle->FacerecService_createIRLivenessEstimatorE(
2172 overridden_keys.size(),
2173 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
2174 overridden_values.empty() ? NULL : &(overridden_values[0]),
2177 checkException(exception, *_dll_handle);
2179 return IRLivenessEstimator::Ptr::make(_dll_handle, the_impl);
2184 const std::string ini_file)
const
2186 const std::string file_path = _facerec_conf_dir + ini_file;
2188 void* exception = NULL;
2190 pbio::facerec::Liveness2DEstimatorImpl*
const the_impl =
2191 _dll_handle->FacerecService_createLiveness2DEstimatorE(
2199 checkException(exception, *_dll_handle);
2201 return Liveness2DEstimator::Ptr::make(_dll_handle, the_impl);
2208 const std::string file_path = _facerec_conf_dir + config.config_filepath;
2210 std::vector<char const*> overridden_keys;
2211 std::vector<double> overridden_values;
2213 config.prepare(overridden_keys, overridden_values);
2215 void* exception = NULL;
2217 pbio::facerec::Liveness2DEstimatorImpl*
const the_impl =
2218 _dll_handle->FacerecService_createLiveness2DEstimatorE(
2221 overridden_keys.size(),
2222 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
2223 overridden_values.empty() ? NULL : &(overridden_values[0]),
2226 checkException(exception, *_dll_handle);
2228 return Liveness2DEstimator::Ptr::make(_dll_handle, the_impl);
2233 const std::string ini_file)
const
2235 const std::string file_path = _facerec_conf_dir + ini_file;
2237 void* exception = NULL;
2239 pbio::facerec::FaceAttributesEstimatorImpl*
const the_impl =
2240 _dll_handle->FacerecService_createFaceAttributesEstimator(
2248 checkException(exception, *_dll_handle);
2250 return FaceAttributesEstimator::Ptr::make(_dll_handle, the_impl);
2256 ProcessingUnit::Ptr FacerecService::createProcessingUnit(
2257 const int block_type,
2258 const char* serializedConfig)
const
2260 return ProcessingUnit::Ptr::make(_dll_handle, block_type, serializedConfig);
2263 #ifndef WITHOUT_PROCESSING_BLOCK
2264 inline Context FacerecService::createContext()
const
2269 inline Context FacerecService::createContextFromEncodedImage(
const uint8_t* data, uint64_t dataSize)
const
2271 return Context(_dll_handle, data, dataSize);
2274 inline Context FacerecService::createContextFromEncodedImage(
const std::vector<uint8_t>& data)
const
2276 return Context(_dll_handle, data.data(), data.size());
2279 inline Context FacerecService::createContextFromEncodedImage(
const std::string& data)
const
2281 return Context(_dll_handle, reinterpret_cast<const uint8_t*>(data.data()), data.size());
2284 inline Context FacerecService::createContextFromEncodedImage(
const std::vector<char>& data)
const
2286 return Context(_dll_handle, reinterpret_cast<const uint8_t*>(data.data()), data.size());
2289 inline Context FacerecService::createContextFromFrame(uint8_t* data, int32_t width, int32_t height, Context::Format format, int32_t baseAngle)
const
2291 return Context(_dll_handle, data, width, height, format, baseAngle);
2294 inline Context FacerecService::createContextFromJsonFile(
const char* path)
2296 return Context(_dll_handle, path);
2299 inline Context FacerecService::createContextFromJsonFile(std::string path)
2301 return Context(_dll_handle, path.c_str());
2315 void* exception = NULL;
2317 void* struct_storage_impl = _dll_handle->FacerecService_getLicenseState(_impl, &exception);
2319 checkException(exception, *_dll_handle);
2321 const StructStorage struct_storage(_dll_handle, struct_storage_impl);
2325 result.
online = struct_storage.get_int64(StructStorageFields::license_state_online_t);
2327 result.
android_app_id = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_android_app_id_t);
2328 result.
android_serial = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_android_serial_t);
2329 result.
ios_app_id = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_ios_app_id_t);
2330 result.
hardware_reg = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_hardware_reg_t);
2332 result.
counters.resize( struct_storage.get_int64(
2333 StructStorageFields::license_state_licenses_count_t) );
2335 for(
size_t i = 0; i < result.
counters.size(); ++i)
2337 result.
counters[i].name = (
char const*) struct_storage.get_pointer(
2338 (i << 16) |
size_t(StructStorageFields::license_state_licenses_names_int16_t) );
2340 result.
counters[i].max_value = struct_storage.get_int64(
2341 (i << 16) |
size_t(StructStorageFields::license_state_licenses_total_counts_int16_t) );
2343 result.
counters[i].value = struct_storage.get_int64(
2344 (i << 16) |
size_t(StructStorageFields::license_state_licenses_in_use_counts_int16_t) );
2354 void* exception = NULL;
2356 _dll_handle->FacerecService_toggleAlgorithmsCacheKepp(1, &exception);
2358 checkException(exception, *_dll_handle);
2364 void* exception = NULL;
2366 _dll_handle->FacerecService_toggleAlgorithmsCacheKepp(0, &exception);
2368 checkException(exception, *_dll_handle);
2379 void* exception = NULL;
2383 void* imagetptr_ptr;
2385 void*
const the_impl = _dll_handle->InternalImageBuffer_constructor(
2394 checkException(exception, *_dll_handle);
2396 return InternalImageBuffer::Ptr::make(
2399 (
unsigned char*) data_ptr,
2412 jobject android_media_image)
2414 void* exception = NULL;
2421 void* imagetptr_ptr;
2423 void*
const the_impl = _dll_handle->InternalImageBuffer_constructor_from_android_image(
2425 android_media_image,
2434 checkException(exception, *_dll_handle);
2436 return InternalImageBuffer::Ptr::make(
2439 (
unsigned char*) data_ptr,
2451 const bool downscale_x2,
2452 void*
const result_buffer)
2454 void* exception = NULL;
2456 const RawImage::CapiData cdata = image.makeCapiData();
2458 _dll_handle->RawImage_convertYUV2ARGB(
2464 cdata.crop_info_offset_x,
2465 cdata.crop_info_offset_y,
2466 cdata.crop_info_data_image_width,
2467 cdata.crop_info_data_image_height,
2472 checkException(exception, *_dll_handle);
2476 void FacerecService::convertYUV2RGB(
2478 const bool downscale_x2,
2479 const int base_angle,
2480 void*
const result_buffer)
2482 void* exception = NULL;
2484 const RawImage::CapiData cdata = image.makeCapiData();
2486 _dll_handle->RawImage_convertYUV2RGB(
2492 cdata.crop_info_offset_x,
2493 cdata.crop_info_offset_y,
2494 cdata.crop_info_data_image_width,
2495 cdata.crop_info_data_image_height,
2501 checkException(exception, *_dll_handle);
2505 void FacerecService::convertBGRA88882RGB(
2507 const bool downscale_x2,
2508 const int base_angle,
2509 void*
const result_buffer)
2511 void* exception = NULL;
2513 const RawImage::CapiData cdata = image.makeCapiData();
2515 _dll_handle->RawImage_convertYUV2RGB(
2521 cdata.crop_info_offset_x,
2522 cdata.crop_info_offset_y,
2523 cdata.crop_info_data_image_width,
2524 cdata.crop_info_data_image_height,
2530 checkException(exception, *_dll_handle);
2539 #endif // __PBIO_API__PBIO__FACEREC_SERVICE_H_
VideoWorker::Ptr createVideoWorker(const pbio::VideoWorker::Params params) const
Creates a VideoWorker object. Thread-safe. When VideoWorker is created with matching_thread=0 and pr...
Definition: FacerecService.h:1851
Interface object used to work with estimators from Processing Block API.
Definition: ProcessingBlock.h:29
std::string android_serial
Serial number of the Android device. Only available on Android (tag <android_serial>).
Definition: FacerecService.h:141
Interface object used to work with estimators from Processing Block API.
Definition: ProcessingBlock.h:16
Struct that provides raw image data and optional cropping information.
Definition: RawImage.h:28
static FacerecService::Ptr createService(const std::string dll_path, std::string facerec_conf_dir, const std::string license_dir=std::string())
Initializes the facerec lib (can be called only once).
Definition: FacerecService.h:1432
Interface object for creating other interface objects.
Definition: FacerecService.h:64
QualityEstimator - Interface object used to estimate sample quality.
FaceAttributesEstimator::Ptr createFaceAttributesEstimator(const std::string ini_file) const
Creates an FaceAttributesEstimator object. Thread-safe.
Definition: FacerecService.h:2232
LightSmartPtr< InternalImageBuffer >::tPtr Ptr
Alias for the type of a smart pointer to InternalImageBuffer.
Definition: InternalImageBuffer.h:34
CameraCalibrator - Interface object for camera calibration and correction of image distortion...
LightSmartPtr< EmotionsEstimator >::tPtr Ptr
Alias for the type of a smart pointer to EmotionsEstimator.
Definition: EmotionsEstimator.h:50
int64_t max_value
Maximum counter value (equals to the tag value).
Definition: FacerecService.h:115
State of the counter assigned to a specified license element.
Definition: FacerecService.h:103
std::string android_app_id
Android application ID. Available only on Android (tag <android_app_id>).
Definition: FacerecService.h:135
LightSmartPtr< IRLivenessEstimator >::tPtr Ptr
Alias for the type of a smart pointer to IRLivenessEstimator.
Definition: IRLivenessEstimator.h:43
LightSmartPtr< FaceQualityEstimator >::tPtr Ptr
Alias for the type of a smart pointer to FaceQualityEstimator.
Definition: FaceQualityEstimator.h:50
LightSmartPtr< VideoWorker >::tPtr Ptr
Alias for the type of a smart pointer to VideoWorker.
Definition: VideoWorker.h:72
Liveness2DEstimator is an interface object used to estimate face liveness in order to prevent spoofin...
IRLivenessEstimator::Ptr createIRLivenessEstimator(const std::string ini_file) const
Creates an IRLivenessEstimator object. Thread-safe.
Definition: FacerecService.h:2134
LightSmartPtr< CameraCalibrator >::tPtr Ptr
Alias for the type of a smart pointer to CameraCalibrator.
Definition: CameraCalibrator.h:48
LightSmartPtr< Capturer >::tPtr Ptr
Alias for the type of a smart pointer to Capturer.
Definition: Capturer.h:45
Recognizer::Ptr createRecognizer(const char *ini_file, const bool processing=true, const bool matching=true, const bool processing_less_memory_consumption=false) const
Creates a Recognizer object. Thread-safe.
Definition: FacerecService.h:1677
void convertYUV2ARGB(const RawImage image, const bool downscale_x2, void *const result_buffer)
Convert input image to android.graphics.Bitmap.Config.ARGB_8888 format. Input must be in YUV_NV21 of ...
Definition: FacerecService.h:2449
CameraCalibrator::Ptr createCameraCalibrator() const
Creates a CameraCalibrator object. Thread-safe.
Definition: FacerecService.h:2067
Parameters of the VideoWorker constructor.
Definition: VideoWorker.h:89
Capturer::Ptr createCapturer(const pbio::FacerecService::Config config) const
Creates a Capturer object. Type and features depend on the content of the configuration file...
Definition: FacerecService.h:1558
DepthLivenessEstimator - Interface object used to estimate face liveness in order to prevent spoofing...
EmotionsEstimator - Interface object for estimation of emotions.
A class used to override the configuration parameters at runtime.
Definition: Config.h:19
LightSmartPtr< RawSample >::tPtr Ptr
Alias for the type of a smart pointer to RawSample.
Definition: RawSample.h:58
LightSmartPtr< QualityEstimator >::tPtr Ptr
Alias for the type of a smart pointer to QualityEstimator.
Definition: QualityEstimator.h:50
Error - the class of exceptions thrown when errors occur.
LivenessEstimator - Interface object used to estimate face liveness to prevent spoofing attacks...
AgeGenderEstimator - interface object for age and gender estimation.
void forceOnlineLicenseUpdate() const
Force online license update.
Definition: FacerecService.h:1546
AgeGenderEstimator::Ptr createAgeGenderEstimator(const std::string ini_file) const
Creates a AgeGenderEstimator object. Thread-safe.
Definition: FacerecService.h:1585
void freeAlgorithmsCache() const
Disable keeping algorithms data in memory. Thread-safe.
Definition: FacerecService.h:2362
const std::string license_body
Сontent of a license.
Definition: FacerecService.h:87
InternalImageBuffer::Ptr createInternalImageBuffer(const int width, const int height, const RawImage::Format format)
Create InternalImageBuffer for specified image size and format. Thread-safe. Always create new Intern...
Definition: FacerecService.h:2374
std::vector< CounterState > counters
State of all license counters.
Definition: FacerecService.h:159
LightSmartPtr< Recognizer >::tPtr Ptr
Alias for the type of a smart pointer to Recognizer.
Definition: Recognizer.h:46
LightSmartPtr< FacerecService >::tPtr Ptr
Alias for the type of a smart pointer to FacerecService.
Definition: FacerecService.h:73
The class of exceptions thrown when errors occur.
Definition: Error.h:26
std::string ios_app_id
iOS application ID. Available only on iOS (tag <ios_app_id>).
Definition: FacerecService.h:147
void keepAlgorithmsCache() const
Enalbe keeping algorithms data in memory even if no owners left. This will speedup repeated algorithm...
Definition: FacerecService.h:2352
LightSmartPtr< DynamicTemplateIndex >::tPtr Ptr
Alias for the type of a smart pointer to DynamicTemplateIndex.
Definition: DynamicTemplateIndex.h:34
Liveness2DEstimator::Ptr createLiveness2DEstimator(const std::string ini_file) const
Creates an Liveness2DEstimator object. Thread-safe.
Definition: FacerecService.h:2183
std::string hardware_reg
Hardware signature (tag <Reg>).
Definition: FacerecService.h:153
FaceQualityEstimator::Ptr createFaceQualityEstimator(const std::string ini_file) const
Creates a FaceQualityEstimator object. Thread-safe.
Definition: FacerecService.h:1623
std::string getVersion() const
Get version of face recognition library. Thread-safe.
Definition: FacerecService.h:1527
QualityEstimator::Ptr createQualityEstimator(const std::string ini_file) const
Creates a QualityEstimator object. Thread-safe.
Definition: FacerecService.h:1604
bool online
Online license flag.
Definition: FacerecService.h:128
int64_t value
Current value (number of used elements).
Definition: FacerecService.h:121
std::string name
Element name (equals to the tag name).
Definition: FacerecService.h:109
Storing the license as a string variable.
Definition: FacerecService.h:81
FaceAttributesEstimator is an interface object used to estimate attributes of the face...
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:52
LightSmartPtr< Liveness2DEstimator >::tPtr Ptr
Alias for the type of a smart pointer to Liveness2DEstimator.
Definition: Liveness2DEstimator.h:50
LightSmartPtr< ContextTemplate >::tPtr Ptr
Alias for the type of a smart pointer to ContextTemplate.
Definition: ContextTemplate.h:47
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:67
IRLivenessEstimator is an interface object used to estimate face liveness in order to prevent spoofin...
LicenseState getLicenseState() const
Get the license state. Thread-safe.
Definition: FacerecService.h:2313
LightSmartPtr< FaceAttributesEstimator >::tPtr Ptr
Alias for the type of a smart pointer to FaceAttributesEstimator.
Definition: FaceAttributesEstimator.h:37
RawSample::Ptr loadRawSample(std::istream &binary_stream) const
Loads a RawSample object that was saved with the RawSample::save member function. The format is platf...
Definition: FacerecService.h:1932
LightSmartPtr< LivenessEstimator >::tPtr Ptr
Alias for the type of a smart pointer to LivenessEstimator.
Definition: LivenessEstimator.h:42
RawSample::Ptr loadRawSampleWithoutImage(pbio::stl_wraps::WrapIStream &binary_stream, const RawImage image, const double space_translation_x=0, const double space_translation_y=0, const double space_scale=1) const
Loads a RawSample object that was saved with the RawSample::saveWithoutImage member function...
Definition: FacerecService.h:1957
EmotionsEstimator::Ptr createEmotionsEstimator(const std::string ini_file) const
Creates a EmotionsEstimator object. Thread-safe.
Definition: FacerecService.h:1657
Format
Format of image data.
Definition: IRawImage.h:46
LightSmartPtr< AgeGenderEstimator >::tPtr Ptr
Alias for the type of a smart pointer to AgeGenderEstimator.
Definition: AgeGenderEstimator.h:55
LivenessEstimator::Ptr createLivenessEstimator() const
Creates a LivenessEstimator object. Thread-safe.
Definition: FacerecService.h:1641
CheckType
Check type for active liveness.
Definition: ActiveLiveness.h:14
Struct that provides raw image data and optional cropping information.
Definition: RawImage.h:113
FaceQualityEstimator - Interface object for sample quality estimation.
DepthLivenessEstimator::Ptr createDepthLivenessEstimator(const std::string ini_file) const
Creates a DepthLivenessEstimator object. Thread-safe.
Definition: FacerecService.h:2084
License status.
Definition: FacerecService.h:97
LightSmartPtr< DepthLivenessEstimator >::tPtr Ptr
Alias for the type of a smart pointer to DepthLivenessEstimator.
Definition: DepthLivenessEstimator.h:43