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
20 #include "pbio/Context.h"
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
877 void* getPtr()
const;
883 const DHPtr &dll_handle,
899 friend class RawSampleExtractor;
900 friend class object_with_ref_counter<
RawSample>;
914 RawSample::RawSample(
915 const DHPtr &dll_handle,
917 ComplexObject(dll_handle, impl)
928 void* exception = NULL;
930 _dll_handle->RawSample_getRectangle(
938 checkException(exception, *_dll_handle);
947 std::vector<float> coordinates;
949 void* exception = NULL;
951 _dll_handle->RawSample_getLandmarks(
954 pbio::stl_wraps::assign_floats_vector_func,
957 checkException(exception, *_dll_handle);
959 std::vector<Point> points(coordinates.size() / 3);
961 for(
size_t i = 0; i < points.size(); ++i)
963 points[i].x = coordinates[i * 3 + 0];
964 points[i].y = coordinates[i * 3 + 1];
965 points[i].z = coordinates[i * 3 + 2];
975 std::vector<float> coordinates;
977 void* exception = NULL;
979 _dll_handle->RawSample_getIrisLandmarks(
982 pbio::stl_wraps::assign_floats_vector_func,
985 checkException(exception, *_dll_handle);
987 std::vector<Point> points(coordinates.size() / 3);
989 for(
size_t i = 0; i < points.size(); ++i)
991 points[i].x = coordinates[i * 3 + 0];
992 points[i].y = coordinates[i * 3 + 1];
993 points[i].z = coordinates[i * 3 + 2];
1005 void* exception = NULL;
1007 _dll_handle->RawSample_getLeftEye(
1013 checkException(exception, *_dll_handle);
1023 void* exception = NULL;
1025 _dll_handle->RawSample_getRightEye(
1031 checkException(exception, *_dll_handle);
1041 void* exception = NULL;
1043 _dll_handle->RawSample_getAngles(
1050 checkException(exception, *_dll_handle);
1058 void* exception = NULL;
1060 const int result = _dll_handle->RawSample_getID(
1064 checkException(exception, *_dll_handle);
1072 void* exception = NULL;
1074 const int result = _dll_handle->RawSample_getFrameID(
1078 checkException(exception, *_dll_handle);
1087 void* exception = NULL;
1089 const int result = _dll_handle->RawSample_getType(
1093 checkException(exception, *_dll_handle);
1103 void* exception = NULL;
1107 _dll_handle->RawSample_getFaceCutRectangle(
1113 checkException(exception, *_dll_handle);
1115 std::vector<RawSample::Point> result(4);
1116 for(
int i = 0; i < 4; ++i)
1118 result[i].x = corners[i * 2 + 0];
1119 result[i].y = corners[i * 2 + 1];
1128 std::ostream &binary_stream,
1132 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1142 int32_t width, height;
1143 std::ostringstream stream;
1144 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(stream);
1146 void* exception = NULL;
1148 _dll_handle->RawSample_cutFaceImage(
1150 &binary_stream_wrap,
1151 pbio::stl_wraps::WrapOStream::write_func,
1159 checkException(exception, *_dll_handle);
1165 (
unsigned char*) stream.str().c_str(),
1166 stream.str().size());
1173 pbio::stl_wraps::WrapOStream &binary_stream,
1177 void* exception = NULL;
1181 _dll_handle->RawSample_cutFaceImage(
1184 pbio::stl_wraps::WrapOStream::write_func,
1192 checkException(exception, *_dll_handle);
1199 std::ostream &binary_stream,
1203 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1215 pbio::stl_wraps::WrapOStream &binary_stream,
1219 void* exception = NULL;
1221 const RawImage::CapiData cdata = original_image.makeCapiData();
1223 _dll_handle->RawSample_cutFaceImage_original_raw_image_with_crop(
1230 cdata.crop_info_offset_x,
1231 cdata.crop_info_offset_y,
1232 cdata.crop_info_data_image_width,
1233 cdata.crop_info_data_image_height,
1235 pbio::stl_wraps::WrapOStream::write_func,
1240 checkException(exception, *_dll_handle);
1246 std::ostream &binary_stream,
1249 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1251 save(binary_stream_wrap, format);
1256 pbio::stl_wraps::WrapOStream &binary_stream,
1259 void* exception = NULL;
1261 _dll_handle->RawSample_save(
1264 pbio::stl_wraps::WrapOStream::write_func,
1268 checkException(exception, *_dll_handle);
1276 void* exception = NULL;
1278 const bool result = _dll_handle->RawSample_hasOriginalImage(
1282 checkException(exception, *_dll_handle);
1290 void* exception = NULL;
1292 const float result = _dll_handle->RawSample_getScore(
1296 checkException(exception, *_dll_handle);
1305 void* exception = NULL;
1307 const float result = _dll_handle->RawSample_getFaceVisibilityScore(
1311 checkException(exception, *_dll_handle);
1323 void const* &data)
const
1325 int32_t rows_, cols_, format_;
1327 void* exception = NULL;
1329 _dll_handle->RawSample_getOriginalImage(
1337 checkException(exception, *_dll_handle);
1348 void* exception = NULL;
1350 pbio::facerec::RawSampleImpl*
const raw_sampl_impl =
1351 _dll_handle->RawSample_downscaleToPreferredSize(
1355 checkException(exception, *_dll_handle);
1357 return RawSample::Ptr::make(_dll_handle, raw_sampl_impl);
1360 #ifndef WITHOUT_PROCESSING_BLOCK
1364 void* exception = NULL;
1366 HContext* handle = _dll_handle->RawSample_toContext(
1370 checkException(exception, *_dll_handle);
1379 pbio::stl_wraps::WrapOStream &binary_stream,
1380 const double space_translation_x,
1381 const double space_translation_y,
1382 const double space_scale)
const
1384 void* exception = NULL;
1386 _dll_handle->RawSample_save_without_image(
1389 pbio::stl_wraps::WrapOStream::write_func,
1390 space_translation_x,
1391 space_translation_y,
1395 checkException(exception, *_dll_handle);
1400 std::ostream &binary_stream,
1401 const double space_translation_x,
1402 const double space_translation_y,
1403 const double space_scale)
const
1405 pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
1409 space_translation_x,
1410 space_translation_y,
1415 void* RawSample::getPtr()
const
1425 #endif // __PBIO_API__PBIO__RAW_SAMPLE_H_
int width
Width of the rectangle.
Definition: Rectangle.h:47
RawImage cutFaceRawImage(RawImage::Format color_model, FaceCutType cut_type) const
Crop face in RawImage format (with raw pixels). Thread-safe.
Definition: RawSample.h:1138
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:1100
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
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
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
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
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:1319
JPEG (lossy compression).
Definition: RawSample.h:101
float getFaceVisibilityScore() const
Get the score of face visibility. Thread-safe.
Definition: RawSample.h:1303
std::vector< Point > getLandmarks() const
Get anthropometric landmarks. Only frontal samples. Thread-safe.
Definition: RawSample.h:945
The face is right-profile-oriented.
Definition: RawSample.h:86
float x
X coordinate.
Definition: Point.h:19
Definition: Recognizer.h:64
Interface object for creating and matching templates.
Definition: Recognizer.h:37
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
Angles getAngles() const
Get a face orientation. Only frontal samples. Thread-safe.
Definition: RawSample.h:1037
SampleType getType() const
Get a sample type. Thread-safe.
Definition: RawSample.h:1085
ISO/IEC 19794-5 Full Frontal (for ID, travel documents) (only frontal sample type).
Definition: RawSample.h:144
Rectangle getRectangle() const
Get a face bounding rectangle. Thread-safe.
Definition: RawSample.h:924
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
int height
Height of the rectangle.
Definition: Rectangle.h:54
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:1245
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:1378
float yaw
Yaw angle in degrees.
Definition: RawSample.h:180
pbio::Rectangle Rectangle
Rectangle in an image.
Definition: RawSample.h:159
Definition: SmartPtr.h:84
std::vector< Point > getIrisLandmarks() const
Get the characteristic points of the eyes. Only frontal samples. Thread-safe.
Definition: RawSample.h:973
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
Point getRightEye() const
Get a point of the right eye. Only frontal samples. Thread-safe.
Definition: RawSample.h:1019
Interface object used to estimate sample quality.
Definition: QualityEstimator.h:41
int getFrameID() const
Get an ID of the frame, in which this RawSample is detected (for samples made with VideoWorker)...
Definition: RawSample.h:1070
Interface object for detecting or tracking of faces in the images or video sequences.
Definition: Capturer.h:16
Face orientation angles.
Definition: RawSample.h:173
VideoWorker is an interface object for tracking, processing and matching faces on multiple video stre...
Definition: VideoWorker.h:105
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
pbio::Context toContext() const
will transform RawSample into a container-Context
Definition: RawSample.h:1362
FaceCutType
Face cropping types.
Definition: RawSample.h:130
float roll
Roll angle in degrees.
Definition: RawSample.h:194
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:51
Point getLeftEye() const
Get a point of the left eye. Only frontal samples. Thread-safe.
Definition: RawSample.h:1001
The face is left-profile-oriented.
Definition: RawSample.h:79
float pitch
Pitch angle in degrees.
Definition: RawSample.h:187
int y
Y coordinate of the top-left corner.
Definition: Rectangle.h:40
float getScore() const
Get the score of the detected face (for samples made with supported single-shot Capturers). Thread-safe.
Definition: RawSample.h:1288
Definition: FacerecService.mm:79
RawSample::Ptr downscaleToPreferredSize() const
Clone this RawSample with an internal face image downscaled to suitable size and without an original ...
Definition: RawSample.h:1346
int getID() const
Get a face ID. Thread-safe.
Definition: RawSample.h:1056
Format
Format of image data.
Definition: IRawImage.h:46
PNG (lossless compression).
Definition: RawSample.h:108
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:1127
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
bool hasOriginalImage() const
Does the sample store the original image (true for samples made with VideoWorker with enabled store_o...
Definition: RawSample.h:1274
Interface object for estimation of emotions.
Definition: EmotionsEstimator.h:41