9 #ifndef __PBIO_API__PBIO__CAMERACALIBRATOR_H_ 
   10 #define __PBIO_API__PBIO__CAMERACALIBRATOR_H_ 
   16 #include "ComplexObject.h" 
   18 #include "ExceptionCheck.h" 
   23 #include "stl_wraps_impls/WrapIStreamImpl.h" 
   24 #include "stl_wraps_impls/WrapOStreamImpl.h" 
   48     typedef LightSmartPtr<CameraCalibrator>::tPtr 
Ptr;
 
  161         const CalibrationSettings settings);
 
  206         bool *pattern_accepted,
 
  207         std::vector<Point> *pattern_points);
 
  243     std::vector<Point> 
getTip();
 
  280         const int max_used_patterns_count,
 
  281         float *reprojection_error);
 
  323         const float alpha) 
const;
 
  347         std::ostream &binary_stream) 
const;
 
  368         pbio::stl_wraps::WrapOStream &binary_stream) 
const;
 
  391         std::istream &binary_stream);
 
  413         pbio::stl_wraps::WrapIStream &binary_stream);
 
  419         const DHPtr &dll_handle,
 
  441 CameraCalibrator::CameraCalibrator(
 
  442     const DHPtr &dll_handle,
 
  444 ComplexObject(dll_handle, impl)
 
  458     void* exception = NULL;
 
  460     _dll_handle->CameraCalibrator_initCalibration(
 
  476     checkException(exception, *_dll_handle);
 
  487     bool *pattern_accepted,
 
  488     std::vector<Point> *pattern_points)
 
  491     int32_t pattern_found_i = 0;
 
  492     int32_t pattern_accepted_i = 0;
 
  494     std::vector<float> pattern_points_f;
 
  496     if(_pattern_height > 0 && _pattern_width > 0)
 
  497         pattern_points_f.resize(_pattern_height * _pattern_width * 2);
 
  499     void* exception = NULL;
 
  501     const RawImage::CapiData cdata = image.makeCapiData();
 
  503     _dll_handle->CameraCalibrator_addImage_with_crop(
 
  512         cdata.crop_info_offset_x,
 
  513         cdata.crop_info_offset_y,
 
  514         cdata.crop_info_data_image_width,
 
  515         cdata.crop_info_data_image_height,
 
  519         pattern_points_f.empty() ?
 
  521             &pattern_points_f[0],
 
  524     checkException(exception, *_dll_handle);
 
  528         *pattern_found = pattern_found_i;
 
  531         *pattern_accepted = pattern_accepted_i;
 
  535         pattern_points->resize(_pattern_width * _pattern_height);
 
  536         for(
size_t i = 0; i < pattern_points->size(); ++i)
 
  538             pattern_points->at(i).x = pattern_points_f[i * 2 + 0];
 
  539             pattern_points->at(i).y = pattern_points_f[i * 2 + 1];
 
  548     void* exception = NULL;
 
  550     const float progress = _dll_handle->CameraCalibrator_getPatternSpaceCoverProgress(
 
  554     checkException(exception, *_dll_handle);
 
  563     std::vector<float> pattern_points_f;
 
  565     if(_pattern_height > 0 && _pattern_width > 0)
 
  566         pattern_points_f.resize(_pattern_height * _pattern_width * 2);
 
  568     void* exception = NULL;
 
  570     const int32_t tip_ready = _dll_handle->CameraCalibrator_getTip(
 
  572         pattern_points_f.empty() ?
 
  574             &pattern_points_f[0],
 
  577     checkException(exception, *_dll_handle);
 
  579     std::vector<Point> pattern_points;
 
  583         pattern_points.resize(_pattern_width * _pattern_height);
 
  585         for(
size_t i = 0; i < pattern_points.size(); ++i)
 
  587             pattern_points[i].x = pattern_points_f[i * 2 + 0];
 
  588             pattern_points[i].y = pattern_points_f[i * 2 + 1];
 
  592     return pattern_points;
 
  599     const int max_used_patterns_count,
 
  600     float *reprojection_error_ptr)
 
  602     void* exception = NULL;
 
  604     const float reprojection_error = _dll_handle->CameraCalibrator_calibrate(
 
  606         max_used_patterns_count,
 
  609     checkException(exception, *_dll_handle);
 
  611     if(reprojection_error < 0 - 0.1f)
 
  614     if(reprojection_error_ptr)
 
  615         *reprojection_error_ptr = reprojection_error;
 
  624     const float alpha)
 const 
  626     pbio::image::Image::Ptr result(
 
  627         new pbio::image::Image(
 
  632     void* exception = NULL;
 
  634     const RawImage::CapiData cdata = image.makeCapiData();
 
  636     _dll_handle->CameraCalibrator_undistort_with_crop(
 
  645         cdata.crop_info_offset_x,
 
  646         cdata.crop_info_offset_y,
 
  647         cdata.crop_info_data_image_width,
 
  648         cdata.crop_info_data_image_height,
 
  654     checkException(exception, *_dll_handle);
 
  663     std::ostream &binary_stream)
 const 
  665     pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
 
  672     pbio::stl_wraps::WrapOStream &binary_stream)
 const 
  674     void* exception = NULL;
 
  676     _dll_handle->CameraCalibrator_saveCameraParameters(
 
  679         pbio::stl_wraps::WrapOStream::write_func,
 
  682     checkException(exception, *_dll_handle);
 
  688     std::istream &binary_stream)
 
  690     pbio::stl_wraps::WrapIStreamImpl binary_stream_wrap(binary_stream);
 
  697     pbio::stl_wraps::WrapIStream &binary_stream)
 
  699     void* exception = NULL;
 
  701     _dll_handle->CameraCalibrator_loadCameraParameters(
 
  704         pbio::stl_wraps::WrapIStream::read_func,
 
  707     checkException(exception, *_dll_handle);
 
  713 #endif  // __PBIO_API__PBIO__CAMERACALIBRATOR_H_ 
HeavySmartPtr< IRawImage >::tPtr Ptr
Псевдоним для типа умного указателя на IRawImage. 
Definition: IRawImage.h:39
int image_height
Высота изображения для калибровки. 
Definition: CameraCalibrator.h:82
Структура, предоставляющая данные изображения в "сыром" формате и опциональную информацию для обрезки...
Definition: RawImage.h:28
Интерфейсный объект для создания других интерфейсных объектов. 
Definition: FacerecService.h:64
PatternType pattern_type
Тип калибровочного шаблона. 
Definition: CameraCalibrator.h:89
LightSmartPtr< CameraCalibrator >::tPtr Ptr
Псевдоним для типа умного указателя на CameraCalibrator. 
Definition: CameraCalibrator.h:48
std::vector< Point > getTip()
Получить подсказку о требуемой позиции калибровочного шаблона на изображении для лучшего покрытия...
Definition: CameraCalibrator.h:561
int width
Ширина изображения. 
Definition: RawImage.h:109
Настройки калибровки. 
Definition: CameraCalibrator.h:56
Format format
Формат данных изображения. 
Definition: RawImage.h:125
Error - класс исключений, выбрасываемых при возникновении ошибок. 
Definition: CameraCalibrator.h:66
bool fix_aspect_ratio
Зафиксировать соотношение сторон. 
Definition: CameraCalibrator.h:110
int pattern_width
Ширина калибровочного шаблона. 
Definition: CameraCalibrator.h:96
bool calib_fix_principal_point
Зафиксировать принципиальную точку в центре изображения. 
Definition: CameraCalibrator.h:124
void addImage(const RawImage image, bool *pattern_found, bool *pattern_accepted, std::vector< Point > *pattern_points)
Поиск калибровочного шаблона на изображении и его сохранение. 
Definition: CameraCalibrator.h:484
IRawImage::Ptr undistort(const RawImage image, const float alpha) const 
Скорректировать дисторсию изображения, используя откалиброванные или загруженные параметры камеры...
Definition: CameraCalibrator.h:622
Definition: CameraCalibrator.h:67
bool calib_zero_tangent_dist
Считать тангенциальную дисторсию нулевой. 
Definition: CameraCalibrator.h:117
int height
Высота изображения. 
Definition: RawImage.h:117
int pattern_height
Высота калибровочного шаблона. 
Definition: CameraCalibrator.h:103
Definition: CameraCalibrator.h:65
void loadCameraParameters(std::istream &binary_stream)
Загрузить откалиброванные параметры. Формат платформонезависимый. 
Definition: CameraCalibrator.h:687
Интерфейсный объект для калибровки камеры и коррекции дисторсии. 
Definition: CameraCalibrator.h:39
int image_width
Ширина изображения для калибровки. 
Definition: CameraCalibrator.h:75
float getPatternSpaceCoverProgress() const 
Оценка покрытия пространства поз калибровочного шаблона для более точной калибровки. 
Definition: CameraCalibrator.h:546
Definition: FacerecService.mm:79
bool rational_distortion_model
Использовать rational distortion model. 
Definition: CameraCalibrator.h:131
PatternType
Типы калибровочных шаблонов. 
Definition: CameraCalibrator.h:63
void initCalibration(const CalibrationSettings settings)
Инициализация процесса калибровки. Ранее принятые шаблоны будут удалены. 
Definition: CameraCalibrator.h:452
bool calibrate(const int max_used_patterns_count, float *reprojection_error)
Калибровка камеры. 
Definition: CameraCalibrator.h:598
void saveCameraParameters(std::ostream &binary_stream) const 
Сохранить откалиброванные параметры. Формат платформонезависимый. 
Definition: CameraCalibrator.h:662