From 6983f3ca57ef01c8794f5afc1e6726f8af49552c Mon Sep 17 00:00:00 2001 From: builder Date: Thu, 10 Oct 2024 12:29:42 +0000 Subject: [PATCH] Samples: Automatic updates to public repository Remember to do the following: 1. Ensure that modified/deleted/new files are correct 2. Make this commit message relevant for the changes 3. Force push 4. Delete branch after PR is merged If this commit is an update from one SDK version to another, make sure to create a release tag for previous version. --- .../UtilizeHandEyeCalibration.cpp | 18 +++++++++--------- .../ROIBoxViaArucoMarker.cpp | 4 ++-- .../ReprojectPoints/ReprojectPoints.cpp | 15 ++++++++------- ...nsformPointCloudFromMillimetersToMeters.cpp | 4 ++-- .../TransformPointCloudViaArucoMarker.cpp | 8 ++++---- .../TransformPointCloudViaCheckerboard.cpp | 14 +++++++------- source/Applications/PointCloudTutorial.md | 2 +- 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/source/Applications/Advanced/HandEyeCalibration/UtilizeHandEyeCalibration/UtilizeHandEyeCalibration.cpp b/source/Applications/Advanced/HandEyeCalibration/UtilizeHandEyeCalibration/UtilizeHandEyeCalibration.cpp index ade136ad..a7f79c37 100644 --- a/source/Applications/Advanced/HandEyeCalibration/UtilizeHandEyeCalibration/UtilizeHandEyeCalibration.cpp +++ b/source/Applications/Advanced/HandEyeCalibration/UtilizeHandEyeCalibration/UtilizeHandEyeCalibration.cpp @@ -128,7 +128,7 @@ int main() std::string fileName; size_t imageCoordinateX = 0; size_t imageCoordinateY = 0; - Zivid::Matrix4x4 transformBaseToCamera; + Zivid::Matrix4x4 baseToCameraTransform; bool loopContinue = true; while(loopContinue) @@ -148,7 +148,7 @@ int main() std::cout << "Reading camera pose in robot base reference frame (result of eye-to-hand calibration" << std::endl; - transformBaseToCamera.load(std::string(ZIVID_SAMPLE_DATA_DIR) + eyeToHandTransformFile); + baseToCameraTransform.load(std::string(ZIVID_SAMPLE_DATA_DIR) + eyeToHandTransformFile); loopContinue = false; break; @@ -168,16 +168,16 @@ int main() std::cout << "Reading camera pose in end-effector reference frame (result of eye-in-hand calibration)" << std::endl; - Zivid::Matrix4x4 transformEndEffectorToCamera( + Zivid::Matrix4x4 endEffectorToCameraTransform( std::string(ZIVID_SAMPLE_DATA_DIR) + eyeInHandTransformFile); std::cout << "Reading end-effector pose in robot base reference frame" << std::endl; - Zivid::Matrix4x4 transformBaseToEndEffector( + Zivid::Matrix4x4 baseToEndEffectorTransform( std::string(ZIVID_SAMPLE_DATA_DIR) + robotTransformFile); std::cout << "Computing camera pose in robot base reference frame" << std::endl; - transformBaseToCamera = eigenToZivid( - zividToEigen(transformBaseToEndEffector) * zividToEigen(transformEndEffectorToCamera)); + baseToCameraTransform = eigenToZivid( + zividToEigen(baseToEndEffectorTransform) * zividToEigen(endEffectorToCameraTransform)); loopContinue = false; break; @@ -216,10 +216,10 @@ int main() << pointInCameraFrame.y() << " " << pointInCameraFrame.z() << std::endl; // Converting to Eigen matrix for easier computation - const Eigen::Affine3f transformBaseToCameraEigen = zividToEigen(transformBaseToCamera); + const Eigen::Affine3f baseToCameraTransformEigen = zividToEigen(baseToCameraTransform); std::cout << "Transforming (picking) point from camera to robot base reference frame" << std::endl; - const Eigen::Vector4f pointInBaseFrame = transformBaseToCameraEigen * pointInCameraFrame; + const Eigen::Vector4f pointInBaseFrame = baseToCameraTransformEigen * pointInCameraFrame; std::cout << "Point coordinates in robot base reference frame: " << pointInBaseFrame.x() << " " << pointInBaseFrame.y() << " " << pointInBaseFrame.z() << std::endl; @@ -231,7 +231,7 @@ int main() { std::cout << "Transforming point cloud" << std::endl; - pointCloud.transform(transformBaseToCamera); + pointCloud.transform(baseToCameraTransform); const auto saveFile = "ZividGemTransformed.zdf"; std::cout << "Saving point cloud to file: " << saveFile << std::endl; diff --git a/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cpp b/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cpp index f4b30733..1ab0accb 100644 --- a/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cpp +++ b/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cpp @@ -141,12 +141,12 @@ int main() } std::cout << "Estimating pose of detected ArUco marker" << std::endl; - const auto transformCameraToMarker = detectionResult.detectedMarkers()[0].pose().toMatrix(); + const auto cameraToMarkerTransform = detectionResult.detectedMarkers()[0].pose().toMatrix(); std::cout << "Transforming the ROI base frame points to the camera frame" << std::endl; const auto roiPointsInCameraFrame = transformPoints( std::vector{ pointOInArUcoFrame, pointAInArUcoFrame, pointBInArUcoFrame }, - transformCameraToMarker); + cameraToMarkerTransform); std::cout << "Setting the ROI" << std::endl; settings.set(Zivid::Settings::RegionOfInterest{ diff --git a/source/Applications/Advanced/ReprojectPoints/ReprojectPoints.cpp b/source/Applications/Advanced/ReprojectPoints/ReprojectPoints.cpp index 4f3fa578..475238fe 100644 --- a/source/Applications/Advanced/ReprojectPoints/ReprojectPoints.cpp +++ b/source/Applications/Advanced/ReprojectPoints/ReprojectPoints.cpp @@ -37,12 +37,12 @@ namespace } - std::vector transformGridToCalibrationBoard( + std::vector transformGridToCameraFrame( const std::vector &grid, - const Zivid::Matrix4x4 &transformCameraToCheckerboard) + const Zivid::Matrix4x4 &cameraToCheckerboardTransform) { std::vector pointsInCameraFrame; - const auto transformationMatrix = cv::Matx44f{ transformCameraToCheckerboard.data() }; + const auto transformationMatrix = cv::Matx44f{ cameraToCheckerboardTransform.data() }; for(const auto &point : grid) { const auto transformedPoint = transformationMatrix * point; @@ -87,15 +87,16 @@ int main() } std::cout << "Estimating checkerboard pose" << std::endl; - const auto transformCameraToCheckerboard = detectionResult.pose().toMatrix(); - std::cout << transformCameraToCheckerboard << std::endl; + const auto cameraToCheckerboardTransform = detectionResult.pose().toMatrix(); + std::cout << cameraToCheckerboardTransform << std::endl; std::cout << "Creating a grid of 7 x 6 points (3D) with 30 mm spacing to match checkerboard corners" << std::endl; - const auto grid = checkerboardGrid(); + const auto gridInCheckerboardFrame = checkerboardGrid(); std::cout << "Transforming the grid to the camera frame" << std::endl; - const auto pointsInCameraFrame = transformGridToCalibrationBoard(grid, transformCameraToCheckerboard); + const auto pointsInCameraFrame = + transformGridToCameraFrame(gridInCheckerboardFrame, cameraToCheckerboardTransform); std::cout << "Getting projector pixels (2D) corresponding to points (3D) in the camera frame" << std::endl; const auto projectorPixels = Zivid::Projection::pixelsFrom3DPoints(camera, pointsInCameraFrame); diff --git a/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cpp b/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cpp index 735b388b..5d8c8b7a 100644 --- a/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cpp +++ b/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cpp @@ -20,11 +20,11 @@ int main() auto frame = Zivid::Frame(dataFile); auto pointCloud = frame.pointCloud(); - const auto transformMillimetersToMeters = + const auto millimetersToMetersTransform = Zivid::Matrix4x4{ { 0.001F, 0, 0, 0 }, { 0, 0.001F, 0, 0 }, { 0, 0, 0.001F, 0 }, { 0, 0, 0, 1 } }; std::cout << "Transforming point cloud from mm to m" << std::endl; - pointCloud.transform(transformMillimetersToMeters); + pointCloud.transform(millimetersToMetersTransform); const auto transformedFile = "FrameInMeters.zdf"; std::cout << "Saving transformed point cloud to file: " << transformedFile << std::endl; diff --git a/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cpp b/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cpp index c9457b78..d31d34a2 100644 --- a/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cpp +++ b/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cpp @@ -107,15 +107,15 @@ int main() std::cout << "ArUco marker pose in camera frame:" << std::endl; std::cout << transformCameraToMarker << std::endl; std::cout << "Camera pose in ArUco marker frame:" << std::endl; - const auto transformMarkerToCamera = transformCameraToMarker.inverse(); - std::cout << transformMarkerToCamera << std::endl; + const auto markerToCameraTransform = transformCameraToMarker.inverse(); + std::cout << markerToCameraTransform << std::endl; const auto transformFile = "ArUcoMarkerToCameraTransform.yaml"; std::cout << "Saving a YAML file with Inverted ArUco marker pose to file: " << transformFile << std::endl; - transformMarkerToCamera.save(transformFile); + markerToCameraTransform.save(transformFile); std::cout << "Transforming point cloud from camera frame to ArUco marker frame" << std::endl; - pointCloud.transform(transformMarkerToCamera); + pointCloud.transform(markerToCameraTransform); const auto arucoMarkerTransformedFile = "CalibrationBoardInArucoMarkerOrigin.zdf"; std::cout << "Saving transformed point cloud to file: " << arucoMarkerTransformedFile << std::endl; diff --git a/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cpp b/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cpp index 2c08b135..4a59cf24 100644 --- a/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cpp +++ b/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cpp @@ -171,24 +171,24 @@ int main() std::cout << "Detecting and estimating pose of the Zivid checkerboard in the camera frame" << std::endl; const auto detectionResult = Zivid::Calibration::detectCalibrationBoard(frame); - const auto transformCameraToCheckerboard = detectionResult.pose().toMatrix(); - std::cout << transformCameraToCheckerboard << std::endl; + const auto cameraToCheckerboardTransform = detectionResult.pose().toMatrix(); + std::cout << cameraToCheckerboardTransform << std::endl; std::cout << "Camera pose in checkerboard frame:" << std::endl; - const auto transformCheckerboardToCamera = transformCameraToCheckerboard.inverse(); - std::cout << transformCheckerboardToCamera << std::endl; + const auto checkerboardToCameraTransform = cameraToCheckerboardTransform.inverse(); + std::cout << checkerboardToCameraTransform << std::endl; const auto transformFile = "CheckerboardToCameraTransform.yaml"; std::cout << "Saving a YAML file with Inverted checkerboard pose to file: " << transformFile << std::endl; - transformCheckerboardToCamera.save(transformFile); + checkerboardToCameraTransform.save(transformFile); std::cout << "Transforming point cloud from camera frame to Checkerboard frame" << std::endl; - pointCloud.transform(transformCheckerboardToCamera); + pointCloud.transform(checkerboardToCameraTransform); std::cout << "Converting to OpenCV image format" << std::endl; const auto bgraImage = pointCloudToColorBGRA(pointCloud); std::cout << "Visualizing checkerboard with coordinate system" << std::endl; - drawCoordinateSystem(frame, transformCameraToCheckerboard, bgraImage); + drawCoordinateSystem(frame, cameraToCheckerboardTransform, bgraImage); displayBGRA(bgraImage, "Checkerboard transformation frame"); const auto checkerboardTransformedFile = "CalibrationBoardInCheckerboardOrigin.zdf"; diff --git a/source/Applications/PointCloudTutorial.md b/source/Applications/PointCloudTutorial.md index 290cba79..582668e5 100644 --- a/source/Applications/PointCloudTutorial.md +++ b/source/Applications/PointCloudTutorial.md @@ -223,7 +223,7 @@ m](https://support.zivid.com/latest//academy/applications/transform/transform-mi source](https://github.com/zivid/zivid-cpp-samples/tree/master//source/Applications/Advanced/HandEyeCalibration/UtilizeHandEyeCalibration/UtilizeHandEyeCalibration.cpp#L234)) ``` sourceCode cpp -pointCloud.transform(transformBaseToCamera); +pointCloud.transform(baseToCameraTransform); ``` ## Downsample