public void CodeCameraExtrinsics(ref CameraExtrinsics v) { var rotation = default(M33d); var translation = default(V3d); CodeM33d(ref rotation); CodeV3d(ref translation); v = new CameraExtrinsics(rotation, translation); }
public void CodeCameraExtrinsics(ref CameraExtrinsics v) { var rotation = v.Rotation; var translation = v.Translation; CodeM33d(ref rotation); CodeV3d(ref translation); }
/// <summary> /// Assesses the provided image for ArUco markers /// </summary> /// <param name="imageData"></param> /// <param name="imageWidth"></param> /// <param name="imageHeight"></param> /// <param name="pixelFormat"></param> /// <param name="intrinsics"></param> /// <param name="extrinsics"></param> /// <returns></returns> public Dictionary <int, Marker> ProcessImage( byte[] imageData, uint imageWidth, uint imageHeight, PixelFormat pixelFormat, CameraIntrinsics intrinsics, CameraExtrinsics extrinsics) { var dictionary = new Dictionary <int, Marker>(); if (!IsInitialized) { Debug.LogError("Process image called but SpectatorViewPlugin.dll did not initialize correctly"); return(dictionary); } if (!IsValidPixelFormat(pixelFormat)) { Debug.LogError("Error: SpectatorViewPlugin.dll expects BGRA pixel format, actual pixel format: " + pixelFormat.ToString()); return(dictionary); } var focalLength = new float[2]; focalLength[0] = intrinsics.FocalLength.x; focalLength[1] = intrinsics.FocalLength.y; var principalPoint = new float[2]; principalPoint[0] = intrinsics.PrincipalPoint.x; principalPoint[1] = intrinsics.PrincipalPoint.y; var radialDistortion = new float[3]; radialDistortion[0] = intrinsics.RadialDistortion.x; radialDistortion[1] = intrinsics.RadialDistortion.y; radialDistortion[2] = intrinsics.RadialDistortion.z; var tangentialDistortion = new float[2]; tangentialDistortion[0] = intrinsics.TangentialDistortion.x; tangentialDistortion[1] = intrinsics.TangentialDistortion.y; if (DetectMarkersNative( imageData, (int)imageWidth, (int)imageHeight, focalLength, principalPoint, radialDistortion, tangentialDistortion, _markerSize, _arucoDictionaryId)) { int count = GetDetectedMarkersCountNative(); if (count > 0) { var ids = new int[count]; if (GetDetectedMarkerIdsNative(ids, ids.Length)) { var cameraToWorldMatrix = extrinsics.ViewFromWorld; for (int i = 0; i < ids.Length; i++) { var id = ids[i]; var position = new float[3]; var rotation = new float[3]; if (GetDetectedMarkerPoseNative(id, position, rotation)) { Vector3 positionInOpenCVCameraSpace = new Vector3(position[0], -position[1], position[2]); // The below logic ensures the following marker orientation: // Positive x axis is in the left direction of the observed marker // Positive y axis is in the upward direction of the observed marker // Positive z axis is facing outward from the observed marker Vector3 rodriguesVector = new Vector3(rotation[0], rotation[1], rotation[2]); Marker marker = CreateMarkerFromPositionAndRotation(id, positionInOpenCVCameraSpace, rodriguesVector, cameraToWorldMatrix); Debug.Log("Marker detected: " + marker.ToString()); dictionary[id] = marker; } else { Debug.LogError("Unable to obtain pose for marker: " + id); } } } else { Debug.LogWarning("Unable to obtain marker ids"); } } } else { Debug.LogError("Unable to detect markers"); } return(dictionary); }
public void Write(CameraExtrinsics c) { Write(c.Rotation); Write(c.Translation); }
public static extern Result ovr_SetExternalCameraProperties(ovrSession session, String name, ref CameraIntrinsics intrinsics, ref CameraExtrinsics extrinsics);
public void CodeCameraExtrinsics(ref CameraExtrinsics v) { throw new NotSupportedException("cannot serialize single camera"); }