本文介绍了过载错误C# - 摄像机校准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我用c#进行了相机校准,这个错误就是我得到的。任何人都可以帮我,我该怎么办?这是我的代码 #region方法 public void Solve() { MCvPoint3D32f [] [] platePointsperView = new MCvPoint3D32f [_imageNumber] []; PointF [] [] crossesperView = new PointF [_imageNumber] []; int index = 0; Trace.WriteLine(相机校准); foreach(十字架在_crosses.CrossesOnImage中交叉) { ComposeInputPerView(crosses,ref crossesperView [index],ref platePointsperView [index]); // crossesperView [index] = ComposeInputCrossesCoordPerView(十字架); 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); //CvInvoke.cvCalibrationMatrixValues(_ioParams.IntrinsicMatrix,_mageSize.Width,_mageSize.Height, // 0.0,0.0,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(主要点x,y:+ pp.x.ToString()+,+ pp.y.ToString()); PrintCalibrationParameters(); //CameraCalibration.CalibrateCamera(platePointsperView,crosssesperView, // _imageSize, // _ioParams, // Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_FIX_FOCAL_LENGTH, // out _eoParams); //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(); //CameraCalibration.CalibrateCamera(platePointsperView,crosssesperView, // _imageSize, // _ioParams, // Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_FIX_PRINCIPAL_POINT | Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_FIX_K1, // out _eoParams); //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(十字交叉,ref PointF [] imgPoints,ref MCvPoint3D32f [] platePoints) { // MCvPoint3D32f [] temp = null; //为图像点创建查询 IEnumerable< Cross> sortedCrossPoints = from crossPt in crosses.CrossPoints orderby(int.Parse(crossPt.LabelName)) select crossPt; 列表< PointF> tempCross = new List< PointF>(); foreach(在crosCrossPoints中交叉c) { //创建PointF PointF pt = new PointF(c.Point2D.X,c.Point2D.Y) ; tempCross.Add(pt); //Trace.WriteLine(c.LabelName + c.Point2D.ToString()++ pt.X.ToString()+;+ pt.Y.ToString()); } //Trace.WriteLine(\"Number of list:+ tempCross.Count.ToString()); imgPoints = tempCross.ToArray(); //创建平板点数查询 List< MCvPoint3D32f> ptsCv =新列表< MCvPoint3D32f>(); foreach(在crosCrossPoints中交叉c) { 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(十字交叉) { PointF [] temp = new PointF [2]; 返回临时; } private void PrintIntrinsicMatrix() { Trace.WriteLine(Intrinsic Matrix:); String line1 = String.Format({0} {1} {2},_ iPalams.IntrinsicMatrix [0,0],_ iPalams.IntrinsicMatrix [0,1], _ioParams.IntrinsicMatrix [0 ,2]); String line2 = String.Format({0} {1} {2},_ iParams.IntrinsicMatrix [1,0],_ iPalams.IntrinsicMatrix [1,1], _ioParams.IntrinsicMatrix [1 ,2]); String line3 = String.Format({0} {1} {2},_ iPalams.IntrinsicMatrix [2,0],_ iPalams.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 } } 这是错误 错误1方法'CalibrateCamera'没有重载需要6个参数 我尝试了什么: i试图在这里寻找答案并谷歌搜索但我仍然找不到它... 解决方案 查看文档: CameraCalibration.CalibrateCamera方法 [ ^ ] - 它需要7个参数,而不是6个。 您似乎错过了终止标准。 i did a camera calibration with c# and this error is what i get. can anyone help me what should i do? here is my code#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]); //crossesperView[index] = ComposeInputCrossesCoordPerView(crosses); index++; } //calculate calibration 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); //CvInvoke.cvCalibrationMatrixValues(_ioParams.IntrinsicMatrix, _imageSize.Width, _imageSize.Height, // 0.0, 0.0, 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(); //CameraCalibration.CalibrateCamera(platePointsperView, crossesperView, // _imageSize, // _ioParams, // Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_FIX_FOCAL_LENGTH, // out _eoParams); //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(); //CameraCalibration.CalibrateCamera(platePointsperView, crossesperView, // _imageSize, // _ioParams, // Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_FIX_PRINCIPAL_POINT | Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_FIX_K1, // out _eoParams); //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) { //MCvPoint3D32f[] temp = null; //create the query for image points 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) { //create PointF PointF pt = new PointF(c.Point2D.X, c.Point2D.Y); tempCross.Add(pt); //Trace.WriteLine(c.LabelName + c.Point2D.ToString()+ " " + pt.X.ToString() + " ; " + pt.Y.ToString()); } //Trace.WriteLine("Number of list: " + tempCross.Count.ToString()); imgPoints = tempCross.ToArray(); //Create the query for plate points 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 }}this is the errorError1No overload for method 'CalibrateCamera' takes 6 argumentsWhat I have tried:i tried to look for the answer here and googling it but i still can't find it... 解决方案 Look at the documentation: CameraCalibration.CalibrateCamera Method[^] - it takes 7 parameters, not six.You appear to be missing the termination criteria. 这篇关于过载错误C# - 摄像机校准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-28 21:34