Replies: 1 comment
-
Seems like an Emgu CV (not Emgu TF) discussion. Duplicate to this: Closing this dicussion for now. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear emgucv user,
I hope , all of you are fine and that i can find a solution for my problem here. For about 5 months I'm programming with csharp using emgu.cv .The paragraph below describe what i did till now.
So now I'm having the image coordinates and the object coordinates and I wish to use the CvInvoke.CalibrateCamera to get out with the projection matrix and the camera matrix. But it is not working since. Please I need help
--------- Below is my code --------------------------------------------------
public static void Test(List finalPoints, Image<Gray,byte> image)
{
// Liste imagepoints
List imagePoints = new List();
List imagesP = new List();
for (int i = 0; i < finalPoints.Count; i++)
{
imagesP.Add(new PointF() {X = (float)finalPoints[i].OriginalCenter.X ,Y=(float) finalPoints[i].OriginalCenter.Y });
}
VectorOfPointF imagePointsvector = new VectorOfPointF();
imagePointsvector.Push(imagesP.ToArray());
for (int i = 0; i < finalPoints.Count; i++)
{
imagePoints.Add(imagePointsvector);
}
// Konvertieren Sie die List in ein Array von PointF-Arrays
PointF[][] imagePointsArray = imagePoints.Select(vp => vp.ToArray().Select(p => new PointF((float)p.X, (float)p.Y)).ToArray()).ToArray();
//-------------------
// Liste objectpoints
List<MCvPoint3D32f[]> objectPoints = new List<MCvPoint3D32f[]>();
List objectP = new List();
for (int i = 0; i < finalPoints.Count; i++)
{
objectP.Add(new MCvPoint3D32f() { X = (float)finalPoints[i].OriginalCenter.X, Y = (float)finalPoints[i].OriginalCenter.Y ,
Z = (float)finalPoints[i].OriginalCenter.Z });
}
MCvPoint3D32f[] objectPointsvector = new MCvPoint3D32f[objectPoints.Count];
Array.Copy(objectP.ToArray() , objectPointsvector , objectPointsvector.Length);
for (int i = 0; i < finalPoints.Count; i++)
{
objectPoints.Add(objectPointsvector);
}
// Konvertierung die List<MCvPoint3D32f[]> in ein Array von MCvPoint3D32f[][]
MCvPoint3D32f[][] objectPointsArray = objectPoints.Select(vp => vp.ToArray().Select(p => new MCvPoint3D32f((float)p.X, (float)p.Y ,
(float)p.Z)).ToArray()).ToArray();
// Kalibrierte Kamera-Matrix und Verzerrungskoeffizienten
Mat cameraMatrix = new Mat(3, 3, DepthType.Cv64F, 1);
Mat distortionCoeffs = new Mat(5, 1, DepthType.Cv64F, 1);
Mat[] rotationVectors ;
Mat[] translationVectors ;
CvInvoke.CalibrateCamera(objectPointsArray, imagePointsArray, new Size(image.Width,image.Height), cameraMatrix,
distortionCoeffs,CalibType.FixK6, new MCvTermCriteria(1), out rotationVectors, out translationVectors);
}
Beta Was this translation helpful? Give feedback.
All reactions