From c8f438ac728e8f8cbfab904eaf2b16bff6162835 Mon Sep 17 00:00:00 2001 From: builder Date: Tue, 6 Aug 2024 15:31:08 +0000 Subject: [PATCH] Nail down transformation matrix convention This commit modifies variable names of transformation matrices. The naming is based on the convention explained at: https://support.zivid.com/en/latest/reference-articles/position-orientation-coordinate-transform.html --- .../ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cs | 4 ++-- .../ROIBoxViaCheckerboard/ROIBoxViaCheckerboard.cs | 4 ++-- .../TransformPointCloudFromMillimetersToMeters.cs | 4 ++-- .../TransformPointCloudViaArucoMarker.cs | 12 ++++++------ .../TransformPointCloudViaCheckerboard.cs | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cs b/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cs index 60903f3..a27ba51 100644 --- a/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cs +++ b/source/Applications/Advanced/ROIBoxViaArucoMarker/ROIBoxViaArucoMarker.cs @@ -81,12 +81,12 @@ static int Main() } Console.WriteLine("Estimating pose of detected ArUco marker"); - var transformCameraToMarker = new Zivid.NET.Matrix4x4(detectionResult.DetectedMarkers()[0].Pose().ToMatrix()); + var cameraToMarkerTransform = new Zivid.NET.Matrix4x4(detectionResult.DetectedMarkers()[0].Pose().ToMatrix()); Console.WriteLine("Transforming the ROI base frame points to the camera frame"); var roiPointsInCameraFrame = TransformPoints( new List { pointOInCheckerboardFrame, pointAInCheckerboardFrame, pointBInCheckerboardFrame }, - transformCameraToMarker); + cameraToMarkerTransform); Console.WriteLine("Setting the ROI"); settings.RegionOfInterest.Box.Enabled = true; diff --git a/source/Applications/Advanced/ROIBoxViaCheckerboard/ROIBoxViaCheckerboard.cs b/source/Applications/Advanced/ROIBoxViaCheckerboard/ROIBoxViaCheckerboard.cs index 6c6d33d..2f0db63 100644 --- a/source/Applications/Advanced/ROIBoxViaCheckerboard/ROIBoxViaCheckerboard.cs +++ b/source/Applications/Advanced/ROIBoxViaCheckerboard/ROIBoxViaCheckerboard.cs @@ -69,12 +69,12 @@ static int Main() Console.WriteLine("Detecting and estimating pose of the Zivid checkerboard in the camera frame"); var detectionResult = Detector.DetectCalibrationBoard(originalFrame); - var transformCameraToCheckerboard = new Zivid.NET.Matrix4x4(detectionResult.Pose().ToMatrix()); + var cameraToCheckerboardTransform = new Zivid.NET.Matrix4x4(detectionResult.Pose().ToMatrix()); Console.WriteLine("Transforming the ROI base frame points to the camera frame"); var roiPointsInCameraFrame = TransformPoints( new List { pointOInCheckerboardFrame, pointAInCheckerboardFrame, pointBInCheckerboardFrame }, - transformCameraToCheckerboard); + cameraToCheckerboardTransform); Console.WriteLine("Setting the ROI"); settings.RegionOfInterest.Box.Enabled = true; diff --git a/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cs b/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cs index c5e3d23..3f3825e 100644 --- a/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cs +++ b/source/Applications/Advanced/TransformPointCloudFromMillimetersToMeters/TransformPointCloudFromMillimetersToMeters.cs @@ -20,11 +20,11 @@ static int Main() var frame = new Zivid.NET.Frame(dataFile); var pointCloud = frame.PointCloud; - var transformMillimetersToMeters = + var millimetersToMetersTransform = new float[,] { { 0.001F, 0, 0, 0 }, { 0, 0.001F, 0, 0 }, { 0, 0, 0.001F, 0 }, { 0, 0, 0, 1 } }; Console.WriteLine("Transforming point cloud from mm to m"); - pointCloud.Transform(transformMillimetersToMeters); + pointCloud.Transform(millimetersToMetersTransform); var transformedFile = "FrameInMeters.zdf"; Console.WriteLine("Saving frame to file: " + transformedFile); diff --git a/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cs b/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cs index c885836..d85aa4f 100644 --- a/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cs +++ b/source/Applications/Advanced/TransformPointCloudViaArucoMarker/TransformPointCloudViaArucoMarker.cs @@ -30,19 +30,19 @@ static int Main() var detectionResult = Detector.DetectMarkers(frame, markerId, markerDictionary); Console.WriteLine("Estimating pose of detected ArUco marker"); - var transformCameraToMarker = new Zivid.NET.Matrix4x4(detectionResult.DetectedMarkers()[0].Pose().ToMatrix()); + var cameraToMarkerTransform = new Zivid.NET.Matrix4x4(detectionResult.DetectedMarkers()[0].Pose().ToMatrix()); Console.WriteLine("ArUco marker pose in camera frame:"); - Console.WriteLine(transformCameraToMarker); + Console.WriteLine(cameraToMarkerTransform); Console.WriteLine("Camera pose in ArUco marker frame:"); - var transformMarkerToCamera = transformCameraToMarker.Inverse(); - Console.WriteLine(transformMarkerToCamera); + var markerToCameraTransform = cameraToMarkerTransform.Inverse(); + Console.WriteLine(markerToCameraTransform); var transformFile = "ArUcoMarkerToCameraTransform.yaml"; Console.WriteLine("Saving a YAML file with Inverted ArUco marker pose to file: " + transformFile); - transformMarkerToCamera.Save(transformFile); + markerToCameraTransform.Save(transformFile); Console.WriteLine("Transforming point cloud from camera frame to ArUco marker frame"); - pointCloud.Transform(transformMarkerToCamera); + pointCloud.Transform(markerToCameraTransform); var arucoMarkerTransformedFile = "CalibrationBoardInArucoMarkerOrigin.zdf"; Console.WriteLine("Saving transformed point cloud to file: " + arucoMarkerTransformedFile); diff --git a/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cs b/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cs index 31e9904..af5ba9a 100644 --- a/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cs +++ b/source/Applications/Advanced/TransformPointCloudViaCheckerboard/TransformPointCloudViaCheckerboard.cs @@ -24,18 +24,18 @@ static int Main() Console.WriteLine("Detecting and estimating pose of the Zivid checkerboard in the camera frame"); var detectionResult = Detector.DetectCalibrationBoard(frame); - var transformCameraToCheckerboard = new Zivid.NET.Matrix4x4(detectionResult.Pose().ToMatrix()); - Console.WriteLine(transformCameraToCheckerboard); + var cameraToCheckerboardTransform = new Zivid.NET.Matrix4x4(detectionResult.Pose().ToMatrix()); + Console.WriteLine(cameraToCheckerboardTransform); Console.WriteLine("Camera pose in checkerboard frame:"); - var transformCheckerboardToCamera = transformCameraToCheckerboard.Inverse(); - Console.WriteLine(transformCheckerboardToCamera); + var checkerboardToCameraTransform = cameraToCheckerboardTransform.Inverse(); + Console.WriteLine(checkerboardToCameraTransform); var transformFile = "CheckerboardToCameraTransform.yaml"; Console.WriteLine("Saving a YAML file with Inverted checkerboard pose to file: " + transformFile); - transformCheckerboardToCamera.Save(transformFile); + checkerboardToCameraTransform.Save(transformFile); Console.WriteLine("Transforming point cloud from camera frame to Checkerboard frame"); - pointCloud.Transform(transformCheckerboardToCamera); + pointCloud.Transform(checkerboardToCameraTransform); var checkerboardTransformedFile = "CalibrationBoardInCheckerboardOrigin.zdf"; Console.WriteLine("Saving transformed point cloud to file: " + checkerboardTransformedFile);