//仿射变换后的全部轮廓
        public void GenDetectionXLDResults(HXLDCont modelXldCont)
        {
            if (resultXLDCont == null)
            {
                resultXLDCont = new HXLDCont();
            }
            if (resultXLDCont != null && resultXLDCont.IsInitialized())
            {
                resultXLDCont.Dispose();
            }
            resultXLDCont.GenEmptyObj();

            HXLDCont rContours;

            for (int i = 0; i < row.Length; i++)
            {
                HHomMat2D mat1 = new HHomMat2D();
                mat1.VectorAngleToRigid(0, 0, 0, row[i].D, column[i].D, angle[i].D);
                mat1 = mat1.HomMat2dScale(scale[i].D, scale[i].D, row[i].D, column[i].D);
                //图像偏移
                rContours = mat1.AffineTransContourXld(modelXldCont);
                //获取模板集合
                resultXLDCont = resultXLDCont.ConcatObj(rContours);
                rContours.Dispose();
                rContours.GenCrossContourXld(row[i].D, column[i].D, 10, angle[i].D);
                resultXLDCont = resultXLDCont.ConcatObj(rContours);
                rContours.Dispose();
            }
        }
        /// <summary>
        /// Gets the detected contour.
        /// </summary>
        /// <returns>Detected contour</returns>
        public HXLDCont getDetectionResults()
        {
            HXLDCont rContours = new HXLDCont();

            hmat.HomMat2dIdentity();
            mContResults.GenEmptyObj();

            for (int i = 0; i < count; i++)
            {
                hmat.VectorAngleToRigid(0, 0, 0, mRow[i].D, mCol[i].D, mAngle[i].D);
                rContours    = hmat.AffineTransContourXld(mContour);
                mContResults = mContResults.ConcatObj(rContours);
            }
            return(mContResults);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the detected contour.
        /// </summary>
        /// <returns>Detected contour</returns>
        public HXLDCont getDetectionResults()
        {
            HXLDCont rContours = new HXLDCont();

            hmat.HomMat2dIdentity();

            if (mContResults != null)
            {
                mContResults.Dispose();
            }
            mContResults.GenEmptyObj();



            for (int i = 0; i < count; i++)
            {
                if (mImageScale < 0.1 || mImageScale > 2)
                {
                    mImageScale = 1.0;
                }
                hmat.VectorAngleToRigid(0, 0, 0, mRow[i].D * mImageScale, mCol[i].D * mImageScale, mAngle[i].D);
                //2020.11.7 gengxmÐÞ¸Ä £¬ÂÖÀª·Å´óÈý±¶
                hmat = hmat.HomMat2dScale(1.0000 / mImageScale, 1.0000 / mImageScale, 0, 0);

                rContours = hmat.AffineTransContourXld(mContour);



                mContResults = mContResults.ConcatObj(rContours);
            }
            if (rContours != null)
            {
                rContours.Dispose();
            }

            if (true)
            {
                HTuple convexity;
                HTuple col1, col2, row1, row2;
                HOperatorSet.SmallestRectangle1Xld(mContResults, out row1, out col1, out row2, out col2);
                HOperatorSet.ConvexityXld(mContResults, out convexity);
                // wid = col2 - col1;
                //hei = row2 - row1;
            }

            return(mContResults);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Composes set of HALCON iconic objects to display
        /// measure edge results
        /// </summary>
        /// <returns>Detected measure edges</returns>
        public HXLDCont getMeasureResults()
        {
            HXLDCont val;
            HXLDCont obj = new HXLDCont();

            obj.GenEmptyObj();

            for (int i = 0; i < mMeasureList.Count; i++)
            {
                val = ((Measurement)mMeasureList[i]).getMeasureResults();
                if (val.IsInitialized())
                {
                    obj = obj.ConcatObj(val);
                }
            }
            return(obj);
        }
Ejemplo n.º 5
0
        public HXLDCont GetMatchModelCont()
        {
            HXLDCont cont = new HXLDCont();

            cont.GenEmptyObj();

            for (int i = 0; i < OutputResult.Count; i++)
            {
                HXLDCont hXLD = GetMatchModelCont(i);

                if (hXLD != null)
                {
                    cont = cont.ConcatObj(hXLD);;
                }
            }

            return(cont);
        }
        /// <summary>
        /// Composes set of HALCON iconic objects to display
        /// measure edge results
        /// </summary>
        /// <returns>Detected measure edges</returns>
        public HXLDCont getMeasureResults()
        {
            HXLDCont val;
            HXLDCont obj = new HXLDCont();

            obj.GenEmptyObj();

            for (int i = 0; i < mMeasureList.Count; i++)
            {
                var mMeasure = ((Measurement)mMeasureList[i]);

                /*
                 * 是否顯示量測的圖形
                 * var roi = mMeasure.GetMeasureROI();
                 * if (!roi.Visiable) continue;
                 */
                val = mMeasure.getMeasureResults();
                if (val.IsInitialized())
                {
                    obj = obj.ConcatObj(val);
                }
            }
            return(obj);
        }
        /// <summary>
        /// Composes set of HALCON iconic objects to display 
        /// measure edge results
        /// </summary>
        /// <returns>Detected measure edges</returns> 
        public HXLDCont getMeasureResults()
        {
            HXLDCont val;
            HXLDCont obj = new HXLDCont();
            obj.GenEmptyObj();

            for (int i=0; i < mMeasureList.Count; i++)
            {
                val = ((Measurement)mMeasureList[i]).getMeasureResults();
                if (val.IsInitialized())
                    obj = obj.ConcatObj(val);
            }
            return obj;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds visual effects (shadows)
        /// to the measure results.
        /// </summary>
        /// <param name="edges">
        /// Add shadows along the edges provided
        /// </param>
        public void UpdateShadowContours(HObject edges)
        {
            double shift;
            HXLDCont shadow1, shadow2;
            HHomMat2D hom2D = new HHomMat2D();

            mShadow.Dispose();
            mShadow.GenEmptyObj();

            shift = Math.Min(0.5 * lineWidth, 2.0);

            hom2D.HomMat2dIdentity();
            hom2D = hom2D.HomMat2dTranslate(shift, 1);
            shadow1 = ((HXLDCont)edges).AffineTransContourXld(hom2D);

            hom2D.HomMat2dIdentity();
            hom2D = hom2D.HomMat2dTranslate(1, shift);
            shadow2 = ((HXLDCont)edges).AffineTransContourXld(hom2D);

            mShadow = mShadow.ConcatObj(shadow1);
            mShadow = mShadow.ConcatObj(shadow2);

            shadow1.Dispose();
            shadow2.Dispose();
        }
        /// <summary>
        /// Composes set of HALCON iconic objects to display 
        /// measure edge results
        /// </summary>
        /// <returns>Detected measure edges</returns> 
        public HXLDCont getMeasureResults()
        {
            HXLDCont val;
            HXLDCont obj = new HXLDCont();
            obj.GenEmptyObj();

            for (int i = 0; i < mMeasureList.Count; i++)
            {
                var mMeasure = ((Measurement)mMeasureList[i]);
                /*
                是否顯示量測的圖形
                var roi = mMeasure.GetMeasureROI();
                if (!roi.Visiable) continue;
                 */
                val = mMeasure.getMeasureResults();
                if (val.IsInitialized())
                    obj = obj.ConcatObj(val);
            }
            return obj;
        }