/// <summary>
        /// 多相机执行
        /// </summary>
        /// <param name="par"></param>
        /// <param name="baseParCalibrate"></param>
        /// <param name="fun"></param>
        public void MainWindow_GetResultValueMult_event(ParGetResultFromCell par, BaseParCalibrate baseParCalibrate, HashAction fun)
        {
            try
            {
                BaseDealComprehensiveResult baseDealComprehensiveResult = null;
                int noCamera = par.NoCameraMult;//多相机序号
                switch (noCamera)
                {
                case 1:
                    baseDealComprehensiveResult = DealComprehensiveResult1;
                    break;

                case 2:
                    baseDealComprehensiveResult = DealComprehensiveResult2;
                    break;

                case 3:
                    baseDealComprehensiveResult = DealComprehensiveResult3;
                    break;

                case 4:
                    baseDealComprehensiveResult = DealComprehensiveResult4;
                    break;

                case 5:
                    baseDealComprehensiveResult = DealComprehensiveResult5;
                    break;

                case 6:
                    baseDealComprehensiveResult = DealComprehensiveResult6;
                    break;

                case 7:
                    baseDealComprehensiveResult = DealComprehensiveResult7;
                    break;

                case 8:
                    baseDealComprehensiveResult = DealComprehensiveResult8;
                    break;
                }
                baseDealComprehensiveResult.GetCellResultValue(par, baseParCalibrate, fun);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="par">参数</param>
        /// <param name="numPos">拍照位置</param>
        public void Init(BaseDealComprehensiveResult par, int numPos)
        {
            try
            {
                g_BaseDealComprehensiveResult = par;

                cboPos.Items.Clear();
                for (int i = 0; i < 6; i++)//算法相对位置,非拍照位置
                {
                    ComboBoxItem comboBoxItem = new ComboBoxItem();
                    comboBoxItem.Content = (i + 1).ToString();
                    cboPos.Items.Add(comboBoxItem);
                }

                cboPos.Text = "1";//默认为所有位置一起运行
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Exemple #3
0
        public void Init(UCStateWork uCStateWork, BaseDealComprehensiveResult baseDealComprehensiveResult)
        {
            try
            {
                g_UCStateWork = uCStateWork;
                g_NoCamera    = int.Parse(this.Tag.ToString());
                g_BaseDealComprehensiveResult = baseDealComprehensiveResult;

                base.g_UCDisplayCamera = g_BaseDealComprehensiveResult.g_UCDisplayCamera;

                //初始化所有的拍照位置
                InitCobPos();

                //初始化单次循环线程
                InitSingleRun();

                ShowPar_Invoke();
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
Exemple #4
0
        protected void Init_TrrigerDealResult(BaseDealComprehensiveResult[] baseDealComprehensiveResults)
        {
            Hashtable g_HtUCDisplayImage = new Hashtable();

            try
            {
                DealComprehensiveResult1 = baseDealComprehensiveResults[0];
                DealComprehensiveResult2 = baseDealComprehensiveResults[1];
                DealComprehensiveResult3 = baseDealComprehensiveResults[2];
                DealComprehensiveResult4 = baseDealComprehensiveResults[3];
                DealComprehensiveResult5 = baseDealComprehensiveResults[4];
                DealComprehensiveResult6 = baseDealComprehensiveResults[5];
                DealComprehensiveResult7 = baseDealComprehensiveResults[6];
                DealComprehensiveResult8 = baseDealComprehensiveResults[7];


                //按照窗体顺序
                for (int i = 0; i < ParSetDisplay.P_I.NumWinDisplayImage; i++)
                {
                    BaseParSetDisplay baseParSetDisplay = ParSetDisplay.P_I[i];

                    if (baseParSetDisplay.TypeDisplayImage.Contains("Image") &&
                        !g_HtUCDisplayImage.Contains(baseParSetDisplay.TypeDisplayImage))
                    {
                        g_HtUCDisplayImage.Add(baseParSetDisplay.TypeDisplayImage, g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i]);
                    }
                    else//相机显示窗体只包含一个
                    {
                        switch (baseParSetDisplay.TypeDisplayImage_e)
                        {
                        case TypeDisplayImage_enum.Camera1:
                            g_UCDisplayCamera1 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;

                        case TypeDisplayImage_enum.Camera2:
                            g_UCDisplayCamera2 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;

                        case TypeDisplayImage_enum.Camera3:
                            g_UCDisplayCamera3 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;

                        case TypeDisplayImage_enum.Camera4:
                            g_UCDisplayCamera4 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;

                        case TypeDisplayImage_enum.Camera5:
                            g_UCDisplayCamera5 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;

                        case TypeDisplayImage_enum.Camera6:
                            g_UCDisplayCamera6 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;

                        case TypeDisplayImage_enum.Camera7:
                            g_UCDisplayCamera7 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;

                        case TypeDisplayImage_enum.Camera8:
                            g_UCDisplayCamera8 = (BaseUCDisplayCamera)g_BaseUCDisplaySum.g_BaseUCDisplayCameras[i];
                            break;
                        }
                    }
                }
                DealComprehensiveResult1.Init(g_UCDisplayCamera1, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
                DealComprehensiveResult2.Init(g_UCDisplayCamera2, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
                DealComprehensiveResult3.Init(g_UCDisplayCamera3, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
                DealComprehensiveResult4.Init(g_UCDisplayCamera4, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
                DealComprehensiveResult5.Init(g_UCDisplayCamera5, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
                DealComprehensiveResult6.Init(g_UCDisplayCamera6, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
                DealComprehensiveResult7.Init(g_UCDisplayCamera7, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
                DealComprehensiveResult8.Init(g_UCDisplayCamera8, g_HtUCDisplayImage, g_UCDisplayMainResult, g_UCAlarm, g_UCStateWork, ShowStateMachine);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
            }
        }
        /// <summary>
        /// 自动相机校准,并且调用多相机执行算子
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="index">拍照序号,99表示结束表达,或者点位引用是_L</param>
        ///  <param name="htResult">哈希表存储结果</param>
        /// <returns></returns>
        bool CalibAffineCamera(int pos, int index, out Hashtable htResult)
        {
            htResult = null;
            Stopwatch sw = new Stopwatch();

            sw.Restart();
            try
            {
                ParCalibCameraAffine par = g_BaseParComprehensive.GetCellParCalibByType("相机投影校准", pos) as ParCalibCameraAffine;
                string nameCell          = par.NameCell;                         //单元格名称
                int    indexCell         = int.Parse(nameCell.Replace("C", "")); //单元格索引

                //关联算法,用来获取基准点
                ParCellExeReference         parCellExecuteReferenceForMult = par.g_ParCellExecuteReferenceForMult;
                ParGetResultFromCell        parGetResultFromCellMult       = par.g_ParGetResultFromCellForMult;
                BaseDealComprehensiveResult baseDealComprehensive          = GetDealComprehensiveResult(parGetResultFromCellMult.NoCameraMult); //
                baseDealComprehensive.GetCellResultValue(parGetResultFromCellMult, par, null);                                                  //执行算法但不显示
                Hashtable htResult_Mult = GetHtResult(parGetResultFromCellMult.NoCameraMult);                                                   //获取不同相机的哈希表结果


                FunCellDataReferenc funMult = new FunCellDataReferenc();//将结果传入参数
                funMult.GetResultValue(htResult_Mult, parGetResultFromCellMult, index - 1);

                //关联算法,用来获取像素点
                ParCellExeReference  parCellExeReference  = par.g_ParCellExecuteReference;
                ParGetResultFromCell parGetResultFromCell = par.g_ParGetResultFromCell;

                //调用执行
                g_BaseDealComprehensive.DealComprehensivePosCell_ForTestRun(g_UCDisplayCamera, parCellExeReference, par.g_ParCellExecuteReference.g_CellExecute_L, out htResult);//执行算法且显示

                string cellError = "";
                if (!GetErrorCell(htResult, pos, out cellError))
                {
                    WinMsgBox.ShowMsgBox(string.Format("相机{0}位置{1},单元格{2}校准计算错误", g_NoCamera.ToString(), pos.ToString(), par.NameCell));
                    return(false);
                }
                FunCellDataReferenc fun = new FunCellDataReferenc();
                fun.GetResultValue(htResult, parGetResultFromCell, index - 1);

                string info = string.Format("相机{0}位置{1},单元格{2}相机校准触发拍照", g_NoCamera.ToString(), pos.ToString(), par.NameCell);
                ShowState_Cam(info);

                //通过传入的坐标点,计算出投影变换的系数
                FunCalibCameraAffine    funCalibCameraAffine = new FunCalibCameraAffine();
                ResultCalibCameraAffine result = funCalibCameraAffine.CalCalibCameraAffine(par, htResult);

                //参数保存到Par
                bool blSavePar = funCalibCameraAffine.SaveResultToPar(par, result);

                info = "将标定参数保存到结果";
                ShowState_Cam(info);

                //将参数保存到结果中
                bool blSaveResult = funCalibCameraAffine.SaveResultToStdResult(par, htResult);


                if (blSaveResult)
                {
                    ShowState_Cam(string.Format("将相机{0}参数{1}保存到结果成功", g_NoCamera.ToString(), par.NameCell));
                }
                else
                {
                    ShowAlarm_Cam(string.Format("将相机{0}参数{1}保存到结果失败", g_NoCamera.ToString(), par.NameCell));
                    return(false);
                }

                //保存基准图片
                SaveStdImage(par, "相机投影校准");
                //保存此单元格
                bool blSave = g_BaseParComprehensive.WriteXmlDoc(par.NameCell);

                if (blSave)
                {
                    ShowState_Cam(string.Format("将相机{0}参数{1}保存到本地成功", g_NoCamera.ToString(), par.NameCell));
                }
                else
                {
                    ShowAlarm_Cam(string.Format("将相机{0}参数{1}保存到本地失败", g_NoCamera.ToString(), par.NameCell));
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                WinMsgBox.ShowMsgBox(string.Format("相机{0}投影校准计算进入Catch", g_NoCamera.ToString()));
                ShowAlarm("相机投影校准计算进入Catch");
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }