Mech-Eye API 2.5.0
API reference documentation for Mech-Eye 3D Laser Profiler
All Classes Functions Variables Typedefs Enumerations Enumerator Pages
MultiProfilerErrorStatus.h
1#pragma once
2#include <string>
3#include <unordered_map>
4namespace mmind {
5namespace eye {
7{
8public:
9 enum ErrorCode {
10 MMIND_STATUS_SUCCESS = 0, //< Success.
11
12 // error code for calibration
13 MMIND_STATUS_EMPTY_DEPTH_IMAGE = -1,
14 MMIND_STATUS_PLANE_SEGMENTATION_FAILURE = -2,
15 MMIND_STATUS_NONE_PARALLEL_PLANES = -3,
16 MMIND_STATUS_OVERMUCH_PARALLEL_PLANES = -4,
17 MMIND_STATUS_REORDER_PLANES_FAILURE = -5,
18 MMIND_STATUS_REPROJECT_ERROR_HIGH = -6,
19 MMIND_STATUS_INVALID_ROI = -7,
20
21 // error code for stitcher
22 MMIND_STATUS_NON_STANDARD_RESOLUTION = -8,
23 MMIND_STATUS_CAMERA_MODEL_ERROR = -9,
24 MMIND_STATUS_INVALID_BOUNDARY_VALUE = -10,
25 MMIND_STATUS_FUSION_POINT_EXCEED_MEMORY = -11,
26 MMIND_STATUS_MULTI_STITCH_CAMERA_MODEL_EMPTY = -12,
27 MMIND_STATUS_MULTI_STITCH_PARAMS_EMPTY = -13,
28 MMIND_STATUS_PARAMS_ARE_NOT_CHECKED = -14,
29 MMIND_STATUS_POINT_CLOUDS_EMPTY = -15,
30 MMIND_STATUS_NO_IMAGE_AVAILABLE = -16,
31 MMIND_STATUS_DEPTH_INTENSITY_IMAGE_SIZE_UNMATCHED = -17,
32 MMIND_STATUS_DEPTH_IMAGE_TYPE_WRONG = -18,
33 MMIND_STATUS_INTENSITY_IMAGE_TYPE_WRONG = -19,
34 MMIND_STATUS_MAJOR_AND_MINOR_RESOLUTION_INCONSISTENCY = -20,
35 MMIND_STATUS_MULTI_STITCH_PARAMS_SIZE_INCONSISTENCY = -21,
36 MMIND_STATUS_MULTI_FUSION_PARAMS_SIZE_INCONSISTENCY = -22,
37 MMIND_STATUS_MINOR_INFO_UNMATCHED_IN_FUSION = -23,
38 MMIND_STATUS_EXTRACT_IMAGE_INFO_ERROR = -24,
39 MMIND_STATUS_EMPTY_BIASES_IN_FUSION = -25,
40 MMIND_STATUS_IMAGE_AND_MASK_SIZE_UNMATCHED_IN_FUSION = -26,
41
42 // error code for checking validity
43 MMIND_STATUS_INVALID_PARAM = -27,
44 MMIND_STATUS_INVALID_POSITIVE_PARAM = -28,
45 MMIND_STATUS_INVALID_IMAGE_CONFIG_PAIR = -29,
46 MMIND_STATUS_INVALID_IMAGE_RESULT_PAIR = -30,
47 MMIND_STATUS_EMPTY_MULTISYSTEM_CONFIG = -31,
48 MMIND_STATUS_INVALID_ROTATION_MATRIX = -32,
49 MMIND_STATUS_INVALID_MOVE_DIR_VECTOR = -33,
50 MMIND_STATUS_INVALID_MOVE_DIR_VECTOR_Y = -34,
51 MMIND_STATUS_INVALID_TOP_LENGTH = -35,
52 MMIND_STATUS_INVALID_ROTATE_RADIUS_ANGLE_MODE = -36,
53 MMIND_STATUS_INVALID_ROTATE_RADIUS_WIDE_MODE = -37,
54 MMIND_STATUS_INVALID_ROTATE_ANGLE_ANGLE_MODE = -38,
55 MMIND_STATUS_INVALID_ROTATE_ANGLE_WIDE_MODE = -39,
56 MMIND_STATUS_INVALID_TRANSLATE_DISTANCE_ANGLE_MODE = -40,
57 MMIND_STATUS_INVALID_ROTATE_AXIS_ANGLE_MODE = -41,
58 MMIND_STATUS_INVALID_ROTATE_AXIS_WIDE_MODE = -42,
59 MMIND_STATUS_INVALID_TRANSLATE_AXIS_ANGLE_MODE = -43,
60 MMIND_STATUS_INVALID_TRANSLATE_AXIS_WIDE_MODE = -44,
61 MMIND_STATUS_INVALID_DOWNSAMPLE = -45,
62 MMIND_STATUS_INVALID_DEPTH_GROUPID = -46,
63 MMIND_STATUS_INVALID_CONFIG_GROUPID = -47,
64 MMIND_STATUS_INVALID_RESULT_GROUPID = -48,
65
66 // error code for IO
67 MMIND_STATUS_INPUT_ERROR = -49,
68
69 // error code for load calib files
70 MMIND_STATUS_CONFIG_LOAD_FAILURE = -50,
71 MMIND_STATUS_RESULT_LOAD_FAILURE = -51,
72 MMIND_STATUS_EVALS_LOAD_FAILURE = -52,
73 MMIND_STATUS_DEPTH_LOAD_FAILURE = -53,
74 };
75
76 enum ErrorSource { System, MajorDevice, MinorDevice };
77
78 MultiProfilerErrorStatus() = default;
79 MultiProfilerErrorStatus(ErrorCode code, const std::string& message)
80 : errorCode(code), errorDescription(message)
81 {
82 }
83
84 bool isOK() const
85 {
86 return errorCode == MMIND_STATUS_SUCCESS ||
87 errorCode == MMIND_STATUS_NON_STANDARD_RESOLUTION;
88 }
89
90 void setErrorCodeAndDescription(const ErrorCode& code)
91 {
92 this->errorCode = code;
93 this->errorDescription = errorInfoMap[code];
94 }
95
96 void setErrorCodeAndDescription(const ErrorCode& code, const std::string& paraName)
97 {
98 this->errorCode = code;
99 this->errorDescription = errorInfoMap[code] + paraName;
100 }
101
102 unsigned int groupID = 0;
103 ErrorSource errorSource = System;
104 ErrorCode errorCode = MMIND_STATUS_SUCCESS;
105 std::string errorDescription = "Success";
106
107private:
108 // description for calibration
109 std::string emptyImageDescription =
110 "Failed to access the specified image. Please check the file path and ensure the file "
111 "exists.";
112 std::string planeSegmentationFailureDescription =
113 "The number of sampling points in the point cloud available for plane segmentation is too "
114 "few. Please check the input depth maps and ensure that they only contain the six feature "
115 "planes of the calibration target.";
116 std::string noneParallelPlanesDescription =
117 "Plane 1 and 2 were not found. Please check the input depth maps and ensure that they only "
118 "contain the six feature planes of the calibration target.";
119 std::string overmuchParallelPlanesDescription =
120 "More than two parallel surfaces were identified. Please ensure the depth map only "
121 "contains the six feature planes of the calibration target. If two laser profilers share a "
122 "common field of view, laser light interference may cause this error; in that case, "
123 "the 'Trigger Delay' parameter should be set for one laser profiler.";
124 std::string reorderPlanesFailureDescription =
125 "Failed to order the feature planes. Please ensure that each lateral face forms a 45° "
126 "angle with both the upper and lower bases, and that the depth map contains only the six "
127 "feature planes of the calibration target.";
128 std::string reprojectErrorHighDescription =
129 "The reprojection error is excessive. Please verify the input parameters: (1) The depth "
130 "maps should only contain the six feature planes of the calibration target; (2) Ensure the "
131 "resolutionX/Y in deviceInfo (algorithm parameter) matches the actual specifications, and "
132 "confirm the targetSize parameters correspond with practical usage; (3) Excessive noise in "
133 "captured data may exist - appropriately increasing downsampleX/Y (downsampling intervals "
134 "along X/Y axes) might alleviate this issue, with recommended values in [10, 40]; (4) "
135 "Contaminants like dust, scratches, or reflective areas on the calibration target could "
136 "interfere with accuracy; (5) Verify the calibration target meets required mechanical "
137 "machining precision; (6) Check whether the camera contour mode parameters align with "
138 "recommended values.";
139 std::string invalidROIDescription =
140 "The ROI (Region of Interest) of the real-time collected image should match the ROI of the "
141 "device information. Please check if the ROI in depthImageInfo and dualProfilerConfig is "
142 "consistent.";
143 // description for stitcher
144 std::string nonStandardResolutionDescription =
145 "In stitching, the user-input resolution in the X direction is an LNX non-standard "
146 "resolution. Please verify that the output matches expectations. This might occur because "
147 "the user rescaled the image before stitching. If errors or unexpected results arise "
148 "during stitching, first check whether the resolution input is correct.";
149 std::string cameraModelErrorDescription = "Please input the model of the laser profiler.";
150 std::string invalidBoundaryValueDescription =
151 "In stitching, the image boundary detection during the resampling step returned invalid "
152 "values. Please check the input parameters, especially whether the RT matrix is incorrect.";
153 std::string fusionPointExceedMemoryDescription =
154 "During stitching, the point cloud fusion process required more computing space than the "
155 "available capacity.";
156 std::string multiStitchCameraModelEmptyDescription =
157 "In stitching, the 'camera model' parameter list is empty.";
158 std::string multiStitchParamsEmptyDescription =
159 "In stitching, the 'stitching parameters' list is empty.";
160 std::string multiStitchParamsSizeInconsistencyDescription =
161 "In stitching, the length of the 'stitching parameters' list does not match the length of "
162 "the 'camera model' parameter list.";
163 std::string multiFusionParamsSizeInconsistencyDescription =
164 "The length of fusionFlag or fusionParam variable input during fusion does not match the "
165 "length of the minor camera image.";
166 std::string stitchParamsAreNotCheckedDescription =
167 "Before calling the stitching function, the parameter check function must be called first.";
168 std::string pointCloudsEmptyDescription = "The input point cloud data was empty.";
169 std::string depthImageTypeWrongDescription = "The input image type was not CV_32F or CV_32F1.";
170 std::string resolutionInconsistencyDescription =
171 "During stitching, the X-axis and Y-axis resolutions must be identical, and the "
172 "resolutions for both axes should be the same across the primary and secondary laser "
173 "profilers.";
174 std::string noImageAvailableDescription =
175 "The intensity image and depth map in the input data were unavailable.";
176 std::string depthAndIntensityImageSizeWrongDescription =
177 "During stitching, the dimensions of the depth map and intensity map from the same camera "
178 "do not match.";
179 std::string intensityImageTypeWrongDescription =
180 "The input intensity image type was not CV_8UC1.";
181 std::string biasesEmptyDescription = "In fusion, the 'image bias' parameter list is empty.";
182 std::string minorInfoSizeErrorDescription =
183 "In fusion, the lengths of the ‘image data’ list and the ‘image bias’ parameter list are "
184 "inconsistent.";
185 std::string imageExtractInfomationErrorDescription =
186 "In fusion, when extracting the fused image from the fused large image, the computed ROI "
187 "exceeds the original image size. The possible reason is incorrect image size or image "
188 "bias input into the function. This interface is not open to the public, so the risk of "
189 "this error occurring is minimal.";
190 std::string imageAndMaskSizeUnmatchedDescription =
191 "In fusion, the sizes of the valid point mask image and the original image do not match.";
192 // description for checking validity
193 std::string invalidParamDescription =
194 "The input parameters were empty or contain invalid values such as infinite or Nan.";
195 std::string invalidPositiveParamDescription =
196 "Input parameters should be positive finite values.";
197 std::string invalidImageConfigPairDescription =
198 "The lengths of minorImageInfos and multiProfilerConfig input parameters are inconsistent; "
199 "please check the relevant inputs.";
200 std::string invalidImageResultPairDescription =
201 "The lengths of minorImageInfos and multiProfilerResult input parameters are inconsistent; "
202 "please check the relevant inputs.";
203 std::string emptyMultiProfilerConfigDescription =
204 "The multiProfilerConfig input parameter is empty; please check the relevant inputs.";
205 std::string invalidRotateMatrixDescription = "The rotation matrix is not an orthogonal matrix.";
206 std::string invalidMoveDirVecDescription = "The motion direction vector is not a unit vector.";
207 std::string invalidMoveDirVecYDescription =
208 "The Y component of the motion direction vector should be a non-negative number.";
209 std::string invalidTopLengthDescription =
210 "The upper base length of the frustum should be smaller than the lower base length.";
211 std::string invalidRotateRadiusInAngleModeDescription =
212 "In the Angled mode, the value of rotateRadius should be greater than half of the frustum "
213 "height.";
214 std::string invalidRotateRadiusInWideModeDescription =
215 "In the Wide mode, the value of rotateRadius should be 0.";
216 std::string invalidRotateAngleInAngleModeDescription =
217 "In the Angled mode, when one frustum is rotated relative to another along the Y axis, the "
218 "included angle between frustum axes (rotateAngleInDegree) should be within [-180, 180]; "
219 "when one frustum is rotated relative to another along the X axis, the included angle "
220 "between frustum axes (rotateAngleInDegree) should be within (-90, 90).";
221 std::string invalidRotateAngleInWideModeDescription =
222 "In the Wide mode, the rotation angle between two frustums (rotateAngleInDegree) should be "
223 "0.";
224 std::string invalidTranslateDistanceInAngleModeDescription =
225 "In the Angled mode, the translate distance between two frustums (translateDistance) "
226 "should be 0.";
227 std::string invalidRotateAxisInAngleModeDescription =
228 "In the Angled mode, the axis along which one frustum is rotated relative to another "
229 "(targetRotateAxis) should not be NullAxis.";
230 std::string invalidRotateAxisInWideModeDescription =
231 "In the Wide mode, the axis along which one frustum is rotated relative to another "
232 "(targetRotateAxis) should be NullAxis.";
233 std::string invalidTranslateAxisInAngleModeDescription =
234 "In the Angled mode, the axis along which one frustum is translated relative to another "
235 "(targetTranslateAxis) should be NullAxis.";
236 std::string invalidTranslateAxisInWideModeDescription =
237 "In the Wide mode, the axis along which one frustum is translated relative to another "
238 "(targetTranslateAxis) should not be NullAxis.";
239 std::string invalidDownSampleDescription =
240 "The input downsampling parameters (downsampleX and downsampleY) should be integers within "
241 "the range [1, 40].";
242 std::string invalidDepthGroupIDDescription =
243 "The groupID of members in the xxx data structure should match the index of their "
244 "position.";
245 std::string invalidConfigGroupIDDescription =
246 "The groupID of each dualProfilerConfig in multiProfilerConfig should correspond to its "
247 "index in the vector (a data structure). For example, if there are three members in "
248 "multiProfilerConfig named dualProfilerConfig0 to dualProfilerConfig2, the groupID of "
249 "dualProfilerConfig0 should be 0, dualProfilerConfig1 should be 1, and dualProfilerConfig2 "
250 "should be 2.";
251 std::string invalidResultGroupIDDescription =
252 "The groupID of each dualProfilerResult in multiProfilerResults should correspond to its "
253 "index in the vector (a data structure). For example, if there are three members in "
254 "multiProfilerResults named dualProfilerResult0 to dualProfilerResult2, the groupID of "
255 "dualProfilerResult0 should be 0, dualProfilerResult1 should be 1, and dualProfilerResult2 "
256 "should be 2.";
257
258 std::unordered_map<ErrorCode, std::string> errorInfoMap = {
259 // for calibration
260 {MMIND_STATUS_EMPTY_DEPTH_IMAGE, emptyImageDescription},
261 {MMIND_STATUS_PLANE_SEGMENTATION_FAILURE, planeSegmentationFailureDescription},
262 {MMIND_STATUS_NONE_PARALLEL_PLANES, noneParallelPlanesDescription},
263 {MMIND_STATUS_OVERMUCH_PARALLEL_PLANES, overmuchParallelPlanesDescription},
264 {MMIND_STATUS_REORDER_PLANES_FAILURE, reorderPlanesFailureDescription},
265 {MMIND_STATUS_REPROJECT_ERROR_HIGH, reprojectErrorHighDescription},
266 {MMIND_STATUS_INVALID_ROI, invalidROIDescription},
267 // for stitcher
268 {MMIND_STATUS_NON_STANDARD_RESOLUTION, nonStandardResolutionDescription},
269 {MMIND_STATUS_CAMERA_MODEL_ERROR, cameraModelErrorDescription},
270 {MMIND_STATUS_INVALID_BOUNDARY_VALUE, invalidBoundaryValueDescription},
271 {MMIND_STATUS_FUSION_POINT_EXCEED_MEMORY, fusionPointExceedMemoryDescription},
272 {MMIND_STATUS_MULTI_STITCH_CAMERA_MODEL_EMPTY, multiStitchCameraModelEmptyDescription},
273 {MMIND_STATUS_MULTI_STITCH_PARAMS_EMPTY, multiStitchParamsEmptyDescription},
274 {MMIND_STATUS_MULTI_STITCH_PARAMS_SIZE_INCONSISTENCY,
275 multiStitchParamsSizeInconsistencyDescription},
276 {MMIND_STATUS_PARAMS_ARE_NOT_CHECKED, stitchParamsAreNotCheckedDescription},
277 {MMIND_STATUS_POINT_CLOUDS_EMPTY, pointCloudsEmptyDescription},
278 {MMIND_STATUS_DEPTH_IMAGE_TYPE_WRONG, depthImageTypeWrongDescription},
279 {MMIND_STATUS_NO_IMAGE_AVAILABLE, noImageAvailableDescription},
280 {MMIND_STATUS_DEPTH_INTENSITY_IMAGE_SIZE_UNMATCHED,
281 depthAndIntensityImageSizeWrongDescription},
282 {MMIND_STATUS_INTENSITY_IMAGE_TYPE_WRONG, intensityImageTypeWrongDescription},
283 {MMIND_STATUS_MAJOR_AND_MINOR_RESOLUTION_INCONSISTENCY, resolutionInconsistencyDescription},
284 {MMIND_STATUS_EMPTY_BIASES_IN_FUSION, biasesEmptyDescription},
285 {MMIND_STATUS_MINOR_INFO_UNMATCHED_IN_FUSION, minorInfoSizeErrorDescription},
286 {MMIND_STATUS_EXTRACT_IMAGE_INFO_ERROR, imageExtractInfomationErrorDescription},
287 {MMIND_STATUS_IMAGE_AND_MASK_SIZE_UNMATCHED_IN_FUSION,
288 imageAndMaskSizeUnmatchedDescription},
289 {MMIND_STATUS_MULTI_FUSION_PARAMS_SIZE_INCONSISTENCY,
290 multiFusionParamsSizeInconsistencyDescription},
291
292 // for checking validity
293 {MMIND_STATUS_INVALID_PARAM, invalidParamDescription},
294 {MMIND_STATUS_INVALID_POSITIVE_PARAM, invalidPositiveParamDescription},
295 {MMIND_STATUS_INVALID_IMAGE_CONFIG_PAIR, invalidImageConfigPairDescription},
296 {MMIND_STATUS_INVALID_IMAGE_RESULT_PAIR, invalidImageResultPairDescription},
297 {MMIND_STATUS_EMPTY_MULTISYSTEM_CONFIG, emptyMultiProfilerConfigDescription},
298 {MMIND_STATUS_INVALID_ROTATION_MATRIX, invalidRotateMatrixDescription},
299 {MMIND_STATUS_INVALID_MOVE_DIR_VECTOR, invalidMoveDirVecDescription},
300 {MMIND_STATUS_INVALID_MOVE_DIR_VECTOR_Y, invalidMoveDirVecYDescription},
301 {MMIND_STATUS_INVALID_TOP_LENGTH, invalidTopLengthDescription},
302 {MMIND_STATUS_INVALID_ROTATE_RADIUS_ANGLE_MODE, invalidRotateRadiusInAngleModeDescription},
303 {MMIND_STATUS_INVALID_ROTATE_RADIUS_WIDE_MODE, invalidRotateRadiusInWideModeDescription},
304 {MMIND_STATUS_INVALID_ROTATE_ANGLE_ANGLE_MODE, invalidRotateAngleInAngleModeDescription},
305 {MMIND_STATUS_INVALID_ROTATE_ANGLE_WIDE_MODE, invalidRotateAngleInWideModeDescription},
306 {MMIND_STATUS_INVALID_TRANSLATE_DISTANCE_ANGLE_MODE,
307 invalidTranslateDistanceInAngleModeDescription},
308 {MMIND_STATUS_INVALID_ROTATE_AXIS_ANGLE_MODE, invalidRotateAxisInAngleModeDescription},
309 {MMIND_STATUS_INVALID_ROTATE_AXIS_WIDE_MODE, invalidRotateAxisInWideModeDescription},
310 {MMIND_STATUS_INVALID_TRANSLATE_AXIS_ANGLE_MODE,
311 invalidTranslateAxisInAngleModeDescription},
312 {MMIND_STATUS_INVALID_TRANSLATE_AXIS_WIDE_MODE, invalidTranslateAxisInWideModeDescription},
313 {MMIND_STATUS_INVALID_DOWNSAMPLE, invalidDownSampleDescription},
314 {MMIND_STATUS_INVALID_DEPTH_GROUPID, invalidDepthGroupIDDescription},
315 {MMIND_STATUS_INVALID_CONFIG_GROUPID, invalidConfigGroupIDDescription},
316 {MMIND_STATUS_INVALID_RESULT_GROUPID, invalidResultGroupIDDescription},
317 };
318};
319} // namespace eye
320} // namespace mmind