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"
47 #include "StructStorage.h"
49 #include "ProcessingUnit.h"
51 #ifndef WITHOUT_PROCESSING_BLOCK
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;
526 const bool processing =
true,
527 const bool matching =
true,
528 const bool processing_less_memory_consumption =
false)
const;
608 const char* recognizer_ini_file,
609 const int streams_count,
610 const int processing_threads_count,
611 const int matching_threads_count)
const;
658 const int streams_count,
659 const int processing_threads_count,
660 const int matching_threads_count)
const;
786 pbio::stl_wraps::WrapIStream &binary_stream,
788 const double space_translation_x = 0,
789 const double space_translation_y = 0,
790 const double space_scale = 1)
const;
796 std::istream &binary_stream,
798 const double space_translation_x = 0,
799 const double space_translation_y = 0,
800 const double space_scale = 1)
const;
856 pbio::stl_wraps::WrapIStream &binary_stream,
857 const unsigned char *image_data,
859 const double space_translation_x = 0,
860 const double space_translation_y = 0,
861 const double space_scale = 1)
const;
868 std::istream &binary_stream,
869 const unsigned char *image_data,
871 const double space_translation_x = 0,
872 const double space_translation_y = 0,
873 const double space_scale = 1)
const;
920 const std::string ini_file)
const;
974 const std::string ini_file)
const;
1028 const std::string ini_file)
const;
1081 const std::string ini_file)
const;
1085 ProcessingUnit::Ptr createProcessingUnit(
1086 const int block_type,
1087 const char* serializedConfig)
const;
1089 #ifndef WITHOUT_PROCESSING_BLOCK
1090 Context createContext()
const;
1092 Context createContextFromEncodedImage(
const uint8_t* data, uint64_t dataSize)
const;
1094 Context createContextFromEncodedImage(
const std::vector<uint8_t>& data)
const;
1096 Context createContextFromEncodedImage(
const std::string& data)
const;
1098 Context createContextFromEncodedImage(
const std::vector<char>& data)
const;
1100 Context createContextFromFrame(uint8_t* data, int32_t width, int32_t height, Context::Format format = Context::Format::FORMAT_BGR, int32_t baseAngle = 0)
const;
1243 jobject android_media_image);
1244 #endif // ifdef ANDROID
1289 const bool downscale_x2,
1290 void*
const result_buffer);
1293 void convertYUV2RGB(
1295 const bool downscale_x2,
1296 const int base_angle,
1297 void*
const result_buffer);
1300 void convertBGRA88882RGB(
1302 const bool downscale_x2,
1303 const int base_angle,
1304 void*
const result_buffer);
1309 const std::string _facerec_conf_dir;
1314 const DHPtr &dll_handle,
1315 const std::string &facerec_conf_dir,
1336 const std::string dll_path,
1337 std::string facerec_conf_dir,
1338 const std::string license_dir)
1340 return createService(NULL, dll_path, facerec_conf_dir, license_dir,
true);
1346 const std::string dll_path,
1347 std::string facerec_conf_dir,
1357 const std::string dll_path,
1358 std::string facerec_conf_dir,
1359 const std::string license,
1360 const bool is_license_dir)
1363 #ifdef __STATIC_LIBFACEREC_BUILD__
1366 const DHPtr dll_handle( DHPtr::make() );
1368 const DHPtr dll_handle( DHPtr::make(dll_path.c_str()) );
1371 if(facerec_conf_dir.empty())
1373 facerec_conf_dir =
"./";
1375 else if(facerec_conf_dir[facerec_conf_dir.length() - 1] !=
'/')
1377 facerec_conf_dir +=
'/';
1380 void* exception = NULL;
1386 the_impl = dll_handle->FacerecService_constructor3(
1388 facerec_conf_dir.c_str(),
1396 the_impl = dll_handle->FacerecService_constructor5(
1398 facerec_conf_dir.c_str(),
1404 checkException(exception, *dll_handle);
1406 return FacerecService::Ptr::make(
1414 FacerecService::FacerecService(
1415 const DHPtr &dll_handle,
1416 const std::string &facerec_conf_dir,
1418 ComplexObject(dll_handle, impl),
1419 _facerec_conf_dir(facerec_conf_dir)
1423 if (LIBFACEREC_VERSION != lib_version)
1424 std::cerr <<
"WARNING: The version in the header does not match the version in the library. Header version: "
1425 << LIBFACEREC_VERSION <<
", library version: " << lib_version << std::endl;
1432 std::ostringstream version_stream;
1433 pbio::stl_wraps::WrapOStreamImpl version_stream_wrap(version_stream);
1435 void* exception = NULL;
1437 _dll_handle->get_version(
1438 &version_stream_wrap,
1439 pbio::stl_wraps::WrapOStream::write_func,
1442 checkException(exception, *_dll_handle);
1444 return version_stream.str();
1451 void* exception = NULL;
1453 _dll_handle->FacerecService_forceOnlineLicenseUpdate(
1457 checkException(exception, *_dll_handle);
1464 const std::string file_path = _facerec_conf_dir + config.config_filepath;
1466 std::vector<char const*> overridden_keys;
1467 std::vector<double> overridden_values;
1469 config.prepare(overridden_keys, overridden_values);
1471 void* exception = NULL;
1473 pbio::facerec::CapturerImpl*
const capturer_impl =
1474 _dll_handle->FacerecService_createCapturerE(
1477 overridden_keys.size(),
1478 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
1479 overridden_values.empty() ? NULL : &(overridden_values[0]),
1482 checkException(exception, *_dll_handle);
1484 return Capturer::Ptr::make(_dll_handle, capturer_impl);
1490 const std::string file_path = _facerec_conf_dir + ini_file;
1492 void* exception = NULL;
1494 pbio::facerec::AgeGenderEstimatorImpl*
const the_impl =
1495 _dll_handle->FacerecService_createAgeGenderEstimator(
1500 checkException(exception, *_dll_handle);
1502 return AgeGenderEstimator::Ptr::make(_dll_handle, the_impl);
1509 const std::string file_path = _facerec_conf_dir + ini_file;
1511 void* exception = NULL;
1513 pbio::facerec::QualityEstimatorImpl*
const the_impl =
1514 _dll_handle->FacerecService_createQualityEstimator(
1519 checkException(exception, *_dll_handle);
1521 return QualityEstimator::Ptr::make(_dll_handle, the_impl);
1528 const std::string file_path = _facerec_conf_dir + ini_file;
1530 void* exception = NULL;
1532 pbio::facerec::FaceQualityEstimatorImpl*
const the_impl =
1533 _dll_handle->FacerecService_createFaceQualityEstimator(
1538 checkException(exception, *_dll_handle);
1540 return FaceQualityEstimator::Ptr::make(_dll_handle, the_impl);
1546 void* exception = NULL;
1548 pbio::facerec::LivenessEstimatorImpl*
const the_impl =
1549 _dll_handle->FacerecService_createLivenessEstimator(
1553 checkException(exception, *_dll_handle);
1555 return LivenessEstimator::Ptr::make(_dll_handle, the_impl);
1561 const std::string ini_file)
const
1563 const std::string file_path = _facerec_conf_dir + ini_file;
1565 void* exception = NULL;
1567 pbio::facerec::EmotionsEstimatorImpl*
const the_impl =
1568 _dll_handle->FacerecService_createEmotionsEstimator(
1573 checkException(exception, *_dll_handle);
1575 return EmotionsEstimator::Ptr::make(_dll_handle, the_impl);
1581 const char* ini_file,
1582 const bool processing,
1583 const bool matching,
1584 const bool processing_less_memory_consumption)
const
1586 const std::string file_path = _facerec_conf_dir + ini_file;
1588 void* exception = NULL;
1590 pbio::facerec::RecognizerImpl*
const recognizer_impl =
1591 _dll_handle->FacerecService_createRecognizer2(
1599 (int) processing_less_memory_consumption,
1602 checkException(exception, *_dll_handle);
1604 return Recognizer::Ptr::make(_dll_handle, recognizer_impl);
1611 const bool processing,
1612 const bool matching,
1613 const bool processing_less_memory_consumption)
const
1615 const std::string file_path = _facerec_conf_dir + recognizer_config.config_filepath;
1617 std::vector<char const*> overridden_keys;
1618 std::vector<double> overridden_values;
1620 recognizer_config.prepare(overridden_keys, overridden_values);
1622 void* exception = NULL;
1624 pbio::facerec::RecognizerImpl*
const recognizer_impl =
1625 _dll_handle->FacerecService_createRecognizer2(
1628 overridden_keys.size(),
1629 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
1630 overridden_values.empty() ? NULL : &(overridden_values[0]),
1633 (
int) processing_less_memory_consumption,
1636 checkException(exception, *_dll_handle);
1638 return Recognizer::Ptr::make(_dll_handle, recognizer_impl);
1646 const char* recognizer_ini_file,
1647 const int streams_count,
1648 const int processing_threads_count,
1649 const int matching_threads_count)
const
1653 .video_worker_config(video_worker_ini_file)
1654 .recognizer_ini_file(recognizer_ini_file)
1655 .streams_count(streams_count)
1656 .processing_threads_count(processing_threads_count)
1657 .matching_threads_count(matching_threads_count)
1665 const int streams_count,
1666 const int processing_threads_count,
1667 const int matching_threads_count)
const
1671 .video_worker_config(video_worker_ini_file)
1672 .recognizer_config(recognizer_config)
1673 .streams_count(streams_count)
1674 .processing_threads_count(processing_threads_count)
1675 .matching_threads_count(matching_threads_count)
1683 std::vector<char const*> vw_overridden_keys;
1684 std::vector<double> vw_overridden_values;
1686 params._video_worker_config.prepare(vw_overridden_keys, vw_overridden_values);
1687 std::vector<std::string> extra_over_params;
1689 if(!params._active_liveness_checks_order.empty()){
1690 bool is_unique =
true;
1691 for (
auto it = params._active_liveness_checks_order.begin(); it != params._active_liveness_checks_order.end(); ++it)
1692 if (std::find(it + 1, params._active_liveness_checks_order.end(), *it) != params._active_liveness_checks_order.end()) {
1698 "Error 0x3302330e: Set a unique order of `active_liveness_checks_order` for Active Liveness.");
1699 for (
size_t i = 0; i < params._active_liveness_checks_order.size(); i++){
1701 std::string check_str = ActiveLiveness::CheckTypeToString(check);
1702 extra_over_params.push_back(
"active_liveness.check_" + check_str);
1703 vw_overridden_keys.push_back(extra_over_params.back().c_str());
1704 vw_overridden_values.push_back(-(
double)(i+1));
1709 if (!params._recognizer_ini_file.empty() && !params._recognizer_config.config_filepath.empty())
1710 throw pbio::Error(0xb3fe4d07,
"Error: 0xed877a99 You must use either recognizer_config or recognizer_ini_file.");
1713 params._recognizer_ini_file.empty() ?
1714 params._recognizer_config :
1717 std::vector<char const*> rec_overridden_keys;
1718 std::vector<double> rec_overridden_values;
1720 recognizer_config.prepare(rec_overridden_keys, rec_overridden_values);
1722 void* exception = NULL;
1724 pbio::facerec::VideoWorkerImpl*
const vw_impl =
1725 _dll_handle->FacerecService_createVideoWorker_sti_age_gender_emotions(
1728 VideoWorker::STrackingCallback,
1729 VideoWorker::STemplateCreatedCallback,
1730 VideoWorker::SMatchFoundCallback,
1731 VideoWorker::STrackingLostCallback,
1732 VideoWorker::SStiPersonOutdatedCallback,
1734 (_facerec_conf_dir + params._video_worker_config.config_filepath).c_str(),
1735 vw_overridden_keys.size(),
1736 vw_overridden_keys.empty() ? NULL : &(vw_overridden_keys[0]),
1737 vw_overridden_values.empty() ? NULL : &(vw_overridden_values[0]),
1739 (_facerec_conf_dir + recognizer_config.config_filepath).c_str(),
1740 rec_overridden_keys.size(),
1741 rec_overridden_keys.empty() ? NULL : &(rec_overridden_keys[0]),
1742 rec_overridden_values.empty() ? NULL : &(rec_overridden_values[0]),
1744 params._streams_count,
1745 params._processing_threads_count,
1746 params._matching_threads_count,
1747 params._short_time_identification_enabled,
1748 params._short_time_identification_distance_threshold,
1749 params._short_time_identification_outdate_time_seconds,
1750 params._age_gender_estimation_threads_count,
1751 params._emotions_estimation_threads_count,
1754 checkException(exception, *_dll_handle);
1756 return VideoWorker::Ptr::make(_dll_handle, vw_impl);
1763 pbio::stl_wraps::WrapIStreamImpl binary_stream_wrap(binary_stream);
1771 void* exception = NULL;
1773 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
1774 _dll_handle->FacerecService_loadRawSample(
1777 pbio::stl_wraps::WrapIStream::read_func,
1780 checkException(exception, *_dll_handle);
1782 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
1787 pbio::stl_wraps::WrapIStream &binary_stream,
1789 const double space_translation_x,
1790 const double space_translation_y,
1791 const double space_scale)
const
1793 void* exception = NULL;
1795 const RawImage::CapiData cdata = image.makeCapiData();
1797 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
1798 _dll_handle->FacerecService_loadRawSampleWithoutImage_raw_image(
1801 pbio::stl_wraps::WrapIStream::read_func,
1808 cdata.crop_info_offset_x,
1809 cdata.crop_info_offset_y,
1810 cdata.crop_info_data_image_width,
1811 cdata.crop_info_data_image_height,
1813 space_translation_x,
1814 space_translation_y,
1819 checkException(exception, *_dll_handle);
1821 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
1826 std::istream &binary_stream,
1828 const double space_translation_x,
1829 const double space_translation_y,
1830 const double space_scale)
const
1832 pbio::stl_wraps::WrapIStreamImpl binary_stream_wrap(binary_stream);
1837 space_translation_x,
1838 space_translation_y,
1844 pbio::stl_wraps::WrapIStream &binary_stream,
1845 const unsigned char *image_data,
1846 int image_data_size,
1847 const double space_translation_x,
1848 const double space_translation_y,
1849 const double space_scale)
const
1851 void* exception = NULL;
1853 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
1854 _dll_handle->FacerecService_loadRawSampleWithoutImage_encoded_image(
1857 pbio::stl_wraps::WrapIStream::read_func,
1862 space_translation_x,
1863 space_translation_y,
1868 checkException(exception, *_dll_handle);
1870 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
1875 std::istream &binary_stream,
1876 const unsigned char *image_data,
1877 int image_data_size,
1878 const double space_translation_x,
1879 const double space_translation_y,
1880 const double space_scale)
const
1882 pbio::stl_wraps::WrapIStreamImpl binary_stream_wrap(binary_stream);
1889 space_translation_x,
1890 space_translation_y,
1898 void* exception = NULL;
1900 pbio::facerec::CameraCalibratorImpl*
const calibrator_impl =
1901 _dll_handle->FacerecService_createCameraCalibrator(
1905 checkException(exception, *_dll_handle);
1907 return CameraCalibrator::Ptr::make(_dll_handle, calibrator_impl);
1914 const std::string ini_file)
const
1916 const std::string file_path = _facerec_conf_dir + ini_file;
1918 void* exception = NULL;
1920 pbio::facerec::DepthLivenessEstimatorImpl*
const the_impl =
1921 _dll_handle->FacerecService_createDepthLivenessEstimatorE(
1929 checkException(exception, *_dll_handle);
1931 return DepthLivenessEstimator::Ptr::make(_dll_handle, the_impl);
1939 const std::string file_path = _facerec_conf_dir + config.config_filepath;
1941 std::vector<char const*> overridden_keys;
1942 std::vector<double> overridden_values;
1944 config.prepare(overridden_keys, overridden_values);
1946 void* exception = NULL;
1948 pbio::facerec::DepthLivenessEstimatorImpl*
const the_impl =
1949 _dll_handle->FacerecService_createDepthLivenessEstimatorE(
1952 overridden_keys.size(),
1953 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
1954 overridden_values.empty() ? NULL : &(overridden_values[0]),
1957 checkException(exception, *_dll_handle);
1959 return DepthLivenessEstimator::Ptr::make(_dll_handle, the_impl);
1964 const std::string ini_file)
const
1966 const std::string file_path = _facerec_conf_dir + ini_file;
1968 void* exception = NULL;
1970 pbio::facerec::IRLivenessEstimatorImpl*
const the_impl =
1971 _dll_handle->FacerecService_createIRLivenessEstimatorE(
1979 checkException(exception, *_dll_handle);
1981 return IRLivenessEstimator::Ptr::make(_dll_handle, the_impl);
1988 const std::string file_path = _facerec_conf_dir + config.config_filepath;
1990 std::vector<char const*> overridden_keys;
1991 std::vector<double> overridden_values;
1993 config.prepare(overridden_keys, overridden_values);
1995 void* exception = NULL;
1997 pbio::facerec::IRLivenessEstimatorImpl*
const the_impl =
1998 _dll_handle->FacerecService_createIRLivenessEstimatorE(
2001 overridden_keys.size(),
2002 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
2003 overridden_values.empty() ? NULL : &(overridden_values[0]),
2006 checkException(exception, *_dll_handle);
2008 return IRLivenessEstimator::Ptr::make(_dll_handle, the_impl);
2013 const std::string ini_file)
const
2015 const std::string file_path = _facerec_conf_dir + ini_file;
2017 void* exception = NULL;
2019 pbio::facerec::Liveness2DEstimatorImpl*
const the_impl =
2020 _dll_handle->FacerecService_createLiveness2DEstimatorE(
2028 checkException(exception, *_dll_handle);
2030 return Liveness2DEstimator::Ptr::make(_dll_handle, the_impl);
2037 const std::string file_path = _facerec_conf_dir + config.config_filepath;
2039 std::vector<char const*> overridden_keys;
2040 std::vector<double> overridden_values;
2042 config.prepare(overridden_keys, overridden_values);
2044 void* exception = NULL;
2046 pbio::facerec::Liveness2DEstimatorImpl*
const the_impl =
2047 _dll_handle->FacerecService_createLiveness2DEstimatorE(
2050 overridden_keys.size(),
2051 overridden_keys.empty() ? NULL : &(overridden_keys[0]),
2052 overridden_values.empty() ? NULL : &(overridden_values[0]),
2055 checkException(exception, *_dll_handle);
2057 return Liveness2DEstimator::Ptr::make(_dll_handle, the_impl);
2062 const std::string ini_file)
const
2064 const std::string file_path = _facerec_conf_dir + ini_file;
2066 void* exception = NULL;
2068 pbio::facerec::FaceAttributesEstimatorImpl*
const the_impl =
2069 _dll_handle->FacerecService_createFaceAttributesEstimator(
2077 checkException(exception, *_dll_handle);
2079 return FaceAttributesEstimator::Ptr::make(_dll_handle, the_impl);
2085 ProcessingUnit::Ptr FacerecService::createProcessingUnit(
2086 const int block_type,
2087 const char* serializedConfig)
const
2089 return ProcessingUnit::Ptr::make(_dll_handle, block_type, serializedConfig);
2092 #ifndef WITHOUT_PROCESSING_BLOCK
2093 inline Context FacerecService::createContext()
const
2095 return Context(_dll_handle);
2098 inline Context FacerecService::createContextFromEncodedImage(
const uint8_t* data, uint64_t dataSize)
const
2100 return Context(_dll_handle, data, dataSize);
2103 inline Context FacerecService::createContextFromEncodedImage(
const std::vector<uint8_t>& data)
const
2105 return Context(_dll_handle, data.data(), data.size());
2108 inline Context FacerecService::createContextFromEncodedImage(
const std::string& data)
const
2110 return Context(_dll_handle, reinterpret_cast<const uint8_t*>(data.data()), data.size());
2113 inline Context FacerecService::createContextFromEncodedImage(
const std::vector<char>& data)
const
2115 return Context(_dll_handle, reinterpret_cast<const uint8_t*>(data.data()), data.size());
2118 inline Context FacerecService::createContextFromFrame(uint8_t* data, int32_t width, int32_t height, Context::Format format, int32_t baseAngle)
const
2120 return Context(_dll_handle, data, width, height, format, baseAngle);
2123 inline ProcessingBlock FacerecService::createProcessingBlock(
const Context& config)
const
2125 return ProcessingBlock(_impl, _dll_handle, config);
2134 void* exception = NULL;
2136 void* struct_storage_impl = _dll_handle->FacerecService_getLicenseState(_impl, &exception);
2138 checkException(exception, *_dll_handle);
2140 const StructStorage struct_storage(_dll_handle, struct_storage_impl);
2144 result.
online = struct_storage.get_int64(StructStorageFields::license_state_online_t);
2146 result.
android_app_id = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_android_app_id_t);
2147 result.
android_serial = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_android_serial_t);
2148 result.
ios_app_id = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_ios_app_id_t);
2149 result.
hardware_reg = (
char const*) struct_storage.get_pointer(StructStorageFields::license_state_hardware_reg_t);
2151 result.
counters.resize( struct_storage.get_int64(
2152 StructStorageFields::license_state_licenses_count_t) );
2154 for(
size_t i = 0; i < result.
counters.size(); ++i)
2156 result.
counters[i].name = (
char const*) struct_storage.get_pointer(
2157 (i << 16) |
size_t(StructStorageFields::license_state_licenses_names_int16_t) );
2159 result.
counters[i].max_value = struct_storage.get_int64(
2160 (i << 16) |
size_t(StructStorageFields::license_state_licenses_total_counts_int16_t) );
2162 result.
counters[i].value = struct_storage.get_int64(
2163 (i << 16) |
size_t(StructStorageFields::license_state_licenses_in_use_counts_int16_t) );
2173 void* exception = NULL;
2175 _dll_handle->FacerecService_toggleAlgorithmsCacheKepp(1, &exception);
2177 checkException(exception, *_dll_handle);
2183 void* exception = NULL;
2185 _dll_handle->FacerecService_toggleAlgorithmsCacheKepp(0, &exception);
2187 checkException(exception, *_dll_handle);
2198 void* exception = NULL;
2202 void* imagetptr_ptr;
2204 void*
const the_impl = _dll_handle->InternalImageBuffer_constructor(
2213 checkException(exception, *_dll_handle);
2215 return InternalImageBuffer::Ptr::make(
2218 (
unsigned char*) data_ptr,
2231 jobject android_media_image)
2233 void* exception = NULL;
2240 void* imagetptr_ptr;
2242 void*
const the_impl = _dll_handle->InternalImageBuffer_constructor_from_android_image(
2244 android_media_image,
2253 checkException(exception, *_dll_handle);
2255 return InternalImageBuffer::Ptr::make(
2258 (
unsigned char*) data_ptr,
2270 const bool downscale_x2,
2271 void*
const result_buffer)
2273 void* exception = NULL;
2275 const RawImage::CapiData cdata = image.makeCapiData();
2277 _dll_handle->RawImage_convertYUV2ARGB(
2283 cdata.crop_info_offset_x,
2284 cdata.crop_info_offset_y,
2285 cdata.crop_info_data_image_width,
2286 cdata.crop_info_data_image_height,
2291 checkException(exception, *_dll_handle);
2295 void FacerecService::convertYUV2RGB(
2297 const bool downscale_x2,
2298 const int base_angle,
2299 void*
const result_buffer)
2301 void* exception = NULL;
2303 const RawImage::CapiData cdata = image.makeCapiData();
2305 _dll_handle->RawImage_convertYUV2RGB(
2311 cdata.crop_info_offset_x,
2312 cdata.crop_info_offset_y,
2313 cdata.crop_info_data_image_width,
2314 cdata.crop_info_data_image_height,
2320 checkException(exception, *_dll_handle);
2324 void FacerecService::convertBGRA88882RGB(
2325 const RawImage image,
2326 const bool downscale_x2,
2327 const int base_angle,
2328 void*
const result_buffer)
2330 void* exception = NULL;
2332 const RawImage::CapiData cdata = image.makeCapiData();
2334 _dll_handle->RawImage_convertYUV2RGB(
2340 cdata.crop_info_offset_x,
2341 cdata.crop_info_offset_y,
2342 cdata.crop_info_data_image_width,
2343 cdata.crop_info_data_image_height,
2349 checkException(exception, *_dll_handle);
2359 #endif // __PBIO_API__PBIO__FACEREC_SERVICE_H_
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
void keepAlgorithmsCache() const
Enalbe keeping algorithms data in memory even if no owners left. This will speedup repeated algorithm...
Definition: FacerecService.h:2171
Struct that provides raw image data and optional cropping information.
Definition: RawImage.h:28
Interface object for creating other interface objects.
Definition: FacerecService.h:64
ProcessingBlock - Interface object used to work with estimators from Processing Block API...
QualityEstimator - Interface object used to estimate sample quality.
VideoWorker is an interface object for tracking, processing and matching faces on multiple video stre...
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...
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:1761
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:1335
LightSmartPtr< EmotionsEstimator >::tPtr Ptr
Alias for the type of a smart pointer to EmotionsEstimator.
Definition: EmotionsEstimator.h:50
Recognizer - Interface object for creating and matching templates.
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...
Capturer - Interface object for detecting or tracking of faces in the images or video sequences...
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
Parameters of the VideoWorker constructor.
Definition: VideoWorker.h:89
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
IRLivenessEstimator::Ptr createIRLivenessEstimator(const std::string ini_file) const
Creates an IRLivenessEstimator object. Thread-safe.
Definition: FacerecService.h:1963
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
FaceQualityEstimator::Ptr createFaceQualityEstimator(const std::string ini_file) const
Creates a FaceQualityEstimator object. Thread-safe.
Definition: FacerecService.h:1526
Error - the class of exceptions thrown when errors occur.
Template - Interface object for saving the face template.
RawSample - Interface object that stores a captured face sample.
CameraCalibrator::Ptr createCameraCalibrator() const
Creates a CameraCalibrator object. Thread-safe.
Definition: FacerecService.h:1896
LivenessEstimator - Interface object used to estimate face liveness to prevent spoofing attacks...
Liveness2DEstimator::Ptr createLiveness2DEstimator(const std::string ini_file) const
Creates an Liveness2DEstimator object. Thread-safe.
Definition: FacerecService.h:2012
AgeGenderEstimator - interface object for age and gender estimation.
EmotionsEstimator::Ptr createEmotionsEstimator(const std::string ini_file) const
Creates a EmotionsEstimator object. Thread-safe.
Definition: FacerecService.h:1560
const std::string license_body
Сontent of a license.
Definition: FacerecService.h:87
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
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:2193
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
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:1461
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:1680
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:1580
std::string hardware_reg
Hardware signature (tag <Reg>).
Definition: FacerecService.h:153
void forceOnlineLicenseUpdate() const
Force online license update.
Definition: FacerecService.h:1449
LicenseState getLicenseState() const
Get the license state. Thread-safe.
Definition: FacerecService.h:2132
DepthLivenessEstimator::Ptr createDepthLivenessEstimator(const std::string ini_file) const
Creates a DepthLivenessEstimator object. Thread-safe.
Definition: FacerecService.h:1913
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...
AgeGenderEstimator::Ptr createAgeGenderEstimator(const std::string ini_file) const
Creates a AgeGenderEstimator object. Thread-safe.
Definition: FacerecService.h:1488
LightSmartPtr< Liveness2DEstimator >::tPtr Ptr
Alias for the type of a smart pointer to Liveness2DEstimator.
Definition: Liveness2DEstimator.h:50
void freeAlgorithmsCache() const
Disable keeping algorithms data in memory. Thread-safe.
Definition: FacerecService.h:2181
IRLivenessEstimator is an interface object used to estimate face liveness in order to prevent spoofin...
std::string getVersion() const
Get version of face recognition library. Thread-safe.
Definition: FacerecService.h:1430
LightSmartPtr< FaceAttributesEstimator >::tPtr Ptr
Alias for the type of a smart pointer to FaceAttributesEstimator.
Definition: FaceAttributesEstimator.h:37
FaceAttributesEstimator::Ptr createFaceAttributesEstimator(const std::string ini_file) const
Creates an FaceAttributesEstimator object. Thread-safe.
Definition: FacerecService.h:2061
LightSmartPtr< LivenessEstimator >::tPtr Ptr
Alias for the type of a smart pointer to LivenessEstimator.
Definition: LivenessEstimator.h:42
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
CheckType
Check type for active liveness.
Definition: ActiveLiveness.h:14
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:2268
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:1786
QualityEstimator::Ptr createQualityEstimator(const std::string ini_file) const
Creates a QualityEstimator object. Thread-safe.
Definition: FacerecService.h:1507
FaceQualityEstimator - Interface object for sample quality estimation.
License status.
Definition: FacerecService.h:97
LivenessEstimator::Ptr createLivenessEstimator() const
Creates a LivenessEstimator object. Thread-safe.
Definition: FacerecService.h:1544
LightSmartPtr< DepthLivenessEstimator >::tPtr Ptr
Alias for the type of a smart pointer to DepthLivenessEstimator.
Definition: DepthLivenessEstimator.h:43