ToFCamera.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * TI Voxel Lib component.
  3. *
  4. * Copyright (c) 2014 Texas Instruments Inc.
  5. */
  6. #ifndef VOXEL_TI_TOFCAMERA_H
  7. #define VOXEL_TI_TOFCAMERA_H
  8. #include <ToFCameraBase.h>
  9. #include "ToFFrameGenerator.h"
  10. #include "TI3DToFExports.h"
  11. #define PIX_CNT_MAX_SET_FAILED "pix_cnt_max_set_failed"
  12. #define PIX_CNT_MAX "pix_cnt_max"
  13. #define QUAD_CNT_MAX "quad_cnt_max"
  14. #define SUBFRAME_CNT_MAX "sub_frame_cnt_max"
  15. #define TG_EN "tg_en"
  16. #define BLK_SIZE "blk_size"
  17. #define BLK_HEADER_EN "blk_header_en"
  18. #define OP_CS_POL "op_cs_pol"
  19. #define FB_READY_EN "fb_ready_en"
  20. #define CONFIDENCE_THRESHOLD "confidence_threshold"
  21. #define ILLUM_EN_POL "illum_en_pol"
  22. #define BIN_ROWS_TO_MERGE "rows_to_merge"
  23. #define BIN_COLS_TO_MERGE "cols_to_merge"
  24. #define BIN_ROW_COUNT "bin_row_count"
  25. #define BIN_COLUMN_COUNT "bin_col_count"
  26. #define BINNING_EN "binning_en"
  27. #define ROW_START "row_start"
  28. #define ROW_END "row_end"
  29. #define COL_START "col_start"
  30. #define COL_END "col_end"
  31. #define DEBUG_EN "debug_en"
  32. #define PIXEL_DATA_SIZE "pixel_data_size"
  33. #define OP_DATA_ARRANGE_MODE "op_data_arrange_mode"
  34. #define OP_CLK_FREQ "op_clk_freq"
  35. #define HISTOGRAM_EN "histogram_en"
  36. #define INTG_TIME "intg_time" // Integration time
  37. #define INTG_DUTY_CYCLE "intg_duty_cycle"
  38. #define INTG_DUTY_CYCLE_SET_FAILED "intg_duty_cycle_set_failed"
  39. #define MOD_FREQ1 "mod_freq1" // Modulation frequency for first source (MHz)
  40. #define MOD_FREQ2 "mod_freq2" // Modulation frequency for second source (MHz)
  41. #define VCO_FREQ "vco_freq"
  42. #define MOD_PS1 "mod_ps1"
  43. #define MOD_PS2 "mod_ps2"
  44. #define MOD_M "mod_m"
  45. #define MOD_N "mod_n"
  46. #define MOD_PLL_UPDATE "mod_pll_update"
  47. #define MA "ma"
  48. #define MB "mb"
  49. #define K0 "ka"
  50. #define DEALIAS_EN "dealias_en"
  51. #define DEALIAS_16BIT_OP_ENABLE "dealias_16bit_op_enable"
  52. #define DEALIASED_PHASE_MASK "dealiased_ph_mask"
  53. #define ToF_CALIB_SECT_FREQUENCY "frequency"
  54. #define ToF_CALIB_SECT_CROSS_TALK "cross_talk"
  55. #define ToF_CALIB_SECT_NON_LINEARITY "non_linearity"
  56. #define ToF_CALIB_SECT_TEMPERATURE "temperature"
  57. #define ToF_CALIB_SECT_COMMON_PHASE_OFFSET "common_phase_offset"
  58. #define ToF_CALIB_SECT_PIXELWISE_PHASE_OFFSET "pixelwise_phase_offset"
  59. #define ToF_CALIB_SECT_FREQUENCY_ID 1
  60. #define ToF_CALIB_SECT_CROSS_TALK_ID 2
  61. #define ToF_CALIB_SECT_NON_LINEARITY_ID 3
  62. #define ToF_CALIB_SECT_TEMPERATURE_ID 4
  63. #define ToF_CALIB_SECT_COMMON_PHASE_OFFSET_ID 5
  64. #define ToF_CALIB_SECT_PIXELWISE_PHASE_OFFSET_ID 6
  65. #define PHASE_CORR_ADD "phase_corr_add" // Is the phase correction additive or subtractive?
  66. #define PHASE_CORR_1 "phase_corr_1"
  67. #define PHASE_CORR_2 "phase_corr_2"
  68. #define TILLUM_CALIB "tillum_calib"
  69. #define TSENSOR_CALIB "tsensor_calib"
  70. #define COEFF_ILLUM_1 "coeff_illum_1"
  71. #define COEFF_ILLUM_2 "coeff_illum_2"
  72. #define COEFF_SENSOR_1 "coeff_sensor_1"
  73. #define COEFF_SENSOR_2 "coeff_sensor_2"
  74. #define DISABLE_OFFSET_CORR "disable_offset_corr"
  75. #define DISABLE_TEMP_CORR "disable_temp_corr"
  76. #define CALIB_PREC "calib_prec"
  77. #define ToF_FRAME_TYPE "output_mode"
  78. #define SOFTWARE_RESET "software_reset"
  79. #define SPEED_OF_LIGHT 299792458.0
  80. #define TI_VENDOR_ID 0x0451U
  81. #define UNAMBIGUOUS_RANGE "unambiguous_range"
  82. #define ILLUM_POWER "illum_power"
  83. #define ILLUM_POWER_PERCENTAGE "illum_power_percentage"
  84. namespace Voxel
  85. {
  86. namespace TI
  87. {
  88. // TI's ToF specific handling. This is generic base currently for TinTin and Haddock generation
  89. class TI3DTOF_EXPORT ToFCamera: public ToFCameraBase
  90. {
  91. protected:
  92. bool _init();
  93. virtual bool _processRawFrame(const RawFramePtr &rawFrameInput, RawFramePtr &rawFrameOutput); // here output raw frame will have processed data, like ToF data for ToF cameras
  94. virtual bool _getAmplitudeNormalizingFactor(float &factor);
  95. virtual bool _getDepthScalingFactor(float& factor);
  96. virtual bool _setFrameRate(const FrameRate &r);
  97. virtual bool _getFrameRate(FrameRate &r) const;
  98. virtual bool _getFrameSize(FrameSize &s) const;
  99. virtual bool _setFrameSize(const FrameSize &s);
  100. virtual bool _setFrameSize(const FrameSize &s, bool resetROI);
  101. virtual bool _setStreamerFrameSize(const FrameSize &s) = 0;
  102. virtual bool _getMaximumFrameRate(FrameRate& frameRate, const FrameSize& forFrameSize) const;
  103. virtual bool _getBytesPerPixel(uint &bpp) const;
  104. virtual bool _setBytesPerPixel(const uint &bpp);
  105. virtual bool _getOpDataArrangeMode(int &dataArrangeMode) const;
  106. // Return the resultant modulation frequency. This is mod_freq1 for non-dealiased case and
  107. // gcd(mod_freq1, mod_freq2) for dealiased case
  108. virtual bool _getIlluminationFrequency(float &frequency) const = 0;
  109. virtual bool _getBinning(uint &rowsToMerge, uint &columnsToMerge) const;
  110. virtual bool _setBinning(uint rowsToMerge, uint columnsToMerge, const FrameSize &frameSize);
  111. // Return in MHz
  112. virtual bool _getSystemClockFrequency(uint &frequency) const = 0;
  113. virtual bool _isHistogramEnabled() const = 0;
  114. virtual bool _getToFFrameType(ToFFrameType &frameType) const;
  115. virtual bool _is16BitModeEnabled(bool &mode16Bit);
  116. virtual bool _getDealiasedPhaseMask(int &dealiasedPhaseMask);
  117. virtual bool _getSubFrameCount(int &subframeCount) const;
  118. virtual bool _initStartParams();
  119. virtual bool _applyCalibrationParams() = 0;
  120. virtual bool _getCurrentProfileRegisterName(String &name) = 0;
  121. virtual bool _getCurrentProfileID(int& id);
  122. virtual bool _saveCurrentProfileID(const int id);
  123. virtual bool _reset();
  124. Ptr<ToFFrameGenerator> _tofFrameGenerator;
  125. public:
  126. ToFCamera(const String &name, const String &chipset, DevicePtr device);
  127. // NOTE: Not using the low-level API for getting serial number. USB's serial number is enough
  128. //virtual bool getSerialNumber(String& serialNumber) const;
  129. virtual bool setSerialNumber(const String& serialNumber);
  130. virtual ~ToFCamera() {}
  131. friend class IntegrationTimeParameter;
  132. };
  133. class TI3DTOF_EXPORT PhaseCorrectionAdditiveParameter: public BoolParameter
  134. {
  135. public:
  136. PhaseCorrectionAdditiveParameter(bool value, RegisterProgrammer &programmer):
  137. BoolParameter(programmer, PHASE_CORR_ADD, 0, 0, 0, {"Subtract common-phase correction to phase.", "Add common-phase correction from phase."},
  138. {"Subtract Correction", "Add Correction"}, value, "Common-phase Correction Type", "This read-only boolean indicates whether common-phase correction is additive or subtractive", Parameter::IO_READ_ONLY)
  139. {}
  140. };
  141. }
  142. }
  143. #endif // VOXEL_TI_TOFCAMERA_H