Hello, I'm a newbie with emgu cv and the code thingy. And currently i have a camera calibration code using emgucv, and i want to add a code to compute extrinsic parameters here.. Umm but i don't know which one yo add and how.. So anyone can help me? Here is the code for camera calibration..
#region Methods
public void Solve()
{
MCvPoint3D32f[][] platePointsperView = new MCvPoint3D32f[_imageNumber][];
PointF[][] crossesperView = new PointF[_imageNumber][];
int index = 0;
Trace.WriteLine("Camera Calibration");
foreach (Crosses crosses in _crosses.CrossesOnImage)
{
ComposeInputPerView(crosses, ref crossesperView[index], ref platePointsperView[index]);
index++;
}
CameraCalibration.CalibrateCamera(platePointsperView, crossesperView,
_imageSize,
_ioParams,
Emgu.CV.CvEnum.CALIB_TYPE.DEFAULT,
out _eoParams);
DisplayIOParams(_ioParams);
double fovx =0.0;
double fovy=0.0;
double focal=0.0;
MCvPoint2D64f pp = new MCvPoint2D64f();
double aspect = 0.0;
CvInvoke.cvCalibrationMatrixValues(_ioParams.IntrinsicMatrix, _imageSize.Width, _imageSize.Height,
4.9, 3.7, ref fovx, ref fovy, ref focal, ref pp, ref aspect);
Trace.WriteLine("fovx = " + fovx.ToString());
Trace.WriteLine("fovy = " + fovy.ToString());
Trace.WriteLine("focal = " + focal.ToString());
Trace.WriteLine("aspect ratio = " + aspect.ToString());
Trace.WriteLine("principal point x,y: " + pp.x.ToString() + " , " + pp.y.ToString());
PrintCalibrationParameters();
}
private void ComposeInputPerView(Crosses crosses, ref PointF[] imgPoints, ref MCvPoint3D32f[] platePoints)
{
IEnumerable<Cross> sortedCrossPoints = from crossPt in crosses.CrossPoints
orderby (int.Parse(crossPt.LabelName))
select crossPt;
List<PointF> tempCross = new List<PointF>();
foreach (Cross c in sortedCrossPoints)
{
PointF pt = new PointF(c.Point2D.X, c.Point2D.Y);
tempCross.Add(pt);
}
imgPoints = tempCross.ToArray();
List<MCvPoint3D32f> ptsCv = new List<MCvPoint3D32f>();
foreach (Cross c in sortedCrossPoints)
{
String label = c.LabelName;
foreach (PlateCalibrationPoint pt in _plateCoord.PlatePoints)
{
if (int.Parse(label) == int.Parse(pt.Label))
{
MCvPoint3D32f p = new MCvPoint3D32f(pt.Point2D.X, pt.Point2D.Y, 0.0f);
ptsCv.Add(p);
}
}
}
platePoints = ptsCv.ToArray();
}
private void DisplayIOParams(IntrinsicCameraParameters io)
{
Trace.WriteLine("Intrinsic Camera Parameters:");
Trace.WriteLine(io.IntrinsicMatrix.Data.ToString());
}
private PointF[] ComposeInputCrossesCoordPerView(Crosses crosses)
{
PointF[] temp = new PointF[2];
return temp;
}
private void PrintIntrinsicMatrix()
{
Trace.WriteLine("Intrinsic Matrix:");
String line1 = String.Format("{0} {1} {2}", _ioParams.IntrinsicMatrix[0, 0], _ioParams.IntrinsicMatrix[0, 1],
_ioParams.IntrinsicMatrix[0, 2]);
String line2 = String.Format("{0} {1} {2}", _ioParams.IntrinsicMatrix[1, 0], _ioParams.IntrinsicMatrix[1, 1],
_ioParams.IntrinsicMatrix[1, 2]);
String line3 = String.Format("{0} {1} {2}", _ioParams.IntrinsicMatrix[2, 0], _ioParams.IntrinsicMatrix[2, 1],
_ioParams.IntrinsicMatrix[2, 2]);
Trace.WriteLine(line1);
Trace.WriteLine(line2);
Trace.WriteLine(line3);
}
private void PrintCalibrationParameters()
{
Trace.WriteLine("k1: " + _ioParams.DistortionCoeffs[0, 0].ToString());
Trace.WriteLine("k2: " + _ioParams.DistortionCoeffs[1, 0].ToString());
Trace.WriteLine("p1: " + _ioParams.DistortionCoeffs[2, 0].ToString());
Trace.WriteLine("p2: " + _ioParams.DistortionCoeffs[3, 0].ToString());
Trace.WriteLine("k3: " + _ioParams.DistortionCoeffs[4, 0].ToString());
PrintIntrinsicMatrix();
}
#endregion
}
}
What I have tried:
I tried looking at emgucv webpage but i still didnt get it..