示例#1
0
        /// <summary>
        /// 需要在相机回调函数中传入图像HObject对象
        /// </summary>
        /// <param name="ho_Image">图像HObject对象</param>
        public void DisplayContinuous(HImage ho_Image)
        {
            ho_Image.GetImageSize(out this.width, out this.height);
            HSystem.SetSystem("width", this.width);
            HSystem.SetSystem("height", this.height);
            this.hWinContinuous.HalconWindow.SetPart(0, 0, this.height - 1, this.width - 1);
            this.hWinContinuous.HalconWindow.DispObj(ho_Image);
            if (this.cTextBoxDesc.Text == "")
            {
                return;
            }

            HRegion ho_Calib = ho_Image.FindCaltab(this.cTextBoxDesc.Text, 3, 112, 5);

            this.hWinContinuous.HalconWindow.DispObj(ho_Calib);
            ho_Calib.Dispose();
        }
        /// <summary>
        /// 取得校正片校正資訊
        /// </summary>
        /// <param name="calibrationPlateDescriptionFile">校正片描述檔案</param>
        /// <param name="image">校正片影像</param>
        /// <param name="plateParam">校正片擷取參數</param>
        /// <param name="startCamerParam">鏡頭參數</param>
        /// <returns>校正片校正資訊模型</returns>
        public CalibrationPlateMarkViewModel GetCalibrationPlateMarkViewModel(string calibrationPlateDescriptionFile
            , HImage image
            , CalibrationPlateParam plateParam
            , HTuple startCamerParam)
        {
            var model = new CalibrationPlateMarkViewModel();
            try
            {
                //找到校正板的區域
                var calibRegion = image.FindCaltab(calibrationPlateDescriptionFile
                                , plateParam.GaussianFilterSize
                                , plateParam.MarkThreshold
                                , plateParam.MinMarkDiam);

                //取得校正片 Mark 的位置和角度
                HTuple markCenterCols;
                HPose estimatedStartPose;
                HTuple markCenterRows = image.FindMarksAndPose(calibRegion
                                                        , calibrationPlateDescriptionFile
                                                        , startCamerParam
                                                        , plateParam.StartThresh
                                                        , plateParam.DeltaThresh
                                                        , plateParam.MinThresh
                                                        , plateParam.Alpha
                                                        , plateParam.MinContourLength
                                                        , plateParam.MaxDiameterMarks
                                                        , out markCenterCols
                                                        , out estimatedStartPose);

                model.MarkCenterRows = new HTuple(markCenterRows);
                model.MarkCenterCols = new HTuple(markCenterCols);
                model.EstimatedMarkPose = new HTuple(estimatedStartPose);
                model.Valid = true;
                model.ErrorMessage = String.Empty;
            }
            catch (HOperatorException ex)
            {
                model.ErrorMessage = ex.Message;
                model.Valid = false;
            }
            return model;
        }
示例#3
0
        /// <summary>
        /// Determine s(or updates) the basic information for this
        /// calibration image, which are the values for the region
        /// plate, the center marks, and the estimated pose.
        /// The flag <c>mPlateStatus</c> describes the evaluation
        /// of the computation process.
        /// If desired the quality assessment can be recalculated
        /// as well.
        /// </summary>
        /// <param name="updateQuality">
        /// Triggers the recalculation of the quality assessment for
        /// this calibration image
        /// </param>
        public void UpdateCaltab(bool updateQuality)
        {
            HTuple worldX, worldY;
            HTuple unit = new HTuple("m");

            bool failed            = false;
            QualityProcedures proc = new QualityProcedures();
            string            descrFile;
            HTuple            startCamp;

            mErrorMessage = "";


            mCaltabRegion.Dispose();
            mMarkCenter.Dispose();
            mEstimatedWCS.Dispose();

            //reset this variable
            mMarkCenterRows = new HTuple();

            mPlateStatus = CalibrationAssistant.PS_NOT_FOUND;

            descrFile = mAssistant.getDesrcFile();

            try
            {
                mCaltabRegion = mImage.FindCaltab(descrFile,
                                                  (int)mAssistant.mFilterSize,
                                                  (int)mAssistant.mMarkThresh,
                                                  (int)mAssistant.mMinMarkDiam);

                mPlateStatus = CalibrationAssistant.PS_MARKS_FAILED;

                //-- Quality issue measurements --
                if (updateQuality)
                {
                    mQualityIssuesList.Clear();
                    failed = mAssistant.testQualityIssues(this);
                }

                startCamp       = mAssistant.getCameraParams(this);
                mMarkCenterRows = mImage.FindMarksAndPose(mCaltabRegion,
                                                          descrFile,
                                                          startCamp,
                                                          (int)mAssistant.mInitThresh,
                                                          (int)mAssistant.mThreshDecr,
                                                          (int)mAssistant.mMinThresh,
                                                          mAssistant.mSmoothing,
                                                          mAssistant.mMinContLength,
                                                          mAssistant.mMaxMarkDiam,
                                                          out mMarkCenterCols,
                                                          out mEstimatedPose);


                mMarkCenter.GenCrossContourXld(mMarkCenterRows,
                                               mMarkCenterCols,
                                               new HTuple(6.0),
                                               0.785398);

                if (failed)
                {
                    mAssistant.addQualityIssue(this, CalibrationAssistant.QUALITY_ISSUE_FAILURE, 0.0);
                }


                HOperatorSet.ImagePointsToWorldPlane(startCamp, mEstimatedPose,
                                                     mMarkCenterRows, mMarkCenterCols,
                                                     unit, out worldX, out worldY);
                mEstimatedPlateSize = HMisc.DistancePp(worldY[0].D, worldX[0].D,
                                                       worldY[1].D, worldX[1].D);
                mEstimatedPlateSize *= 10.0;
                proc.get_3d_coord_system(mImage, out mEstimatedWCS,
                                         startCamp, mEstimatedPose,
                                         new HTuple(mEstimatedPlateSize / 2.0));

                mPlateStatus = mQualityIssuesList.Count > 0 ? CalibrationAssistant.PS_QUALITY_ISSUES:CalibrationAssistant.PS_OK; // "Quality Issues found": "OK";
                mCanCalib    = 0;
            }
            catch (HOperatorException e)
            {
                this.mErrorMessage = e.Message;
                mCanCalib          = 1;

                /* if exception was raised due to lack of memory,
                 * forward the error to the calling method */
                if (e.Message.IndexOf("not enough") != -1)
                {
                    throw(e);
                }
            }
        }