/// <summary> /// 保存多目校准的系数 /// </summary> /// <param name="noCamera_e">相机序号</param> /// <param name="index">算子序号,不是拍照位置</param> /// <param name="calib"></param> /// <returns></returns> public static bool SaveCalibMultCo(NoCamera_enum noCamera_e, int index, double[] calib) { try { BaseParComprehensive par = GetParComphensive(noCamera_e); //index 获取对应算子的所有单元格名称 List <string> nameCell_L = par.GetAllNameCellByType("多目校准"); if (nameCell_L.Count < index) { return(false); } string nameCell = nameCell_L[index - 1]; ParCalibMult parCalibMult = par.GetCellParCalibrate(nameCell) as ParCalibMult; for (int i = 0; i < calib.Length; i++) { parCalibMult.CoCalib[i] = calib[i]; } bool blSave = par.WriteXmlDoc(nameCell); if (blSave) { ShowState(string.Format("将多目校准{0}参数保存到本地成功", nameCell)); } else { ShowAlarm(string.Format("将多目校准{0}参数保存到本地失败", nameCell)); return(false); } return(true); } catch (Exception ex) { Log.L_I.WriteError("BaseDealComprehensiveResult", ex); return(false); } }
public bool CalibRotateCenter(string cellName, Point2D pt2Mark1, Point2D pt2Mark2, double rotateAngle, BaseParComprehensive parComprehensive) { try { //获取旋转中心cell BaseParCalibrate baseParComprehensive = parComprehensive.GetCellParCalibrate(cellName); //获取旋转中心算子 ParCalibRotate parCalibRotate = (ParCalibRotate)baseParComprehensive; //根据参数求旋转中心 Point2D rc = new FunCalibRotate().GetOriginPoint(rotateAngle, pt2Mark1, pt2Mark2); //把旋转中心存入算子 parCalibRotate.XRC = rc.DblValue1; parCalibRotate.YRC = rc.DblValue2; //讲计算结果写入xml parComprehensive.WriteXmlDoc(cellName); //将参数保存到结果类 new FunCalibRotate().SaveParToResult(HtResult_Cam1, parCalibRotate); //输出计算结果 string info = string.Format("相机{0}旋转中心标定完成,X:{1},Y:{2}", g_NoCamera, parCalibRotate.XRC.ToString(), parCalibRotate.YRC.ToString()); ShowState(info); return(true); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); return(false); } }
/// <summary> /// 计算相机的映射系数 /// </summary> /// <param name="par1">基准相机参数</param> /// <param name="index1">算子索引号</param> /// <param name="par2"></param> /// <param name="index2">算子索引号</param> /// <returns></returns> bool CalibMult_Co(BaseParComprehensive par1, int index1, BaseParComprehensive par2, int index2) { try { //第一个相机 List <string> name1_L = par1.GetAllNameCellByType("多目校准"); if (name1_L.Count < index1) { WinMsgBox.ShowMsgBox("算子个数小于序号!"); return(false); } string name1 = name1_L[index1 - 1]; ParCalibMult parCalibMult1 = par1.GetCellParCalibrate(name1) as ParCalibMult; //第二个相机 List <string> name2_L = par2.GetAllNameCellByType("多目校准"); if (name2_L.Count < index1) { WinMsgBox.ShowMsgBox("算子个数小于序号!"); return(false); } string name2 = name2_L[index1 - 1]; ParCalibMult parCalibMult2 = par2.GetCellParCalibrate(name2) as ParCalibMult; //计算系数 FunCalibMult fun = new FunCalibMult(); fun.CalCalibMult(parCalibMult1, parCalibMult2); //保存此单元格 bool blSave = par1.WriteXmlDoc(par1.NameCell); if (blSave) { ShowState(string.Format("将相机{0}参数{1}保存到本地成功", par1.NoCamera.ToString(), par1.NameCell)); } else { ShowAlarm(string.Format("将相机{0}参数{1}保存到本地失败", par1.NoCamera.ToString(), par1.NameCell)); return(false); } blSave = par2.WriteXmlDoc(par2.NameCell); if (blSave) { ShowState(string.Format("将相机{0}参数{1}保存到本地成功", par2.NoCamera.ToString(), par2.NameCell)); } else { ShowAlarm(string.Format("将相机{0}参数{1}保存到本地失败", par2.NoCamera.ToString(), par2.NameCell)); return(false); } return(true); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); return(false); } }
public bool SetRotateCenter(string cellName, Point2D rc, BaseParComprehensive parComprehensive) { //获取旋转中心cell BaseParCalibrate baseParComprehensive = parComprehensive.GetCellParCalibrate(cellName); //获取旋转中心算子 ParCalibRotate parCalibRotate = (ParCalibRotate)baseParComprehensive; //把旋转中心存入算子 parCalibRotate.XRC = rc.DblValue1; parCalibRotate.YRC = rc.DblValue2; //讲计算结果写入xml parComprehensive.WriteXmlDoc(cellName); //将参数保存到结果类 new FunCalibRotate().SaveParToResult(HtResult_Cam1, parCalibRotate); //输出计算结果 string info = string.Format("相机{0}旋转中心标定完成,X:{1},Y:{2}", g_NoCamera, parCalibRotate.XRC.ToString(), parCalibRotate.YRC.ToString()); ShowState(info); return(true); }