9 #ifndef __PBIO_API__PBIO__RAW_SAMPLE_H_
10 #define __PBIO_API__PBIO__RAW_SAMPLE_H_
15 #include "ComplexObject.h"
16 #include "ExceptionCheck.h"
19 #ifndef WITHOUT_PROCESSING_BLOCK
23 #include "stl_wraps_impls/WrapOStreamImpl.h"
24 #include "stl_wraps_impls/WrapVectorImpl.h"
29 class AgeGenderEstimator;
32 class LivenessEstimator;
33 class QualityEstimator;
34 class FaceQualityEstimator;
37 class EmotionsEstimator;
38 class DepthLivenessEstimator;
39 class IRLivenessEstimator;
40 class Liveness2DEstimator;
41 class FaceAttributesEstimator;
42 class RawSampleExtractor;
466 void const* &data)
const;
541 std::ostream &binary_stream,
605 pbio::stl_wraps::WrapOStream &binary_stream,
646 std::ostream &binary_stream,
687 pbio::stl_wraps::WrapOStream &binary_stream,
759 void save(pbio::stl_wraps::WrapOStream &binary_stream,
ImageFormat format)
const;
817 pbio::stl_wraps::WrapOStream &binary_stream,
818 const double space_translation_x = 0,
819 const double space_translation_y = 0,
820 const double space_scale = 1)
const;
826 std::ostream &binary_stream,
827 const double space_translation_x = 0,
828 const double space_translation_y = 0,
829 const double space_scale = 1)
const;
864 #ifndef WITHOUT_PROCESSING_BLOCK
869 void* getPtr()
const;
875 const DHPtr &dll_handle,
891 friend class RawSampleExtractor;
892 friend class object_with_ref_counter<
RawSample>;
906 RawSample::RawSample(
907 const DHPtr &dll_handle,
909 ComplexObject(dll_handle, impl)
920 void* exception = NULL;
922 _dll_handle->RawSample_getRectangle(
930 checkException(exception, *_dll_handle);
939 std::vector<float> coordinates;
941 void* exception = NULL;
943 _dll_handle->RawSample_getLandmarks(
946 pbio::stl_wraps::assign_floats_vector_func,
949 checkException(exception, *_dll_handle);
951 std::vector<Point> points(coordinates.size() / 3);
953 for(
size_t i = 0; i < points.size(); ++i)
955 points[i].x = coordinates[i * 3 + 0];
956 points[i].y = coordinates[i * 3 + 1];
957 points[i].z = coordinates[i * 3 + 2];
967 std::vector<float> coordinates;
969 void* exception = NULL;
971 _dll_handle->RawSample_getIrisLandmarks(
974 pbio::stl_wraps::assign_floats_vector_func,
977 checkException(exception, *_dll_handle);
979 std::vector<Point> points(coordinates.size() / 3);
981 for(
size_t i = 0; i < points.size(); ++i)
983 points[i].x = coordinates[i * 3 + 0];
984 points[i].y = coordinates[i * 3 + 1];
985 points[i].z = coordinates[i * 3 + 2];
997 void* exception = NULL;
999 _dll_handle->RawSample_getLeftEye(
1005 checkException(exception, *_dll_handle);
1015 void* exception = NULL;
1017 _dll_handle->RawSample_getRightEye(
1023 checkException(exception, *_dll_handle);
1033 void* exception = NULL;
1035 _dll_handle->RawSample_getAngles(
1042 checkException(exception, *_dll_handle);
1050 void* exception = NULL;
1052 const int result = _dll_handle->RawSample_getID(
1056 checkException(exception, *_dll_handle);
1064 void* exception = NULL;
1066 const int result = _dll_handle->RawSample_getFrameID(
1070 checkException(exception, *_dll_handle);
1079 void* exception = NULL;
1081 const int result = _dll_handle->RawSample_getType(
1085 checkException(exception, *_dll_handle);
1095 void* exception = NULL;
1099 _dll_handle->RawSample_getFaceCutRectangle(
1105 checkException(exception, *_dll_handle);
1107 std::vector<RawSample::Point> result(4);
1108 for(
int i = 0; i < 4; ++i)
1110 result[i].x = corners[i * 2 + 0];
1111 result[i].y = corners[i * 2 + 1];
1120 std::ostream &binary_stream,
1124 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1134 int32_t width, height;
1135 std::ostringstream stream;
1136 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(stream);
1138 void* exception = NULL;
1140 _dll_handle->RawSample_cutFaceImage(
1142 &binary_stream_wrap,
1143 pbio::stl_wraps::WrapOStream::write_func,
1151 checkException(exception, *_dll_handle);
1157 (
unsigned char*) stream.str().c_str(),
1158 stream.str().size());
1165 pbio::stl_wraps::WrapOStream &binary_stream,
1169 void* exception = NULL;
1173 _dll_handle->RawSample_cutFaceImage(
1176 pbio::stl_wraps::WrapOStream::write_func,
1184 checkException(exception, *_dll_handle);
1191 std::ostream &binary_stream,
1195 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1207 pbio::stl_wraps::WrapOStream &binary_stream,
1211 void* exception = NULL;
1213 const RawImage::CapiData cdata = original_image.makeCapiData();
1215 _dll_handle->RawSample_cutFaceImage_original_raw_image_with_crop(
1222 cdata.crop_info_offset_x,
1223 cdata.crop_info_offset_y,
1224 cdata.crop_info_data_image_width,
1225 cdata.crop_info_data_image_height,
1227 pbio::stl_wraps::WrapOStream::write_func,
1232 checkException(exception, *_dll_handle);
1238 std::ostream &binary_stream,
1241 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1243 save(binary_stream_wrap, format);
1248 pbio::stl_wraps::WrapOStream &binary_stream,
1251 void* exception = NULL;
1253 _dll_handle->RawSample_save(
1256 pbio::stl_wraps::WrapOStream::write_func,
1260 checkException(exception, *_dll_handle);
1268 void* exception = NULL;
1270 const bool result = _dll_handle->RawSample_hasOriginalImage(
1274 checkException(exception, *_dll_handle);
1282 void* exception = NULL;
1284 const float result = _dll_handle->RawSample_getScore(
1288 checkException(exception, *_dll_handle);
1297 void* exception = NULL;
1299 const float result = _dll_handle->RawSample_getFaceVisibilityScore(
1303 checkException(exception, *_dll_handle);
1315 void const* &data)
const
1317 int32_t rows_, cols_, format_;
1319 void* exception = NULL;
1321 _dll_handle->RawSample_getOriginalImage(
1329 checkException(exception, *_dll_handle);
1340 void* exception = NULL;
1342 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
1343 _dll_handle->RawSample_downscaleToPreferredSize(
1347 checkException(exception, *_dll_handle);
1349 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
1352 #ifndef WITHOUT_PROCESSING_BLOCK
1354 Context RawSample::toContext()
const
1356 void* exception = NULL;
1358 HContext* handle = _dll_handle->RawSample_toContext(
1362 checkException(exception, *_dll_handle);
1364 return Context(_dll_handle, handle,
false);
1371 pbio::stl_wraps::WrapOStream &binary_stream,
1372 const double space_translation_x,
1373 const double space_translation_y,
1374 const double space_scale)
const
1376 void* exception = NULL;
1378 _dll_handle->RawSample_save_without_image(
1381 pbio::stl_wraps::WrapOStream::write_func,
1382 space_translation_x,
1383 space_translation_y,
1387 checkException(exception, *_dll_handle);
1392 std::ostream &binary_stream,
1393 const double space_translation_x,
1394 const double space_translation_y,
1395 const double space_scale)
const
1397 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1401 space_translation_x,
1402 space_translation_y,
1407 void* RawSample::getPtr()
const
1417 #endif // __PBIO_API__PBIO__RAW_SAMPLE_H_
int width
Width of the rectangle.
Definition: Rectangle.h:47
float getFaceVisibilityScore() const
Get the score of face visibility. Thread-safe.
Definition: RawSample.h:1295
Interface object for sample quality estimation.
Definition: FaceQualityEstimator.h:41
Struct that provides raw image data and optional cropping information.
Definition: RawImage.h:28
ISO/IEC 19794-5 Token Frontal (fixed eye positions) (only frontal sample type).
Definition: RawSample.h:151
Interface object for creating other interface objects.
Definition: FacerecService.h:64
float getScore() const
Get the score of the detected face (for samples made with supported single-shot Capturers). Thread-safe.
Definition: RawSample.h:1280
int x
X coordinate of the top-left corner.
Definition: Rectangle.h:33
Interface object used to estimate attributes of the face.
Definition: FaceAttributesEstimator.h:28
std::vector< Point > getFaceCutRectangle(FaceCutType cut_type) const
Get a cropping rectangle (for preview) that will be used in cutFaceImage. Thread-safe.
Definition: RawSample.h:1092
Interface object used to estimate face liveness in order to prevent spoofing attacks.
Definition: Liveness2DEstimator.h:41
BMP (no compression).
Definition: RawSample.h:122
Interface object used to estimate face liveness to prevent spoofing attacks.
Definition: LivenessEstimator.h:33
Interface object that stores a captured face sample.
Definition: RawSample.h:49
SampleType
Sample types (see also Capturer::CapturerType).
Definition: RawSample.h:65
void cutFaceImage(std::ostream &binary_stream, ImageFormat format, FaceCutType cut_type) const
Crop the face and save in the specified format. Thread-safe.
Definition: RawSample.h:1119
Rectangle getRectangle() const
Get a face bounding rectangle. Thread-safe.
Definition: RawSample.h:916
Interface object used to estimate face liveness in order to prevent spoofing attacks.
Definition: DepthLivenessEstimator.h:34
pbio::Point Point
2D point.
Definition: RawSample.h:166
JPEG (lossy compression).
Definition: RawSample.h:101
The face is right-profile-oriented.
Definition: RawSample.h:86
float x
X coordinate.
Definition: Point.h:19
void getOriginalImage(int &rows, int &cols, IRawImage::Format &format, void const *&data) const
Get an original image. Throws an exception if a sample doesn’t contain an original image (check with ...
Definition: RawSample.h:1311
SampleType getType() const
Get a sample type. Thread-safe.
Definition: RawSample.h:1077
Interface object for creating and matching templates.
Definition: Recognizer.h:37
RawSample::Ptr downscaleToPreferredSize() const
Clone this RawSample with an internal face image downscaled to suitable size and without an original ...
Definition: RawSample.h:1338
ImageFormat
Image formats for saving.
Definition: RawSample.h:94
LightSmartPtr< RawSample >::tPtr Ptr
Alias for the type of a smart pointer to RawSample.
Definition: RawSample.h:58
ISO/IEC 19794-5 Full Frontal (for ID, travel documents) (only frontal sample type).
Definition: RawSample.h:144
Point getRightEye() const
Get a point of the right eye. Only frontal samples. Thread-safe.
Definition: RawSample.h:1011
3D point.
Definition: Point.h:12
VideoWorker is an interface object for tracking, processing and matching faces on multiple video stre...
Definition: VideoWorker.h:63
RawImage cutFaceRawImage(RawImage::Format color_model, FaceCutType cut_type) const
Crop face in RawImage format (with raw pixels). Thread-safe.
Definition: RawSample.h:1130
std::vector< Point > getIrisLandmarks() const
Get the characteristic points of the eyes. Only frontal samples. Thread-safe.
Definition: RawSample.h:965
int height
Height of the rectangle.
Definition: Rectangle.h:54
int getID() const
Get a face ID. Thread-safe.
Definition: RawSample.h:1048
float yaw
Yaw angle in degrees.
Definition: RawSample.h:180
std::vector< Point > getLandmarks() const
Get anthropometric landmarks. Only frontal samples. Thread-safe.
Definition: RawSample.h:937
void saveWithoutImage(pbio::stl_wraps::WrapOStream &binary_stream, const double space_translation_x=0, const double space_translation_y=0, const double space_scale=1) const
Save (serialize) all sample information except the image. You have to store the image on your own in ...
Definition: RawSample.h:1370
pbio::Rectangle Rectangle
Rectangle in an image.
Definition: RawSample.h:159
Definition: SmartPtr.h:84
Rectangle in an image.
Definition: Rectangle.h:12
float y
Y coordinate.
Definition: Point.h:26
The face is frontal-oriented.
Definition: RawSample.h:72
Interface object for age and gender estimation.
Definition: AgeGenderEstimator.h:46
Interface object used to estimate sample quality.
Definition: QualityEstimator.h:41
Face orientation angles.
Definition: RawSample.h:173
TIFF (lossless compression).
Definition: RawSample.h:115
Interface object for detecting or tracking of faces in the images or video sequences.
Definition: Capturer.h:36
FaceCutType
Face cropping types.
Definition: RawSample.h:130
Point getLeftEye() const
Get a point of the left eye. Only frontal samples. Thread-safe.
Definition: RawSample.h:993
float roll
Roll angle in degrees.
Definition: RawSample.h:194
bool hasOriginalImage() const
Does the sample store the original image (true for samples made with VideoWorker with enabled store_o...
Definition: RawSample.h:1266
The face is left-profile-oriented.
Definition: RawSample.h:79
float pitch
Pitch angle in degrees.
Definition: RawSample.h:187
void save(std::ostream &binary_stream, ImageFormat format) const
Save (serialize) the sample. Original image will not be saved (i.e. only the part of an image contain...
Definition: RawSample.h:1237
int y
Y coordinate of the top-left corner.
Definition: Rectangle.h:40
int getFrameID() const
Get an ID of the frame, in which this RawSample is detected (for samples made with VideoWorker)...
Definition: RawSample.h:1062
Format
Format of image data.
Definition: IRawImage.h:46
PNG (lossless compression).
Definition: RawSample.h:108
Interface object used to estimate face liveness in order to prevent spoofing attacks.
Definition: IRLivenessEstimator.h:34
Unspecified cropping (any sample type).
Definition: RawSample.h:137
Angles getAngles() const
Get a face orientation. Only frontal samples. Thread-safe.
Definition: RawSample.h:1029
Interface object for estimation of emotions.
Definition: EmotionsEstimator.h:41