예제 #1
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);
                }
            }
        }
        /// <summary>
        /// Tests different quality features for the calibration image 
        /// <c>cImg</c>
        /// </summary>
        /// <returns>
        /// Returns a value indicating the success or failure
        /// of the quality assessment
        /// </returns>
        public bool testQualityIssues(CalibImage cImg)
        {
            ArrayList qList;

            HObject markContours;
            HObject plateRegion;
            HImage  mImg;
            HTuple  score, score2, contrast;
            int  numRegions, numContours;
            bool qualityFailure;

            mImg            = cImg.getImage();
            qList           = cImg.getQualityIssueList();
            procedure       = new QualityProcedures();
            contrast        = new HTuple();
            qualityFailure  = false;
            // DescriptionFileName = mDescrFileName;
            ;

            try
            {
                procedure.find_caltab_edges(mImg, out plateRegion,
                                            out markContours,
                                            new HTuple(mDescrFileName));
                numRegions   = plateRegion.CountObj();
                numContours  = markContours.CountObj();

                if(mImageTests < QUALITY_ISSUE_TEST_NONE)
                {
                    if(numRegions == 0)
                    {
                        qualityFailure = true;
                    }
                    else
                    {
                        procedure.eval_caltab_overexposure(mImg, plateRegion, out score);
                        addQualityIssue(qList, QUALITY_ISSUE_IMG_EXPOSURE, score.D);
                    }

                    if(numContours == 0)
                    {
                        qualityFailure = true;
                    }
                    else
                    {
                        procedure.eval_caltab_contrast_homogeneity(mImg, markContours,out contrast, out score, out score2);
                        addQualityIssue(qList, QUALITY_ISSUE_IMG_CONTRAST,    score.D);
                        addQualityIssue(qList, QUALITY_ISSUE_IMG_HOMOGENEITY, score2.D);

                        procedure.eval_caltab_size(mImg, plateRegion, markContours, out score);
                        addQualityIssue(qList, QUALITY_ISSUE_IMG_CALTAB_SIZE, score.D);
                    }

                    if(mImageTests == QUALITY_ISSUE_TEST_ALL)
                    {
                        procedure.eval_caltab_focus(mImg, markContours,contrast , out score);
                        addQualityIssue(qList, QUALITY_ISSUE_IMG_FOCUS, score.D);
                    }
                }
            }
            catch(HOperatorException e)
            {
                throw(e);
            }

            return qualityFailure;
        }
        /* Constructor, in which all calibration parameters
           * and  auxiliary variables, flags and lists are initilized */
        public CalibrationAssistant()
        {
            CalibData       = new ArrayList(15);
            mReferenceIndex = -1;
            mDescrFileName  = "caltab_30mm.descr";
            mCalibValid     = false;
            mCanCalib       = true;
            mAtImgCoord     = false;

            mReferenceImage = new HImage();
            mSimulatedImage = new HImage();

            mFilterSize    = resetFilterSize;
            mMarkThresh    = resetMarkThresh;
            mMinMarkDiam   = resetMinMarkDiam;
            mInitThresh    = resetInitThresh;
            mThreshDecr    = resetThreshDecr;
            mMinThresh     = resetMinThresh;
            mSmoothing     = resetSmoothing;
            mMinContLength = resetMinContL;
            mMaxMarkDiam   = resetMaxMarkDiam;

            mWarnLevel      = 70;
            mImageTests     = QUALITY_ISSUE_TEST_ALL;
            mSequenceTests  = QUALITY_ISSUE_TEST_ALL;
            mSeqQualityList = new ArrayList(15);
            procedure       = new QualityProcedures();

            mThickness     = 1.00;       // millimeter
            mCameraType    = CAMERA_TYP_AREA_SCAN_DIV;
            mCellWidth     = 8.300;         // micrometer
            mCellHeight    = 8.300;        // micrometer
            mFocalLength   = 8.000;          // millimeter
            isTelecentric  = false;
            mKappa         = 0.0;
            mK1            = 0.0;
            mK2            = 0.0;
            mK3            = 0.0;
            mP1            = 0.0;
            mP2            = 0.0;
            mMotionVx      = 0.0;
            mMotionVy      = 500.0;
            mMotionVz      = 0.0;

            NotifyCalibObserver = new CalibDelegate(dummy);
        }
예제 #4
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);
            }
        }