RVC  1.14.1
a product by RVBUST.
RVC.h
1 // Copyright (c) RVBUST, Inc - All rights reserved.
2 #pragma once
3 
4 #include <assert.h>
5 #include <stdbool.h>
6 #include <stddef.h>
7 #include <stdint.h>
8 
9 #include <string>
10 #include <vector>
11 
12 // Define EXPORTED for any platform
13 #if defined _WIN32 || defined __CYGWIN__
14 #ifdef RVC_WIN_EXPORT
15 #ifdef __GNUC__
16 #define RVC_EXPORT __attribute__((dllexport))
17 #else
18 #define RVC_EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
19 #endif
20 #else
21 #ifdef __GNUC__
22 #define RVC_EXPORT __attribute__((dllimport))
23 #else
24 #define RVC_EXPORT __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
25 #endif
26 #endif
27 #define RVC_NOT_EXPORT
28 #else
29 #if __GNUC__ >= 4
30 #define RVC_EXPORT __attribute__((visibility("default")))
31 #define RVC_NOT_EXPORT __attribute__((visibility("hidden")))
32 #else
33 #define RVC_EXPORT
34 #define RVC_NOT_EXPORT
35 #endif
36 #endif
37 
42 namespace RVC {
47 typedef uint32_t HandleID;
52 struct RVC_EXPORT Handle {
57  Handle() : sid(0), gid(0) {}
64  Handle(HandleID sid_, HandleID gid_) : sid(sid_), gid(gid_) {}
70  Handle(const Handle &rhs) : sid(rhs.sid), gid(rhs.gid) {}
78  Handle &operator=(const Handle &rhs) {
79  sid = rhs.sid;
80  gid = rhs.gid;
81  return *this;
82  }
90  inline bool operator==(const Handle &rhs) { return sid == rhs.sid && gid == rhs.gid; }
98  inline bool operator!=(const Handle &rhs) { return sid != rhs.sid || gid != rhs.gid; }
99 
100  HandleID sid;
101  HandleID gid;
102 };
103 
108 struct RVC_EXPORT Size {
113  Size() : width(0), height(0) {}
120  Size(int w, int h) : width(w), height(h) {}
125  union {
126  int32_t width, cols;
127  };
132  union {
133  int32_t height, rows;
134  };
135 };
136 
145 inline bool operator==(const Size &lhs, const Size &rhs) {
146  return lhs.width == rhs.width && lhs.height == rhs.height;
147 }
156 inline bool operator!=(const Size &lhs, const Size &rhs) {
157  return lhs.width != rhs.width || lhs.height != rhs.height;
158 }
159 
164 struct RVC_EXPORT ROI {
169  ROI() : x(0), y(0), width(0), height(0) {}
178  ROI(int x, int y, int w, int h) : x(x), y(y), width(w), height(h) {}
183  int x;
188  int y;
193  int width;
198  int height;
199 };
200 
205 struct RVC_EXPORT ROIRange {
210  int x_step;
215  int y_step;
246 };
247 
256 inline bool operator==(const ROI &lhs, const ROI &rhs) {
257  return lhs.width == rhs.width && lhs.height == rhs.height && lhs.x == rhs.x && lhs.y == rhs.y;
258 }
259 
268 inline bool operator!=(const ROI &lhs, const ROI &rhs) {
269  return lhs.width != rhs.width || lhs.height != rhs.height || lhs.x != rhs.x || lhs.y != rhs.y;
270 }
276 struct RVC_EXPORT ImageType {
277  enum Enum {
278  None = 0,
279  Mono8 = 1,
280  RGB8 = 2,
281  BGR8 = 3,
282  };
289  static const char *ToString(ImageType::Enum type);
296  static size_t GetPixelSize(ImageType::Enum type);
297 };
298 
303 struct RVC_EXPORT Image {
313  static Image Create(ImageType::Enum it, const Size sz, unsigned char *data = nullptr, bool own_data = true);
314  static Image CreateFromFile(const char *addr);
321  static void Destroy(Image img, bool no_reuse = true);
325  Image Clone() const;
332  bool IsValid() const;
338  Size GetSize() const;
344  ImageType::Enum GetType() const;
350  unsigned char *GetDataPtr() const;
356  const unsigned char *GetDataConstPtr() const;
365  bool SaveImage(const char *addr) const;
371 };
372 
377 struct RVC_EXPORT DepthMap {
386  static DepthMap Create(const Size sz, double *data = nullptr, bool own_data = true);
387 
394  static void Destroy(DepthMap depthmap, bool no_reuse = true);
395 
402  bool IsValid();
408  Size GetSize();
414  double *GetDataPtr();
420  const double *GetDataConstPtr();
421 
431  bool SaveDepthMap(const char *address, bool is_m = true);
432 
438 };
439 
440 struct RVC_EXPORT ConfidenceMap {
450  static ConfidenceMap Create(const Size sz, double *data = nullptr, bool own_data = true);
451 
458  static void Destroy(ConfidenceMap confidencemap, bool no_reuse = true);
459 
466  bool IsValid();
467 
473  Size GetSize();
479  double *GetDataPtr();
485  const double *GetDataConstPtr();
486 
492 };
493 
498 struct RVC_EXPORT PointMapType {
504  enum Enum {
505  None = 0,
506  PointsOnly = 1,
507  PointsNormals = 2,
508  };
515  static const char *ToString(enum Enum e);
516 };
517 
518 struct RVC_EXPORT PointMapUnit {
522  enum Enum {
523  Meter = 0,
524  Millimeter = 1,
525  };
531  static const char *ToString(Enum e);
532 };
533 
538 struct RVC_EXPORT PointMap {
548  static PointMap Create(PointMapType::Enum pmt, const Size size, double *data = nullptr, bool owndata = true);
557  static PointMap CreateFromFile(const char *fileName, const Size sz, const PointMapUnit::Enum unit);
564  static void Destroy(PointMap pm, bool no_reuse = true);
573  bool Save(const char *fileName, const PointMapUnit::Enum unit, const bool isBinary,
574  const Image &rawImage = Image());
581  bool IsValid() const;
587  Size GetSize() const;
593  double *GetPointDataPtr();
599  double *GetNormalDataPtr();
605  const double *GetPointDataConstPtr() const;
611  const double *GetNormalDataConstPtr() const;
612 
624  bool GetPointMapSeperated(double *x, double *y, double *z, const double scale = 1.0);
625 
626  /*
627  * @brief clone the point data
628  * return PointMap
629  */
630 
631  PointMap Clone() const;
637 };
638 
639 struct RVC_EXPORT CorrespondMap {
640  static CorrespondMap Create(const Size sz, double *data = nullptr, bool own_data = true);
641  static void Destroy(CorrespondMap correspondMap, bool no_reuse = true);
642 
643  bool IsValid();
644  Size GetSize();
645  double *GetDataPtr();
646  const double *GetDataConstPtr();
647 
648  Handle m_handle;
649 };
650 
656 RVC_EXPORT int GetLastError();
657 
663 RVC_EXPORT const char *GetVersion();
664 
670 RVC_EXPORT const char *GetLastErrorMessage();
671 
678 enum CameraID {
679  CameraID_NONE = 0,
680  CameraID_0 = 1 << 0,
681  CameraID_1 = 1 << 1,
682  CameraID_2 = 1 << 2,
683  CameraID_3 = 1 << 3,
684  CameraID_Left = CameraID_0,
685  CameraID_Right = CameraID_1,
686  CameraID_Both = CameraID_Left | CameraID_Right,
687  CameraID_Extra = CameraID_2
688 };
689 
695 enum PortType {
696  PortType_NONE = 0,
697  PortType_USB = 1,
698  PortType_GIGE = 2,
699 };
700 
709  NetworkType_DHCP = 0,
710  NetworkType_STATIC = 1,
711 };
712 
719  ProjectorColor_None = 0,
720  ProjectorColor_Red = 1,
721  ProjectorColor_Green = 2,
722  ProjectorColor_Blue = 4,
723  ProjectorColor_White = 8,
724  ProjectorColor_ALL = ProjectorColor_Red | ProjectorColor_Green | ProjectorColor_Blue | ProjectorColor_White,
725 };
726 
732  ProtectiveCoverStatus_Unknown = 0,
733  ProtectiveCoverStatus_Closed = 1,
734  ProtectiveCoverStatus_Closing = 2,
735  ProtectiveCoverStatus_Open = 3,
736  ProtectiveCoverStatus_Opening = 4,
737 };
738 
744  BalanceSelector_None = 0,
745  BalanceSelector_Red,
746  BalanceSelector_Green,
747  BalanceSelector_Blue,
748 };
749 
755  NetworkDevice_LightMachine = 0,
756  NetworkDevice_LeftCamera = 1,
757  NetworkDevice_RightCamera = 2,
758  NetworkDevice_ExtraCamera = 3,
759 };
760 
767  NetworkDeviceStatus_OK,
768  NetworkDeviceStatus_Not_Reachable,
769  NetworkDeviceStatus_In_Use,
770  NetworkDeviceStatus_Conflict,
771 };
772 
779  CaptureMode_Fast = 1 << 0,
780  CaptureMode_Normal = 1 << 1,
781  CaptureMode_Ultra = 1 << 2,
782  CaptureMode_Robust = 1 << 3, // [deprecated] CaptureMode_Robust is deprecated! Use scan_times instead.
783  CaptureMode_AntiInterReflection = 1 << 4,
784  CaptureMode_SwingLineScan = 1 << 5,
785  CaptureMode_FixedLineScan = 1 << 6,
786  CaptureMode_LineArrayShift = 1 << 7,
787  CaptureMode_All = CaptureMode_Fast | CaptureMode_Normal | CaptureMode_Ultra | CaptureMode_Robust |
788  CaptureMode_AntiInterReflection | CaptureMode_SwingLineScan | CaptureMode_FixedLineScan |
789  CaptureMode_LineArrayShift,
790 };
791 
807 struct RVC_EXPORT DeviceInfo {
808  char name[32];
809  char sn[32];
810  char factroydate[32];
811  char port[32];
812  enum PortType type;
813  enum CameraID cameraid;
814  int boardmodel;
815  bool support_x2;
816  enum ProjectorColor support_color;
817  int workingdist_near_mm;
818  int workingdist_far_mm;
819  char firmware_version[128];
820  enum CaptureMode support_capture_mode;
821  bool support_x1;
822  bool support_protective_cover;
823  bool support_extra;
824 };
825 
830 struct RVC_EXPORT Device {
836  static void Destroy(Device d);
843  bool IsValid() const;
848  void Print() const;
856  bool GetDeviceInfo(DeviceInfo *pinfo);
867  int SetNetworkConfig(enum NetworkDevice d, NetworkType type, const char *ip, const char *netMask,
868  const char *gateway);
880  int GetNetworkConfig(enum NetworkDevice d, NetworkType *type, char *ip, char *netMask, char *gateway, int *status);
888  bool UpgradeFirmware(const char *device_firmware_path, const char *config_data_path);
895  bool IsFirmwareMatch(void);
901 };
902 
908 struct RVC_EXPORT SystemListDeviceType {
913  enum Enum {
914  None = 0,
915  USB = 1 << 0,
916  GigE = 1 << 1,
917  All = USB | GigE,
918  };
925  static const char *ToString(const SystemListDeviceType::Enum e);
926 };
927 
934 RVC_EXPORT bool SystemInit();
941 RVC_EXPORT bool SystemIsInited();
946 RVC_EXPORT void SystemShutdown();
947 
948 
960 RVC_EXPORT int SystemListDevices(Device *pdevices, size_t size, size_t *actual_size,
961  SystemListDeviceType::Enum opt = SystemListDeviceType::All);
962 
969 RVC_EXPORT Device SystemFindDevice(const char *serialNumber);
970 
976 RVC_EXPORT void SystemSetLoggerName(const char *loggerName);
977 
978 
979 
980 enum CameraTempSelector {
981  CameraTempSelector_Camera,
982  CameraTempSelector_CoreBoard,
983  CameraTempSelector_FpgaCore,
984  CameraTempSelector_Framegrabberboard,
985  CameraTempSelector_Sensor,
986  CameraTempSelector_SensorBoard,
987 };
988 
989 enum SmoothnessLevel { SmoothnessLevel_Off, SmoothnessLevel_Weak, SmoothnessLevel_Normal, SmoothnessLevel_Strong };
990 
991 // UserPtr
992 typedef void *UserPtr;
993 
998 struct RVC_EXPORT X1 {
1010  calc_normal = false;
1011  transform_to_camera = true;
1012  use_auto_noise_removal = true;
1013  noise_removal_distance = 0;
1014  noise_removal_point_number = 40;
1015  light_contrast_threshold = 3;
1016  phase_filter_range = 0;
1017  projector_brightness = 240;
1018  exposure_time_2d = 11;
1019  exposure_time_3d = 11;
1020  gain_2d = 0.f;
1021  gain_3d = 0.f;
1022  hdr_exposure_times = 0;
1023  hdr_exposuretime_content[0] = 11;
1024  hdr_exposuretime_content[1] = 20;
1025  hdr_exposuretime_content[2] = 50;
1026  hdr_gain_3d[0] = 0;
1027  hdr_gain_3d[1] = 0;
1028  hdr_gain_3d[2] = 0;
1029 
1030  hdr_scan_times[0] = 1;
1031  hdr_scan_times[1] = 1;
1032  hdr_scan_times[2] = 1;
1033 
1034  hdr_projector_brightness[0] = 240;
1035  hdr_projector_brightness[1] = 240;
1036  hdr_projector_brightness[2] = 240;
1037  calc_normal_radius = 5;
1038  gamma_2d = 1.f;
1039  gamma_3d = 1.f;
1040  use_projector_capturing_2d_image = true;
1041  smoothness = SmoothnessLevel_Off;
1042  downsample_distance = 0.0;
1043  capture_mode = CaptureMode_Normal;
1044  confidence_threshold = 0;
1045  roi = RVC::ROI();
1046  truncate_z_min = -9999.f;
1047  truncate_z_max = 9999.f;
1048  bilateral_filter_kernal_size = 0;
1049  bilateral_filter_depth_sigma = 0;
1050  bilateral_filter_space_sigma = 0;
1051  scan_times = 1;
1052  use_auto_bilateral_filter = true;
1053  reflection_filter_threshold = 0;
1054  smooth_sigma = 1.75;
1055  enable_2d_in_capture = true;
1056  }
1073  [[deprecated]] int filter_range;
1126  float gain_2d;
1131  float gain_3d;
1141  int hdr_exposuretime_content[3];
1146  float hdr_gain_3d[3];
1147 
1152  int hdr_scan_times[3];
1153 
1158  int hdr_projector_brightness[3];
1162  unsigned int calc_normal_radius;
1167  float gamma_2d;
1172  float gamma_3d;
1182  [[deprecated(
1183  "smoothness has been deprecated in CPU version,use smooth_sigma instead")]] SmoothnessLevel smoothness;
1184 
1190 
1196 
1203 
1211 
1218 
1225 
1231  [[deprecated("Use smooth_sigma instead")]] int bilateral_filter_kernal_size;
1232 
1238  [[deprecated("Use smooth_sigma instead")]] double bilateral_filter_depth_sigma;
1239 
1245  [[deprecated("Use smooth_sigma instead")]] double bilateral_filter_space_sigma;
1246 
1251 
1258  [[deprecated("Use smooth_sigma instead")]] bool use_auto_bilateral_filter;
1259 
1267 
1275 
1280  };
1293  CoordinateSelect_Disabled,
1294  CoordinateSelect_Camera,
1295  CoordinateSelect_CaliBoard,
1296  };
1297 
1299  : coordinate_select(CoordinateSelect_Disabled), transform{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1} {}
1300 
1307 
1312  double transform[16];
1313  };
1314 
1319  Image image;
1320  };
1321 
1326  Image image;
1327  PointMap pointmap;
1328  DepthMap depthmap;
1329  ConfidenceMap confidencemap;
1330  };
1331 
1335  typedef void (*CollectionCallBackPtr)(X1::CollectionCallBackInfo, X1::CaptureOptions, UserPtr);
1336  typedef void (*CalculationCallBackPtr)(X1::CalculationCallBackInfo, X1::CaptureOptions, UserPtr);
1337 
1347  static X1 Create(const Device &d, enum CameraID camid = CameraID_Left);
1355  static void Destroy(X1 &x);
1364  bool IsValid();
1373  bool Open();
1379  void Close();
1388  bool IsOpen();
1397  bool IsPhysicallyConnected();
1404  bool OpenProtectiveCover();
1411  bool OpenProtectiveCoverAsync();
1418  bool CloseProtectiveCover();
1425  bool CloseProtectiveCoverAsync();
1432  bool ResetProtectiveCover();
1433 
1438  bool GetProtectiveCoverStatus(ProtectiveCoverStatus &status);
1449  bool SetCollectionCallBack(X1::CollectionCallBackPtr cb, UserPtr ctx);
1450 
1461  bool SetCalculationCallBack(X1::CalculationCallBackPtr cb, UserPtr ctx);
1462 
1472  bool Capture(const CaptureOptions &opts);
1480  bool Capture();
1489  bool Capture2D(const CaptureOptions &opts);
1497  bool Capture2D();
1505  bool SetBandwidth(float percent);
1506 
1514  bool GetBandwidth(float &percent);
1515 
1523  bool SetCustomTransformation(const CustomTransformOptions &opts);
1531  bool GetCustomTransformation(CustomTransformOptions &opts);
1538  bool SaveEncodedImagesData(const char *addr);
1539 
1545  Image GetImage();
1551  DepthMap GetDepthMap();
1557  PointMap GetPointMap();
1563  ConfidenceMap GetConfidenceMap();
1578  bool GetExtrinsicMatrix(float *matrix);
1593  bool GetIntrinsicParameters(float *instrinsic_matrix, float *distortion);
1600  bool GetProjectorTemperature(float &temperature);
1608  [[deprecated]] bool GetCameraTemperature(CameraTempSelector seletor, float &temperature);
1617  bool SetBalanceRatio(BalanceSelector selector, float value);
1626  bool GetBalanceRatio(BalanceSelector selector, float *value);
1627 
1637  bool GetBalanceRange(BalanceSelector selector, float *min_value, float *max_value);
1638 
1649  bool AutoWhiteBalance(int wb_times = 10, const CaptureOptions &opts = CaptureOptions(),
1650  const RVC::ROI &roi = RVC::ROI());
1651 
1660  bool GetExposureTimeRange(int *min_value, int *max_value);
1661 
1670  bool GetGainRange(float *min_value, float *max_value);
1671 
1680  bool GetGammaRange(float *min_value, float *max_value);
1681 
1689  bool SaveCaptureOptionParameters(const X1::CaptureOptions &opts);
1690 
1698  bool LoadCaptureOptionParameters(X1::CaptureOptions &opts);
1699 
1707  bool GetAutoCaptureSetting(CaptureOptions &opts, const ROI &roi = ROI());
1708 
1718  bool GetAutoHdrCaptureSetting(CaptureOptions &opts, const ROI &roi);
1719 
1723  bool GetAutoNoiseRemovalSetting(CaptureOptions &opts);
1724 
1731  bool LoadSettingFromFile(const char *filename);
1732 
1739  bool SaveSettingToFile(const char *filename);
1740 
1747  bool CheckRoi(ROI roi);
1748 
1754  ROI AutoAdjustRoi(ROI roi = ROI());
1755 
1759  bool GetRoiRange(ROIRange &range);
1760 
1768  bool GetCameraResolution(Size &resolution);
1769 
1775 };
1776 
1777 
1782 struct RVC_EXPORT X2 {
1793  transform_to_camera = CameraID_Left;
1794  projector_brightness = 240;
1795  calc_normal = false;
1796  calc_normal_radius = 5;
1797  use_auto_noise_removal = true;
1798  noise_removal_distance = 0;
1799  noise_removal_point_number = 40;
1800  light_contrast_threshold = 3;
1801  edge_noise_reduction_threshold = 2;
1802  exposure_time_2d = 11;
1803  exposure_time_3d = 11;
1804  gain_2d = 0.f;
1805  gain_3d = 0.f;
1806  hdr_exposure_times = 0;
1807  hdr_exposuretime_content[0] = 11;
1808  hdr_exposuretime_content[1] = 20;
1809  hdr_exposuretime_content[2] = 50;
1810  hdr_gain_3d[0] = 0;
1811  hdr_gain_3d[1] = 0;
1812  hdr_gain_3d[2] = 0;
1813 
1814  hdr_scan_times[0] = 1;
1815  hdr_scan_times[1] = 1;
1816  hdr_scan_times[2] = 1;
1817 
1818  hdr_projector_brightness[0] = 240;
1819  hdr_projector_brightness[1] = 240;
1820  hdr_projector_brightness[2] = 240;
1821  gamma_2d = 1.f;
1822  gamma_3d = 1.f;
1823  projector_color = ProjectorColor_Blue;
1824  use_projector_capturing_2d_image = true;
1825  smoothness = SmoothnessLevel_Off;
1826  downsample_distance = 0.0;
1827  capture_mode = CaptureMode_Normal;
1828  confidence_threshold = 0;
1829  scan_times = 1;
1830 
1831  bilateral_filter_kernal_size = 0;
1832  bilateral_filter_depth_sigma = 0;
1833  bilateral_filter_space_sigma = 0;
1834 
1835  line_scanner_scan_time_ms = 1000;
1836  line_scanner_exposure_time_us = 300;
1837  line_scanner_min_distance = 0;
1838  line_scanner_max_distance = 0;
1839 
1840  correspond2d = false;
1841  line_scanner_laser_position = 65536 / 2;
1842  use_auto_bilateral_filter = true;
1843  reflection_filter_threshold = 0;
1844  smooth_sigma = 1.75;
1845 
1846  roi = RVC::ROI();
1847  enable_2d_in_capture = true;
1848  pointcloud_completion = false;
1849  line_scanner_brightness_threshold = 5;
1850  }
1867 
1871  unsigned int calc_normal_radius;
1872 
1899  float gain_2d;
1904  float gain_3d;
1914  int hdr_exposuretime_content[3];
1919  float hdr_gain_3d[3];
1924  int hdr_projector_brightness[3];
1929  float gamma_2d;
1934  float gamma_3d;
1944 
1949  [[deprecated(
1950  "smoothness has been deprecated in CPU version,use smooth_sigma instead")]] SmoothnessLevel smoothness;
1973 
1979 
1985 
2000  int hdr_scan_times[3];
2001 
2007  [[deprecated("Use smooth_sigma instead")]] int bilateral_filter_kernal_size;
2008 
2014  [[deprecated("Use smooth_sigma instead")]] double bilateral_filter_depth_sigma;
2015 
2021  [[deprecated("Use smooth_sigma instead")]] double bilateral_filter_space_sigma;
2022 
2039 
2045 
2051 
2058  [[deprecated("Use smooth_sigma instead")]] bool use_auto_bilateral_filter;
2059 
2067 
2075 
2083 
2088 
2094 
2106  };
2119  CoordinateSelect_Disabled,
2120  CoordinateSelect_CameraLeft,
2121  CoordinateSelect_CameraRight,
2122  CoordinateSelect_CaliBoard,
2123  CoordinateSelect_CameraExtra,
2124  };
2125 
2127  : coordinate_select(CoordinateSelect_Disabled), transform{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1} {}
2128 
2134 
2139  double transform[16];
2140  };
2141 
2146  Image image[2];
2147  };
2148 
2153  Image image[2];
2154  PointMap pointmap;
2155  DepthMap depthmap;
2156  ConfidenceMap confidencemap;
2157  };
2158 
2162  typedef void (*CollectionCallBackPtr)(X2::CollectionCallBackInfo, X2::CaptureOptions, UserPtr);
2163  typedef void (*CalculationCallBackPtr)(X2::CalculationCallBackInfo, X2::CaptureOptions, UserPtr);
2164 
2171  static X2 Create(const Device &d);
2177  static void Destroy(X2 &x);
2178 
2185  bool IsValid();
2192  bool Open();
2196  void Close();
2203  bool IsOpen();
2210  bool IsPhysicallyConnected();
2217  bool OpenProtectiveCover();
2224  bool OpenProtectiveCoverAsync();
2231  bool CloseProtectiveCover();
2238  bool CloseProtectiveCoverAsync();
2245  bool ResetProtectiveCover();
2250  bool GetProtectiveCoverStatus(ProtectiveCoverStatus &status);
2261  bool SetCollectionCallBack(X2::CollectionCallBackPtr cb, UserPtr ctx);
2272  bool SetCalculationCallBack(X2::CalculationCallBackPtr cb, UserPtr ctx);
2273 
2281  bool Capture(const CaptureOptions &opts);
2288  bool Capture();
2289 
2297  bool StartFixedLineScan(const CaptureOptions &opts);
2298 
2306  bool StartFixedLineScan();
2307 
2313  [[deprecated("Use bool GetFixedLineScanPointMap(PointMap &point_map) instead")]] PointMap
2314  GetFixedLineScanPointMap();
2315 
2322  bool GetFixedLineScanPointMap(PointMap &point_map);
2323 
2330  bool StopFixedLineScan();
2331 
2341  bool Capture2D(const CameraID cid, const CaptureOptions &opts);
2350  bool Capture2D(const CameraID cid);
2358  bool SetBandwidth(float percent);
2359 
2367  bool GetBandwidth(float &percent);
2368 
2376  bool SetCustomTransformation(const CustomTransformOptions &opts);
2377 
2385  bool GetCustomTransformation(CustomTransformOptions &opts);
2386 
2392  PointMap GetPointMap();
2398  Image GetImage(const CameraID cid);
2399 
2405  DepthMap GetDepthMap();
2406 
2412  ConfidenceMap GetConfidenceMap();
2418  CorrespondMap GetCorrespondMap();
2419 
2434  bool GetExtrinsicMatrix(const CameraID cid, float *matrix);
2435 
2452  bool GetIntrinsicParameters(const CameraID cid, float *instrinsicMatrix, float *distortion);
2459  bool GetProjectorTemperature(float &temperature);
2468  [[deprecated]] bool GetCameraTemperature(const CameraID cid, CameraTempSelector seletor, float &temperature);
2479  bool AutoWhiteBalance(int wb_times = 10, const CaptureOptions &opts = CaptureOptions(),
2480  const RVC::ROI &roi = RVC::ROI());
2489  bool GetExposureTimeRange(int *min_value, int *max_value);
2498  bool GetGainRange(float *min_value, float *max_value);
2507  bool GetGammaRange(float *min_value, float *max_value);
2514  bool SaveEncodedImagesData(const char *addr);
2515 
2523  bool SaveCaptureOptionParameters(const X2::CaptureOptions &opts);
2524 
2532  bool LoadCaptureOptionParameters(X2::CaptureOptions &opts);
2533 
2541  bool GetAutoCaptureSetting(CaptureOptions &opts, const ROI &roi = ROI());
2542 
2552  bool GetAutoHdrCaptureSetting(CaptureOptions &opts, const ROI &roi);
2553 
2557  bool GetAutoNoiseRemovalSetting(CaptureOptions &opts);
2558 
2565  bool LoadSettingFromFile(const char *filename);
2566 
2573  bool SaveSettingToFile(const char *filename);
2574 
2581  bool CheckRoi(ROI roi);
2582 
2588  ROI AutoAdjustRoi(ROI roi = ROI());
2589 
2593  bool GetRoiRange(ROIRange &range);
2594 
2602  bool GetCameraResolution(Size &resolution);
2603 
2604  Handle m_handle;
2605 };
2606 
2607 // You can use these to better get and set.
2608 namespace utils {
2609 struct Point3D {
2610  Point3D(double x = 0.0, double y = 0.0, double z = 0.0) : x(x), y(y), z(z) {}
2611  double x;
2612  double y;
2613  double z;
2614 };
2615 
2616 // Helper class upon RVC::PointMap to ease data-access
2617 struct PointMap {
2618  PointMap(RVC::PointMap pm) : pm(pm) {}
2619  Point3D At(int rows, int cols) {
2620  Point3D p;
2621  auto sz = pm.GetSize();
2622  if (!pm.IsValid()) {
2623  printf("RVC::Utils: Invalid");
2624  assert(false);
2625  } else if (rows >= sz.rows || cols >= sz.cols) {
2626  printf("RVC::Utils: Invalid rows and cols(%d, %d), size(%d, %d)", rows, cols, sz.rows, sz.cols);
2627  assert(false);
2628  } else {
2629  double *data = pm.GetPointDataPtr() + 3 * (rows * sz.cols + cols);
2630  p.x = *data++;
2631  p.y = *data++;
2632  p.z = *data++;
2633  }
2634  return p;
2635  }
2636  void Set(int rows, int cols, const Point3D p) {
2637  auto sz = pm.GetSize();
2638  if (!pm.IsValid()) {
2639  printf("RVC::Utils: Invalid");
2640  assert(false);
2641  } else if (rows >= sz.rows || cols >= sz.cols) {
2642  printf("RVC::Utils: Invalid rows and cols(%d, %d), size(%d, %d)", rows, cols, sz.rows, sz.cols);
2643  assert(false);
2644  } else {
2645  double *data = pm.GetPointDataPtr() + 3 * (rows * sz.cols + cols);
2646  *data++ = p.x;
2647  *data++ = p.y;
2648  *data++ = p.z;
2649  }
2650  }
2651 
2652  RVC::Size GetSize() { return pm.GetSize(); }
2653 
2654  RVC::PointMap pm;
2655 };
2656 
2657 template <typename T, typename H>
2658 T _At(H handle, int rows, int cols) {
2659  T v = 0;
2660  RVC::Size sz = handle.GetSize();
2661  if (!handle.IsValid()) {
2662  printf("RVC::Utils: Invalid");
2663  assert(false);
2664  return v;
2665  } else if (rows >= sz.rows || cols >= sz.cols) {
2666  printf("RVC::Utils: Invalid rows and cols(%d, %d), size(%d, %d)", rows, cols, sz.rows, sz.cols);
2667  assert(false);
2668  return v;
2669  } else {
2670  return *(handle.GetDataConstPtr() + rows * sz.cols + cols);
2671  }
2672 }
2673 
2674 template <typename T, typename H>
2675 void _Set(H handle, int rows, int cols, const T v) {
2676  RVC::Size sz = handle.GetSize();
2677  if (!handle.IsValid()) {
2678  printf("RVC::Utils: Invalid");
2679  assert(false);
2680  } else if (rows >= sz.rows || cols >= sz.cols) {
2681  printf("RVC::Utils: Invalid rows and cols(%d, %d), size(%d, %d)", rows, cols, sz.rows, sz.cols);
2682  assert(false);
2683  } else {
2684  *(handle.GetDataPtr() + rows * sz.cols + cols) = v;
2685  }
2686 }
2687 
2688 // Helper class upon RVC::Image to ease data-access
2689 struct Image {
2690  Image(RVC::Image img) : img(img) {}
2691  unsigned char At(int rows, int cols) { return _At<unsigned char>(img, rows, cols); }
2692  void Set(int rows, int cols, const unsigned char v) { _Set(img, rows, cols, v); }
2693  RVC::Size GetSize() { return img.GetSize(); }
2694 
2695  RVC::Image img;
2696 };
2697 
2698 // Helper class upon RVC::ConfidenceMap to ease data-access
2700  ConfidenceMap(RVC::ConfidenceMap cm) : cm(cm) {}
2701  double At(int rows, int cols) { return _At<double>(cm, rows, cols); }
2702  void Set(int rows, int cols, const double v) { _Set(cm, rows, cols, v); }
2703  RVC::Size GetSize() { return cm.GetSize(); }
2704 
2705  RVC::ConfidenceMap cm;
2706 };
2707 
2708 // Helper class upon RVC::DepthMap to ease data-access
2709 struct DepthMap {
2710  DepthMap(RVC::DepthMap dm) : dm(dm) {}
2711  double At(int rows, int cols) { return _At<double>(dm, rows, cols); }
2712  void Set(int rows, int cols, const double v) { _Set(dm, rows, cols, v); }
2713  RVC::Size GetSize() { return dm.GetSize(); }
2714 
2715  RVC::DepthMap dm;
2716 };
2717 } // namespace utils
2718 } // namespace RVC
X1 struct.
Definition: RVC.h:998
int reflection_filter_threshold
Used to remove large-area erroneous point clouds caused by reflections. The higher this value is set...
Definition: RVC.h:1266
BalanceSelector
White balance ratio selector, suport BalanceSelector_Red, BalanceSelector_Green and BalanceSelector_B...
Definition: RVC.h:743
ProtectiveCoverStatus
Protective Cover Status.
Definition: RVC.h:731
CaptureMode capture_mode
control capture mode
Definition: RVC.h:1984
double confidence_threshold
confidence threshold, the point with confindence low then this value will be removed range: [0...
Definition: RVC.h:1202
bool calc_normal
flag Whether calculate 3D points normal vector
Definition: RVC.h:1061
int filter_range
Set the noise filter value. The larger the value, the greater the filtering degree. The default value has been changed to 0 from 1 after v1.6.1.
Definition: RVC.h:1073
RVC_EXPORT void SystemSetLoggerName(const char *loggerName)
Set the name of logger.
int y
start y of Image roi (row index of roi up left corner)
Definition: RVC.h:188
Handle m_handle
RVC Handle.
Definition: RVC.h:370
Options when setting custom transformation.
Definition: RVC.h:2111
int exposure_time_2d
Set the exposure_time 2D value in milliseconds.
Definition: RVC.h:1889
RVC_EXPORT int GetLastError()
Get last error of RVC SDK.
int projector_brightness
Set the projector brightness value.
Definition: RVC.h:1121
CoordinateSelect
base coordinate of custom transformation,default is CoordinateSelect_Disabled
Definition: RVC.h:2118
SmoothnessLevel smoothness
control point map smoothness
Definition: RVC.h:1950
int exposure_time_3d
Set the exposure_time 3D value in milliseconds.
Definition: RVC.h:1894
Capture options.
Definition: RVC.h:1787
Handle m_handle
RVC Handle.
Definition: RVC.h:900
RVC X Device info.
Definition: RVC.h:807
RVC_EXPORT const char * GetVersion()
Get the Version of RVC SDK.
double smooth_sigma
The Gaussian filters are used to smooth points. The larger the smooth_sigma, the smoother the point c...
Definition: RVC.h:2074
NetworkDevice
NetworkDevie, support NetworkDevice_LightMachine, NetworkDevice_LeftCamera and NetworkDevice_RightCam...
Definition: RVC.h:754
int light_contrast_threshold
Light contrast trheshold, range in [0, 10]. The contrast of point less than this value will be treat ...
Definition: RVC.h:1101
double truncate_z_max
truncate point map and depth map by z direction maximum value (units: mm) and truncate_z_max should m...
Definition: RVC.h:1224
Options when setting custom transformation.
Definition: RVC.h:1285
bool use_auto_bilateral_filter
flag Whether to use auto bilateral filter. If true, the bilateral_filter_kernal_size and bilateral_fi...
Definition: RVC.h:2058
X1 CollectionCallBackInfo.
Definition: RVC.h:1318
Size GetSize() const
Get the PointMap Size object.
float gamma_2d
Set the 2D gamma value in milliseconds.
Definition: RVC.h:1929
int phase_filter_range
Set the phase filter value. The larger the value, the greater the filtering degree 0~40...
Definition: RVC.h:1106
void(* CollectionCallBackPtr)(X2::CollectionCallBackInfo, X2::CaptureOptions, UserPtr)
X2 CallBackPtr.
Definition: RVC.h:2162
X2 CollectionCallBackInfo.
Definition: RVC.h:2145
Handle(HandleID sid_, HandleID gid_)
Construct a new Handle object with sid and gid.
Definition: RVC.h:64
Definition: RVC.h:639
double downsample_distance
uniform downsample distance. if <= 0, do nothing.
Definition: RVC.h:1978
int width_max
Maximum value of width of Image roi.
Definition: RVC.h:240
ProjectorColor projector_color
projector color
Definition: RVC.h:1938
double noise_removal_distance
The smaller the value, the greater the filtering degree. range: 0 ~ 20 (units: mm) ...
Definition: RVC.h:1091
bool use_auto_bilateral_filter
flag Whether to use auto bilateral filter. If true, the bilateral_filter_kernal_size and bilateral_fi...
Definition: RVC.h:1258
double bilateral_filter_space_sigma
the guassian sigma in space of bilateral filter of depth map range: [0, 100]
Definition: RVC.h:2021
RVC X PointMap Type.
Definition: RVC.h:498
int light_contrast_threshold
Light contrast trheshold, range in [0, 10]. The contrast of point less than this value will be treat ...
Definition: RVC.h:1878
Handle m_handle
RVC Handle.
Definition: RVC.h:636
CameraID
CameraID, support CameraID_Left and CameraID_Right
Definition: RVC.h:678
int width_step
step of width of Image roi
Definition: RVC.h:220
Enum
RVC camera type, support USB, GigE and All
Definition: RVC.h:913
CaptureOptions()
Construct a new Capture Options object.
Definition: RVC.h:1792
double truncate_z_min
truncate point map and depth map by z direction minimum value (units: mm) and truncate_z_min should l...
Definition: RVC.h:1217
int scan_times
scan times, only use in robust mode. range [2, 8],
Definition: RVC.h:1995
uint32_t HandleID
Handle id 4 bytes long.
Definition: RVC.h:47
int line_scanner_brightness_threshold
Only laser lines with brightness greater than the &#39;line_scanner_brightness_threshold&#39; will be extract...
Definition: RVC.h:2105
RVC::ROI roi
set ROI function, only 3d points in the roi will be generated. This function can improve 3d capturesp...
Definition: RVC.h:1210
double bilateral_filter_depth_sigma
the guassian sigma in depth of bilateral filter of depth map range: [0, 100]
Definition: RVC.h:1238
float gamma_3d
Set the 3D gamma value.
Definition: RVC.h:1172
int width_min
Minimum value of width of Image roi.
Definition: RVC.h:230
bool pointcloud_completion
In &#39;CaptureMode_SwingLineScan&#39; mode with &#39;correspond2d&#39; enabled,turning on &#39;pointcloud_completion&#39; wi...
Definition: RVC.h:2093
Definition: RVC.h:2609
ROI()
Construct a new Image ROI object.
Definition: RVC.h:169
bool operator!=(const Size &lhs, const Size &rhs)
Compare two Image size.
Definition: RVC.h:156
CaptureMode capture_mode
control capture mode
Definition: RVC.h:1195
RVC Handle.
Definition: RVC.h:52
RVC_EXPORT const char * GetLastErrorMessage()
Get the lastest error message. The pointer to string is temporary, you need to copy data from its buf...
int edge_noise_reduction_threshold
edge control after point matching, range in [0, 10], default = 2. The big the value, the more edge noise to be removed.
Definition: RVC.h:1884
unsigned int calc_normal_radius
Neighborhood radius in pixel of calculating normal, > 0.
Definition: RVC.h:1871
double * GetPointDataPtr()
Get the Point Data Ptr of PointMap object.
Capture options.
Definition: RVC.h:1004
Enum
Unit support Meter and Millimeter
Definition: RVC.h:522
CoordinateSelect coordinate_select
base coordinate setting of custom transformation
Definition: RVC.h:1306
bool calc_normal
flag Whether calculate 3D points normal vector
Definition: RVC.h:1866
X1 CalculationCallBackInfo.
Definition: RVC.h:1325
Handle & operator=(const Handle &rhs)
Assigns new Object to the Handle object, replace its current parameters.
Definition: RVC.h:78
int height_step
step of height of Image roi
Definition: RVC.h:225
int reflection_filter_threshold
Used to remove large-area erroneous point clouds caused by reflections. The higher this value is set...
Definition: RVC.h:2066
X2 CalculationCallBackInfo.
Definition: RVC.h:2152
ROI(int x, int y, int w, int h)
Construct a new Image ROI object with x,y,w,h.
Definition: RVC.h:178
Image ROI.
Definition: RVC.h:164
int exposure_time_3d
Set the exposure_time 3D value in milliseconds.
Definition: RVC.h:1116
Definition: RVC.h:440
double smooth_sigma
The Gaussian filters are used to smooth points. The larger the smooth_sigma, the smoother the point c...
Definition: RVC.h:1274
int bilateral_filter_kernal_size
the kernal size of bilateral filter of depth map range: [3, 31], 0 for not use bilateral filter ...
Definition: RVC.h:1231
Device ROIRange.
Definition: RVC.h:205
float gamma_2d
Set the 2D gamma value.
Definition: RVC.h:1167
int x_step
step of x of Image roi (col index of roi up left corner)
Definition: RVC.h:210
int hdr_exposure_times
Set the hdr exposure times value. 0,2,3.
Definition: RVC.h:1136
bool correspond2d
whether to generate point clouds corresponding to 2D images
Definition: RVC.h:2044
NetworkType
RVC supported Camera Network type.
Definition: RVC.h:708
int exposure_time_2d
Set the exposure_time 2D value in milliseconds.
Definition: RVC.h:1111
Size GetSize()
Get the DepthMap Size object.
Definition: RVC.h:2617
Definition: RVC.h:2709
RVC_EXPORT bool SystemInit()
SystemInit.
Definition: PythonAPI.py:353
bool operator==(const Size &lhs, const Size &rhs)
Compare two Image size.
Definition: RVC.h:145
Size(int w, int h)
Construct a new Image/PointMap Size object with width/cols and height/rows.
Definition: RVC.h:120
PortType
RVC supported Camera Port type.
Definition: RVC.h:695
Image Type.
Definition: RVC.h:276
Device struct.
Definition: RVC.h:830
ProjectorColor
Projector color, support ProjectorColor_Red, ProjectorColor_Green, ProjectorColor_Blue, ProjectorColor_White and ProjectorColor_ALL
Definition: RVC.h:718
Definition: RVC.h:518
SmoothnessLevel smoothness
control point map smoothness
Definition: RVC.h:1183
CaptureOptions()
Construct a new Capture Options object.
Definition: RVC.h:1009
bool transform_to_camera
flag Whether transfrom 3D points from calibration board system to camera coordinate system ...
Definition: RVC.h:1066
CoordinateSelect coordinate_select
base coordinate setting of custom transformation
Definition: RVC.h:2133
unsigned int calc_normal_radius
Neighborhood radius in pixel of calculating normal, > 0.
Definition: RVC.h:1162
float gamma_3d
Set the 3D gamma value in milliseconds.
Definition: RVC.h:1934
bool operator==(const Handle &rhs)
Compare with another Handle object.
Definition: RVC.h:90
Definition: RVC.h:2699
double downsample_distance
uniform downsample distance. if <= 0, do nothing.
Definition: RVC.h:1189
RVC_EXPORT void SystemShutdown()
SystemShutdown.
Definition: PythonAPI.py:365
RVC_EXPORT int SystemListDevices(Device *pdevices, size_t size, size_t *actual_size, SystemListDeviceType::Enum opt=SystemListDeviceType::All)
List the fix number devices.
Size GetSize()
Get the Size object.
int noise_removal_point_number
Set the noise filter parameter 2. The larger the value, the greater the filtering degree...
Definition: RVC.h:1972
Handle m_handle
DepthMap Handle.
Definition: RVC.h:437
float gain_3d
Set the 3D gain value in milliseconds.
Definition: RVC.h:1904
int bilateral_filter_kernal_size
the kernal size of bilateral filter of depth map range: [3, 31], 0 for not use bilateral filter ...
Definition: RVC.h:2007
Handle(const Handle &rhs)
Construct a new Handle object with another Handle.
Definition: RVC.h:70
RVC X DepthMap.
Definition: RVC.h:377
int line_scanner_max_distance
Set line scanner mode&#39;s maximum working distance.
Definition: RVC.h:2038
Handle m_handle
RVC Handle.
Definition: RVC.h:1774
Size()
Construct a new Image/PointMap Size object.
Definition: RVC.h:113
bool use_auto_noise_removal
flag Whether to use auto noise removal. If true, the noise_removal_distance and noise_removal_point_n...
Definition: RVC.h:1086
RVC_EXPORT bool SystemIsInited()
Check system is inited or not.
Definition: PythonAPI.py:359
RVC_EXPORT Device SystemFindDevice(const char *serialNumber)
Return the device according to the serialNumber, if the device is valid.
RVC X PointMap.
Definition: RVC.h:538
int line_scanner_scan_time_ms
Set line scanner mode&#39;s total scan time.
Definition: RVC.h:2026
bool enable_2d_in_capture
Acquire 2D images during capture.
Definition: RVC.h:1279
void(* CollectionCallBackPtr)(X1::CollectionCallBackInfo, X1::CaptureOptions, UserPtr)
X1 CallBackPtr.
Definition: RVC.h:1335
float gain_2d
Set the 2D gain value in milliseconds.
Definition: RVC.h:1899
X2 struct.
Definition: RVC.h:1782
int hdr_exposure_times
Set the hdr exposure times value. 0,2,3.
Definition: RVC.h:1909
int x
start x of Image roi (col index of roi up left corner)
Definition: RVC.h:183
bool use_projector_capturing_2d_image
Set 2D image whether use projector.
Definition: RVC.h:1943
int line_scanner_min_distance
Set line scanner mode&#39;s minimum working distance.
Definition: RVC.h:2034
bool operator!=(const Handle &rhs)
Compare with another Handle object.
Definition: RVC.h:98
RVC::ROI roi
set ROI function, only 3d points in the roi will be generated. This function can improve 3d capture s...
Definition: RVC.h:2082
Handle()
Construct a new Handle object.
Definition: RVC.h:57
int height_max
Maximum value of height of Image roi.
Definition: RVC.h:245
int width
Image roi width.
Definition: RVC.h:193
double confidence_threshold
confidence threshold, the point with confindence low then this value will be removed range: [0...
Definition: RVC.h:1991
Definition: RVC.h:2689
bool enable_2d_in_capture
Acquire 2D images during capture.
Definition: RVC.h:2087
float gain_2d
Set the 2D gain value.
Definition: RVC.h:1126
int scan_times
scan times, only use in robust mode. range [2, 8],
Definition: RVC.h:1250
Handle m_handle
confidence map handle
Definition: RVC.h:491
double bilateral_filter_depth_sigma
the guassian sigma in depth of bilateral filter of depth map range: [0, 100]
Definition: RVC.h:2014
int projector_brightness
Set the projector brightness value.
Definition: RVC.h:1861
Enum
PointMap Type Support type PointsOnly and PointsNormals
Definition: RVC.h:504
System list Device type.
Definition: RVC.h:908
Image/PointMap Size.
Definition: RVC.h:108
double noise_removal_distance
The smaller the value, the greater the filtering degree. range: 0 ~ 20 (units: mm) ...
Definition: RVC.h:1968
NetworkDeviceStatus_
NetworkDevieStatus, support NetworkDeviceStatus_OK, NetworkDeviceStatus_Not_Reachable, NetworkDeviceStatus_In_Use and NetworkDeviceStatus_Conflict
Definition: RVC.h:766
uint16_t line_scanner_laser_position
select laser position in fixed line scan mode
Definition: RVC.h:2050
bool use_projector_capturing_2d_image
Set 2D image whether use projector.
Definition: RVC.h:1177
double bilateral_filter_space_sigma
the guassian sigma in space of bilateral filter of depth map range: [0, 100]
Definition: RVC.h:1245
int y_step
step of y of Image roi (row index of roi up left corner)
Definition: RVC.h:215
int noise_removal_point_number
Set the noise filter parameter 2. The larger the value, the greater the filtering degree...
Definition: RVC.h:1095
Size GetSize() const
Get the Image Size object.
int height_min
Minimum value of height of Image roi.
Definition: RVC.h:235
CoordinateSelect
base coordinate of custom transformation,default is CoordinateSelect_Disabled
Definition: RVC.h:1292
RVC X Image object.
Definition: RVC.h:303
CaptureMode
CaptureMode, support CaptureMode_Fast, CaptureMode_Normal, CaptureMode_Ultra, CaptureMode_Robust, CaptureMode_AntiInterReflection and CaptureMode_SwingLineScan
Definition: RVC.h:778
CameraID transform_to_camera
CameraID_Left transfrom 3D points from calibration board system to left camera coordinate system Came...
Definition: RVC.h:1856
int line_scanner_exposure_time_us
Set line scanner mode&#39;s single line exposure time.
Definition: RVC.h:2030
bool IsValid() const
Check PointMap is Valid or not.
int height
Image roi height.
Definition: RVC.h:198
bool use_auto_noise_removal
flag Whether to use auto noise removal. If true, the noise_removal_distance and noise_removal_point_n...
Definition: RVC.h:1963
RVC namespace.
Definition: QuickStart.dox:1
float gain_3d
Set the 3D gain value.
Definition: RVC.h:1131