Skip to content

Commit

Permalink
Nail down transformation matrix convention
Browse files Browse the repository at this point in the history
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
  • Loading branch information
csu-bot-zivid authored and SatjaSivcev committed Aug 7, 2024
1 parent 6b444f4 commit c8f438a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Zivid.NET.PointXYZ> { pointOInCheckerboardFrame, pointAInCheckerboardFrame, pointBInCheckerboardFrame },
transformCameraToMarker);
cameraToMarkerTransform);

Console.WriteLine("Setting the ROI");
settings.RegionOfInterest.Box.Enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Zivid.NET.PointXYZ> { pointOInCheckerboardFrame, pointAInCheckerboardFrame, pointBInCheckerboardFrame },
transformCameraToCheckerboard);
cameraToCheckerboardTransform);

Console.WriteLine("Setting the ROI");
settings.RegionOfInterest.Box.Enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c8f438a

Please sign in to comment.