3DiVi Face SDK  3.21.0
 Указатель Классы Пространства имен Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Свойства Группы
Capturer.h
См. документацию.
1 
9 #ifndef __PBIO_API__PBIO__CAPTURER_H_
10 #define __PBIO_API__PBIO__CAPTURER_H_
11 
12 #include <sstream>
13 #include <vector>
14 
15 
16 #include "ComplexObject.h"
17 #include "Error.h"
18 #include "RawImage.h"
19 #include "RawSample.h"
20 #include "SmartPtr.h"
21 #include "stl_wraps_impls/WrapOStreamImpl.h"
22 #include "stl_wraps_impls/WrapVectorImpl.h"
23 
24 
25 namespace pbio
26 {
27 
28 class FacerecService;
29 
36 class Capturer : public ComplexObject
37 {
38 public:
39 
45  typedef LightSmartPtr<Capturer>::tPtr Ptr;
46 
53  {
60 
67 
74  };
75 
76 
104  std::vector<RawSample::Ptr> capture(const RawImage image);
105 
141  std::vector<RawSample::Ptr> capture(const unsigned char *data, int data_size);
142 
189  const RawImage image,
190  float left_eye_x,
191  float left_eye_y,
192  float right_eye_x,
193  float right_eye_y);
194 
249  const RawImage image,
250  const std::vector<RawSample::Point> &points);
251 
306  const unsigned char *data,
307  int data_size,
308  float left_eye_x,
309  float left_eye_y,
310  float right_eye_x,
311  float right_eye_y);
312 
375  const unsigned char *data,
376  int data_size,
377  const std::vector<RawSample::Point> &points);
378 
387  void resetHistory();
388 
389 
405  CapturerType getType() const;
406 
428  void setParameter(
429  const std::string parameter,
430  const double value);
431 
432 private:
433 
434  Capturer(
435  const DHPtr &dll_handle,
436  void* impl);
437 
438  friend class FacerecService;
439  friend class object_with_ref_counter<Capturer>;
440 };
441 
442 } // pbio namespace
443 
444 
445 
449 
450 namespace pbio
451 {
452 
453 
454 inline
455 Capturer::Capturer(
456  const DHPtr &dll_handle,
457  void* impl):
458 ComplexObject(dll_handle, impl)
459 {
460  // nothing else
461 }
462 
463 
464 inline
465 std::vector<RawSample::Ptr> Capturer::capture(const RawImage image)
466 {
467  std::vector<void*> void_result;
468 
469  void* exception = NULL;
470 
471  const RawImage::CapiData cdata = image.makeCapiData();
472 
473  _dll_handle->Capturer_capture_raw_image_with_crop(
474  _impl,
475  cdata.data,
476  cdata.width,
477  cdata.height,
478  cdata.format,
479  cdata.with_crop,
480  cdata.crop_info_offset_x,
481  cdata.crop_info_offset_y,
482  cdata.crop_info_data_image_width,
483  cdata.crop_info_data_image_height,
484  &void_result,
485  pbio::stl_wraps::assign_pointers_vector_func,
486  &exception);
487 
488 
489  checkException(exception, *_dll_handle);
490 
491 
492  std::vector<RawSample::Ptr> result(void_result.size());
493 
494  for(size_t i = 0; i < void_result.size(); ++i)
495  result[i] = RawSample::Ptr::make(_dll_handle, void_result[i]);
496 
497  return result;
498 }
499 
500 inline
501 std::vector<RawSample::Ptr> Capturer::capture(const unsigned char *data, int data_size)
502 {
503  std::vector<void*> void_result;
504 
505  void* exception = NULL;
506 
507  _dll_handle->Capturer_capture_encoded_image(
508  _impl,
509  data,
510  data_size,
511  &void_result,
512  pbio::stl_wraps::assign_pointers_vector_func,
513  &exception);
514 
515 
516  checkException(exception, *_dll_handle);
517 
518 
519  std::vector<RawSample::Ptr> result(void_result.size());
520 
521  for(size_t i = 0; i < void_result.size(); ++i)
522  result[i] = RawSample::Ptr::make( _dll_handle, void_result[i] );
523 
524  return result;
525 }
526 
527 inline
529  const RawImage image,
530  float left_eye_x,
531  float left_eye_y,
532  float right_eye_x,
533  float right_eye_y)
534 {
535  void* exception = NULL;
536 
537  const RawImage::CapiData cdata = image.makeCapiData();
538 
539  void* const result_impl = _dll_handle->Capturer_manualCapture_raw_image_eyes_points_with_crop(
540  _impl,
541  cdata.data,
542  cdata.width,
543  cdata.height,
544  cdata.format,
545 
546  cdata.with_crop,
547  cdata.crop_info_offset_x,
548  cdata.crop_info_offset_y,
549  cdata.crop_info_data_image_width,
550  cdata.crop_info_data_image_height,
551 
552  left_eye_x,
553  left_eye_y,
554  right_eye_x,
555  right_eye_y,
556  &exception);
557 
558  checkException(exception, *_dll_handle);
559 
560  return RawSample::Ptr::make(_dll_handle, result_impl);
561 }
562 
563 inline
565  const RawImage image,
566  const std::vector<RawSample::Point> &points)
567 {
568  void* exception = NULL;
569 
570  std::vector<float> points_data(points.size() * 3);
571  for(size_t i = 0; i < points.size(); ++i)
572  {
573  points_data[i * 3 + 0] = points[i].x;
574  points_data[i * 3 + 1] = points[i].y;
575  points_data[i * 3 + 2] = points[i].z;
576  }
577 
578  const RawImage::CapiData cdata = image.makeCapiData();
579 
580  void* const result_impl = _dll_handle->Capturer_manualCapture_raw_image_points_vector_with_crop(
581  _impl,
582  cdata.data,
583  cdata.width,
584  cdata.height,
585  cdata.format,
586 
587  cdata.with_crop,
588  cdata.crop_info_offset_x,
589  cdata.crop_info_offset_y,
590  cdata.crop_info_data_image_width,
591  cdata.crop_info_data_image_height,
592 
593  points_data.empty() ? NULL : points_data.data(),
594  points.size(),
595  &exception);
596 
597  checkException(exception, *_dll_handle);
598 
599  return RawSample::Ptr::make(_dll_handle, result_impl);
600 }
601 
602 inline
604  const unsigned char *data,
605  int data_size,
606  float left_eye_x,
607  float left_eye_y,
608  float right_eye_x,
609  float right_eye_y)
610 {
611  void* exception = NULL;
612 
613  void* const result_impl = _dll_handle->Capturer_manualCapture_encoded_image_eyes_points(
614  _impl,
615  data,
616  data_size,
617  left_eye_x,
618  left_eye_y,
619  right_eye_x,
620  right_eye_y,
621  &exception);
622 
623  checkException(exception, *_dll_handle);
624 
625  return RawSample::Ptr::make(_dll_handle, result_impl);
626 }
627 
628 inline
630  const unsigned char *data,
631  int data_size,
632  const std::vector<RawSample::Point> &points)
633 {
634  void* exception = NULL;
635 
636  std::vector<float> points_data(points.size() * 3);
637  for(size_t i = 0; i < points.size(); ++i)
638  {
639  points_data[i * 3 + 0] = points[i].x;
640  points_data[i * 3 + 1] = points[i].y;
641  points_data[i * 3 + 2] = points[i].z;
642  }
643 
644  void* const result_impl = _dll_handle->Capturer_manualCapture_encoded_image_points_vector(
645  _impl,
646  data,
647  data_size,
648  points_data.empty() ? NULL : points_data.data(),
649  points.size(),
650  &exception);
651 
652  checkException(exception, *_dll_handle);
653 
654  return RawSample::Ptr::make(_dll_handle, result_impl);
655 }
656 
657 
658 inline
660 {
661  void* exception = NULL;
662 
663  _dll_handle->Capturer_resetHistory(
664  _impl,
665  &exception);
666 
667  checkException(exception, *_dll_handle);
668 }
669 
670 inline
672 {
673  void* exception = NULL;
674 
675  const int result = _dll_handle->Capturer_getType(
676  _impl,
677  &exception);
678 
679  checkException(exception, *_dll_handle);
680 
681  return (CapturerType) result;
682 }
683 
684 inline
686  const std::string parameter,
687  const double value)
688 {
689  void* exception = NULL;
690 
691  _dll_handle->Capturer_setParameter(
692  _impl,
693  parameter.c_str(),
694  value,
695  &exception);
696 
697  checkException(exception, *_dll_handle);
698 }
699 
700 
701 
702 } // pbio namespace
703 
704 #endif // __PBIO_API__PBIO__CAPTURER_H_
Детектирует только лица в профиль, смотрящие вправо.
Definition: Capturer.h:73
Структура, предоставляющая данные изображения в "сыром" формате и опциональную информацию для обрезки...
Definition: RawImage.h:28
void resetHistory()
Удалить из истории все кадры и лица (только для трекеров).
Definition: Capturer.h:659
Интерфейсный объект для создания других интерфейсных объектов.
Definition: FacerecService.h:64
void setParameter(const std::string parameter, const double value)
Изменить значение параметра в runtime.
Definition: Capturer.h:685
CapturerType getType() const
Получить тип детектора.
Definition: Capturer.h:671
LightSmartPtr< Capturer >::tPtr Ptr
Псевдоним для типа умного указателя на Capturer.
Definition: Capturer.h:45
Детектирует только лица в профиль, смотрящие влево.
Definition: Capturer.h:66
LightSmartPtr< RawSample >::tPtr Ptr
Псевдоним для типа умного указателя на RawSample.
Definition: RawSample.h:58
Error - класс исключений, выбрасываемых при возникновении ошибок.
RawSample - Интерфейсный объект, хранящий образец лица.
Детектирует только лица в анфас.
Definition: Capturer.h:59
Интерфейсный объект для детекции и трекинга лиц на изображениях или видеопоследовательностях.
Definition: Capturer.h:36
SmartPtr.
RawSample::Ptr manualCapture(const RawImage image, float left_eye_x, float left_eye_y, float right_eye_x, float right_eye_y)
Создать сэмпл вручную с отмеченными позициями глаз.
Definition: Capturer.h:528
CapturerType
Типы детекторов (см. также RawSample::SampleType).
Definition: Capturer.h:52
std::vector< RawSample::Ptr > capture(const RawImage image)
Детектировать (и отследить) лица на изображении (кадре видео).
Definition: Capturer.h:465