/// <summary> /// Overrides the standard GetIntrinsic method. /// </summary> /// <param name="channelName">The channel name.</param> /// <returns>The ProjectiveTransformationZhang</returns> /// <remarks>The method first searches for a pt file on disk. If this fails it is able to provide internal intrinsics for ZImage channel.</remarks> public override IProjectiveTransformation GetIntrinsics(string channelName) { IProjectiveTransformation result = null; log.Info("Trying to load projective transformation from file."); try { return(base.GetIntrinsics(channelName)); } catch { /* empty */ } if (result == null) { log.Info("Projective transformation file not found. Using R200 factory intrinsics as projective transformation."); switch (channelName) { case ChannelNames.ZImage: result = new ProjectiveTransformationZhang(widthZImage, heightZImage, calibDataDepth.focalLength.x, calibDataDepth.focalLength.y, calibDataDepth.principalPoint.x, calibDataDepth.principalPoint.y, calibDataDepth.radialDistortion[0], calibDataDepth.radialDistortion[1], calibDataDepth.radialDistortion[2], calibDataDepth.tangentialDistortion[0], calibDataDepth.tangentialDistortion[1]); break; case ChannelNames.Color: result = new ProjectiveTransformationZhang(widthColor, heightColor, calibDataColor.focalLength.x, calibDataColor.focalLength.y, calibDataColor.principalPoint.x, calibDataColor.principalPoint.y, calibDataColor.radialDistortion[0], calibDataColor.radialDistortion[1], calibDataColor.radialDistortion[2], calibDataColor.tangentialDistortion[0], calibDataColor.tangentialDistortion[1]); break; default: log.Error("Unsupported channel in GetIntrinsics()."); throw new ArgumentException("Unsupported channel " + channelName + " in GetIntrinsics()."); } } return(result); }
/// <summary> /// Loads the intrisic parameters from the camera. /// </summary> /// <param name="channelName">Channel for which intrisics are loaded.</param> /// <returns>ProjectiveTransformationZhang object holding the intrinsics.</returns> public override IProjectiveTransformation GetIntrinsics(string channelName) { if (channelName == ChannelNames.Intensity || channelName == ChannelNames.Distance) { ProjectiveTransformationZhang proj; lock (cameraLock) { proj = new ProjectiveTransformationZhang(imageData.Width, imageData.Height, imageData.FX, imageData.FY, imageData.CX, imageData.CY, imageData.K1, imageData.K2, 0, 0, 0); } return(proj); } throw new ArgumentException(string.Format("Channel {0} intrinsics not supported.", channelName)); }