Mech-Eye API 2.6.0
API reference documentation for Mech-Eye 3D Laser Profiler
Loading...
Searching...
No Matches
ProfilerCalibrationInterfaces.h
1/*******************************************************************************
2 * BSD 3-Clause License
3 *
4 * Copyright (c) 2016-2025, Mech-Mind Robotics Technologies Co., Ltd.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * Info: https://www.mech-mind.com/
33 *
34 ******************************************************************************/
35
36#pragma once
37#include <memory>
38#include <optional>
39#include <opencv2/core/mat.hpp>
40#include "api_global.h"
41#include "profiler/ProfileData.h"
42#include "profiler/calibration/MultiProfilerErrorStatus.h"
43#include "profiler/calibration/ProfilerHandEyeErrorStatus.h"
44#include "profiler/calibration/ProfilerCalibrationTypes.h"
45
46namespace mmind {
47namespace eye {
48class MultiProfilerCalibration;
49class MMIND_API_EXPORT ProfilerCalibrationInterfaces
50{
51public:
56 enum class CloudStitchOption {
57 RefineStitchParameters = 1,
58 OverlapRegionUniformSampling =
59 2,
60 };
61
67 RefineT = 1,
68 };
69
70 using CorrectedResult = TransformedImageInfo;
71
72public:
75
82 bool setCalibCameraModel(const std::string& cameraModel);
83
89 void setMajorDeviceInfo(const DeviceInfo& deviceInfo);
90
96 void setMinorDeviceInfos(const std::vector<DeviceInfo>& deviceInfos);
97
103 void setCalibTargetSize(const TargetSize& targetSize);
104
110 void setCalibTargetPoses(const std::vector<TargetPose>& targetPoses);
111
126 const cv::Mat& majorDepth, const std::vector<cv::Mat>& minorDepths,
127 std::vector<CalibResult>& calibResults, bool unifiedMoveDirection = true,
128 const std::optional<cv::Point3f>& majorCameraMoveDirVec = std::nullopt);
129
144 const cv::Mat& firstDepth, const cv::Mat& secondDepth, ProfilerMovementAxis moveAxis,
145 MoveDirCalibResult& calibResult,
146 const std::optional<cv::Point3f>& knownYAxisMoveDir = std::nullopt);
147
160 const cv::Mat& firstDepth, const cv::Mat& secondDepth,
161 const std::vector<RefPositionBias>& refPositionBiases, std::vector<StitchParams>& results,
162 const std::optional<cv::Point3f>& knownYAxisMoveDir = std::nullopt);
163
178 const std::vector<TrussRobotCalibMatchedPoint>& matchedPoints,
179 const TrussRobotCalibConfig& config, TrussRobotCalibResult& calibResult);
180
193 const cv::Point3f& profilerPoint, const cv::Point3f& profilerCapturePosition,
194 const TrussRobotCalibResult& calibResult, cv::Point3f& dstPoint,
195 const std::optional<cv::Point3f>& tcpOffSet = std::nullopt);
196
206 const ProfilerImage& srcImage,
207 CorrectedResult& result,
208 const MoveDirCorrectionOptions& options = {});
209
221 const ImageInfo& majorImageInfo, const std::vector<ImageInfo>& minorImageInfos,
222 const WidthExpansionType& type, FusionResult& results,
223 const std::vector<StitchParams>& multiParams, bool fusionFlag);
224
238 const ImageInfo& majorImageInfo, const std::vector<ImageInfo>& minorImageInfos,
239 const WidthExpansionType& type, FusionResult& results,
240 const std::vector<StitchParams>& multiParams, bool fusionFlag,
241 const std::vector<bool>& moveConsistentFlags);
242
253 bool saveCalibFiles(bool needSaveAll = true, const std::string& saveFolderName = "") const;
254
270 const ProfilerImage& majorImage, const std::vector<ProfilerImage>& minorImages,
271 const std::vector<CalibResult>& calibResults, MultiStitchResult& stitchResults,
272 const std::optional<MultiStitchParams>& stitchParams = std::nullopt);
273
289 const ProfilerImage& majorImage, const std::vector<ProfilerImage>& minorImages,
290 const std::vector<CalibResult>& calibResults, MultiStitchResultZParallel& stitchResults,
291 const std::optional<MultiStitchParams>& stitchParams = std::nullopt);
292
312 const ProfilerImage& majorImage, const std::vector<ProfilerImage>& minorImages,
313 int cloudStitchOption, int paramRefineOption, const std::vector<CalibResult>& calibResults,
314 bool correctRingError = true, int normalEstimationKnn = -1,
315 const std::optional<MultiStitchParams>& stitchParams = std::nullopt);
316
323 ProfileBatch::UntexturedPointCloud& pointCloud) const;
324
332 ProfileBatch::TexturedPointCloud& texturedPointCloud) const;
333
345 const std::vector<bool>& fusionFlag = {});
346
378 const cv::Point2i& majorBias,
379 FusionResult& fusionResult,
380 const std::vector<bool>& fusionFlag = {});
381
388 bool saveStitchFiles(const std::string& saveFolderName = "") const;
389
397 bool saveStitchFilesForZParallel(const std::string& saveFolderName = "") const;
398
409 MultiProfilerErrorStatus loadCalibProperties(const std::string& loadFolderName = "",
410 bool needLoadAll = false);
415 std::vector<CalibResult> getCurrentCalibResults() const;
416
424
431
437 std::string getCameraModel() const;
438
444 std::vector<DeviceInfo> getMinorDeviceInfos() const;
445
452 std::vector<TargetPose> getTargetPoses() const;
453
467 ProfilerCalibrationInterfaces(const std::string& cameraModel, const DeviceInfo& majorDeviceInfo,
468 const std::vector<DeviceInfo>& minorDeviceInfos,
469 const TargetSize& targetSize,
470 const std::vector<TargetPose>& targetPoses);
471
483 ProfilerCalibrationInterfaces(const std::string& cameraModel,
484 const DeviceInfo& profilerDeviceInfo,
485
486 const TargetSize& targetSize,
487 const std::vector<TargetPose>& targetPoses);
488
489private:
490 friend class InternalInterfaces;
491 std::unique_ptr<MultiProfilerCalibration> calibrationInstance;
492};
493
494} // namespace eye
495
496} // namespace mmind
void setMinorDeviceInfos(const std::vector< DeviceInfo > &deviceInfos)
Initializes the configuration for the secondary laser profiler(s).
MultiProfilerErrorStatus imageFusionForZParallel(const MultiStitchResultZParallel &stitchResult, const cv::Point2i &majorBias, FusionResult &fusionResult, const std::vector< bool > &fusionFlag={})
Performs fusion based on the stitching results when the laser profilers are arranged in the Wide mode...
CloudStitchOption
Cloud stitching options. This enum defines the options available for stitching point clouds.
bool saveCalibFiles(bool needSaveAll=true, const std::string &saveFolderName="") const
Saves the calibration data to files in the specified path.
bool setCalibCameraModel(const std::string &cameraModel)
Sets the model of the laser profilers used in the calibration, in the form of a string such as "Mech-...
ProfilerCalibrationInterfaces(const std::string &cameraModel, const DeviceInfo &majorDeviceInfo, const std::vector< DeviceInfo > &minorDeviceInfos, const TargetSize &targetSize, const std::vector< TargetPose > &targetPoses)
Constructs a new ProfilerCalibrationInterfaces object with specified parameters. This constructor ini...
MultiProfilerErrorStatus stitchPointCloud(const ProfilerImage &majorImage, const std::vector< ProfilerImage > &minorImages, int cloudStitchOption, int paramRefineOption, const std::vector< CalibResult > &calibResults, bool correctRingError=true, int normalEstimationKnn=-1, const std::optional< MultiStitchParams > &stitchParams=std::nullopt)
Calculates the stitching results for point clouds.
bool saveStitchFiles(const std::string &saveFolderName="") const
Saves the stitching results to files in the specified path.
std::vector< TargetPose > getTargetPoses() const
Gets the calibration target poses. This function retrieves the spatial positions and orientations of ...
MultiProfilerErrorStatus stitchImages(const ProfilerImage &majorImage, const std::vector< ProfilerImage > &minorImages, const std::vector< CalibResult > &calibResults, MultiStitchResult &stitchResults, const std::optional< MultiStitchParams > &stitchParams=std::nullopt)
Calculates the stitching results when the laser profilers are arranged in the Angle mode (i....
void setCalibTargetSize(const TargetSize &targetSize)
Sets the dimensions of the frustums of the calibration target.
ProfilerHandEyeErrorStatus calibrateTrussRobot(const std::vector< TrussRobotCalibMatchedPoint > &matchedPoints, const TrussRobotCalibConfig &config, TrussRobotCalibResult &calibResult)
Calculates the calibration results based on the depth maps acquired by the primary and secondary lase...
MultiProfilerErrorStatus stitchProfilerWidthExpansion(const ImageInfo &majorImageInfo, const std::vector< ImageInfo > &minorImageInfos, const WidthExpansionType &type, FusionResult &results, const std::vector< StitchParams > &multiParams, bool fusionFlag)
Perform width-expansion stitching for a single profiler (S/Z-type scanning).
std::vector< CalibResult > getCurrentCalibResults() const
Gets the current calibration results, which can be used for stitching.
StitchParamRefineOption
Stitching parameter refinement options. This enum defines the options available for stitching paramet...
MultiProfilerErrorStatus calibrateSingleProfilerWidthExpansion(const cv::Mat &firstDepth, const cv::Mat &secondDepth, const std::vector< RefPositionBias > &refPositionBiases, std::vector< StitchParams > &results, const std::optional< cv::Point3f > &knownYAxisMoveDir=std::nullopt)
Performs width-expansion calibration for a single profiler based on two depth maps captured at differ...
ProfilerHandEyeErrorStatus transformPointFromProfilerCoord2TrussRobotCoord(const cv::Point3f &profilerPoint, const cv::Point3f &profilerCapturePosition, const TrussRobotCalibResult &calibResult, cv::Point3f &dstPoint, const std::optional< cv::Point3f > &tcpOffSet=std::nullopt)
Obtain the calibration result function.
MultiProfilerErrorStatus correctProfilerMoveDir(const cv::Point3f &moveDirVec, const ProfilerImage &srcImage, CorrectedResult &result, const MoveDirCorrectionOptions &options={})
Correct the profiler output based on its movement direction.
MultiProfilerErrorStatus calculateCalibration(const cv::Mat &majorDepth, const std::vector< cv::Mat > &minorDepths, std::vector< CalibResult > &calibResults, bool unifiedMoveDirection=true, const std::optional< cv::Point3f > &majorCameraMoveDirVec=std::nullopt)
Calculates the calibration results based on the depth maps acquired by the primary and secondary lase...
MultiProfilerErrorStatus imageFusionForZParallel(FusionResult &fusionResult, const std::vector< bool > &fusionFlag={})
Performs fusion based on the stitching results when the laser profilers are arranged in the Wide mode...
MultiProfilerErrorStatus getStitchedPointCloud(ProfileBatch::UntexturedPointCloud &pointCloud) const
Retrieves the stitched point cloud based on the stitching results.
DeviceInfo getMajorDeviceInfo() const
Gets the major device information. This function retrieves the information of the primary device used...
MultiProfilerErrorStatus stitchImagesForZParallel(const ProfilerImage &majorImage, const std::vector< ProfilerImage > &minorImages, const std::vector< CalibResult > &calibResults, MultiStitchResultZParallel &stitchResults, const std::optional< MultiStitchParams > &stitchParams=std::nullopt)
Calculates the stitching results when the laser profilers are arranged in the Wide mode (i....
MultiProfilerErrorStatus calibrateSingleProfilerMoveDirection(const cv::Mat &firstDepth, const cv::Mat &secondDepth, ProfilerMovementAxis moveAxis, MoveDirCalibResult &calibResult, const std::optional< cv::Point3f > &knownYAxisMoveDir=std::nullopt)
Calibrates the scanning movement direction of a single profiler based two depth maps acquired along a...
TargetSize getTargetSize() const
Gets the target size. This function retrieves the size of the calibration target.
std::vector< DeviceInfo > getMinorDeviceInfos() const
Gets the minor devices' information. This function retrieves a list of information for all minor devi...
void setCalibTargetPoses(const std::vector< TargetPose > &targetPoses)
Defines the relative position of the frustums of the calibration target.
void setMajorDeviceInfo(const DeviceInfo &deviceInfo)
Initializes the configuration for the primary laser profiler.
std::string getCameraModel() const
Gets the camera model identifier. This function retrieves the model name of the profiler.
ProfilerCalibrationInterfaces(const std::string &cameraModel, const DeviceInfo &profilerDeviceInfo, const TargetSize &targetSize, const std::vector< TargetPose > &targetPoses)
Constructs a new ProfilerCalibrationInterfaces object with specified parameters. This constructor ini...
MultiProfilerErrorStatus getStitchedPointCloud(ProfileBatch::TexturedPointCloud &texturedPointCloud) const
Retrieves the stitched point cloud based on the stitching results, including texture information.
MultiProfilerErrorStatus loadCalibProperties(const std::string &loadFolderName="", bool needLoadAll=false)
Loads the calibration data from the files in the specified path, typically used before stitching star...
bool saveStitchFilesForZParallel(const std::string &saveFolderName="") const
Saves the stitching results to files in the specified path when the laser profilers are arranged in t...
MultiProfilerErrorStatus stitchProfilerWidthExpansion(const ImageInfo &majorImageInfo, const std::vector< ImageInfo > &minorImageInfos, const WidthExpansionType &type, FusionResult &results, const std::vector< StitchParams > &multiParams, bool fusionFlag, const std::vector< bool > &moveConsistentFlags)
Perform width-expansion stitching for a single profiler (S/Z-type scanning).
Defines the configuration for each laser profiler.
Image information used for stitching and correction.
Results of the movement-direction calibration for a single profiler.
Set custom size/resolution (to prevent data loss).
Stores the stitching results.
The stitching results when the laser profilers are arranged in the Wide mode (i.e....
Stores the intensity image and depth map acquired by the laser profiler.
Defines the dimensions of the frustums of the calibration target.
Configuration parameters for truss robot calibration.
Truss Robot Calibration Result.