Example #1
0
        public CogImage8Grey GetImage8Grey()
        {
            if (m_cogDisplay.Image == null)
            {
                return(null);
            }

            return(CogImageConvert.GetIntensityImage(m_cogDisplay.Image, 0, 0, m_cogDisplay.Image.Width, m_cogDisplay.Image.Height));
        }
Example #2
0
        // 2015.04.01
        public int Run(ICogImage cogImage)
        {
            // 2016.03.22
            m_nFindCount = 0;

            SetBlobParam();

            // 2016.03.29
            //if (m_cogBlobTool != null)
            if (m_cogBlobTool != null && cogImage != null)
            {
                m_cogBlobTool.InputImage = CogImageConvert.GetIntensityImage(cogImage, 0, 0, cogImage.Width, cogImage.Height);
                if (m_cogimgMask != null)
                {
                    m_cogBlobTool.RunParams.InputImageMask = m_cogimgMask;
                }

                try
                {
                    // 2015.04.08
                    m_bRan = false;

                    m_cogBlobTool.Run();
                    // 2015.04.08
                    WaitRanEvent();

                    if (m_cogBlobTool.Results != null)
                    {
                        // 2011.05.24
                        m_nFindCount = m_cogBlobTool.Results.GetBlobs().Count;
                    }
                }
                catch
                {
                    MessageBox.Show("Run Blob Error");
                }
            }

            return(m_nFindCount);
        }
Example #3
0
        // 2016.11.10
        public int Run(ICogImage cogImage)
        {
            m_stResult.dX     = 0;
            m_stResult.dY     = 0;
            m_stResult.dAngle = 0;

            if (m_cogFindCornerTool != null)
            {
                InputImage = CogImageConvert.GetIntensityImage(cogImage, 0, 0, cogImage.Width, cogImage.Height);

                m_bRan = false;

                m_cogFindCornerTool.Run();

                WaitRanEvent();

                m_stResult.nR = (int)m_cogFindCornerTool.RunStatus.Result;
                if (m_stResult.nR == 0 && m_cogFindCornerTool.Result.CornerFound == true)
                {
                    m_stResult.dX     = m_cogFindCornerTool.Result.CornerX;
                    m_stResult.dY     = m_cogFindCornerTool.Result.CornerY;
                    m_stResult.dAngle =
                        (m_cogFindCornerTool.Result.LineResultsB.GetLine().Rotation - m_cogFindCornerTool.Result.LineResultsA.GetLine().Rotation)
                        * (180 / Math.PI);
                }
                else
                {
                    m_stResult.nR = -2;
                }
            }
            else
            {
                m_stResult.nR = -1;
            }

            return(m_stResult.nR);
        }
Example #4
0
        // 2015.06.15
        public int Run(ICogImage cogImage)
        {
            SetCaliperParam();

            if (m_cogCaliperTool != null)
            {
                m_cogCaliperTool.InputImage = CogImageConvert.GetIntensityImage(cogImage, 0, 0, cogImage.Width, cogImage.Height);

                // 2015.04.08
                m_bRan = false;

                m_cogCaliperTool.Run();

                // 2015.04.08
                WaitRanEvent();

                // 2012.02.02
                if (m_cogCaliperTool.Results == null)
                {
                    m_nFindCount = 0;
                    return(m_nFindCount);
                }

                if (m_cogCaliperTool.Results.Count > 0)
                {
                    m_dScore     = m_cogCaliperTool.Results[0].Score;
                    m_dPositionX = m_cogCaliperTool.Results[0].PositionX;
                    m_dPositionY = m_cogCaliperTool.Results[0].PositionY;
                    m_dPosition  = m_cogCaliperTool.Results[0].Position;

                    if (m_emEdgeMode == CogCaliperEdgeModeConstants.SingleEdge)
                    {
                        m_dEdge0PositionX = m_cogCaliperTool.Results[0].Edge0.PositionX;
                        m_dEdge0PositionY = m_cogCaliperTool.Results[0].Edge0.PositionY;
                        m_dEdge0Position  = m_cogCaliperTool.Results[0].Edge0.Position;
                        m_dEdge0Contrast  = m_cogCaliperTool.Results[0].Edge0.Contrast;
                        m_dEdge1PositionX = 0;
                        m_dEdge1PositionY = 0;
                        m_dEdge1Position  = 0;
                        m_dEdge1Contrast  = 0;
                    }
                    else
                    {
                        m_dEdge0PositionX = m_cogCaliperTool.Results[0].Edge0.PositionX;
                        m_dEdge0PositionY = m_cogCaliperTool.Results[0].Edge0.PositionY;
                        m_dEdge0Position  = m_cogCaliperTool.Results[0].Edge0.Position;
                        m_dEdge0Contrast  = m_cogCaliperTool.Results[0].Edge0.Contrast;
                        m_dEdge1PositionX = m_cogCaliperTool.Results[0].Edge1.PositionX;
                        m_dEdge1PositionY = m_cogCaliperTool.Results[0].Edge1.PositionY;
                        m_dEdge1Position  = m_cogCaliperTool.Results[0].Edge1.Position;
                        m_dEdge1Contrast  = m_cogCaliperTool.Results[0].Edge1.Contrast;
                    }

                    //m_dWidth = m_cogCaliperTool.Results[0].Width;
                    m_nFindCount = m_cogCaliperTool.Results.Count;
                }
                else
                {
                    //m_dScore = 0;
                    //m_dPositionX = 0;
                    //m_dPositionY = 0;
                    //m_dPosition = 0;
                    //m_dEdge0PositionX = 0;
                    //m_dEdge0PositionY = 0;
                    //m_dEdge0Position = 0;
                    //m_dEdge0Contrast = 0;
                    //m_dEdge1PositionX = 0;
                    //m_dEdge1PositionY = 0;
                    //m_dEdge1Position = 0;
                    //m_dEdge1Contrast = 0;
                    //m_dWidth = 0;
                    m_nFindCount = 0;
                }
            }

            return(m_nFindCount);
        }
Example #5
0
        private void 研究图像缝合ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CogImageFile imagefile_0 = new CogImageFile();

            imagefile_0.Open(Application.StartupPath + "/../../../street/street_0.bmp", CogImageFileModeConstants.Read);
            CogImage24PlanarColor image_24_0 = new CogImage24PlanarColor();

            image_24_0 = (CogImage24PlanarColor)imagefile_0[0];
            CogImage8Grey imageGray8_0 = CogImageConvert.GetIntensityImage(image_24_0, 0, 0, image_24_0.Width, image_24_0.Height);


            CogImageFile imagefile_1 = new CogImageFile();

            imagefile_1.Open(Application.StartupPath + "/../../../street/street_1.bmp", CogImageFileModeConstants.Read);
            CogImage24PlanarColor image_24_1 = new CogImage24PlanarColor();

            image_24_1 = (CogImage24PlanarColor)imagefile_1[0];
            CogImage8Grey imageGray8_1 = CogImageConvert.GetIntensityImage(image_24_1, 0, 0, image_24_1.Width, image_24_1.Height);


            CogImageFile imagefile_2 = new CogImageFile();

            imagefile_2.Open(Application.StartupPath + "/../../../street/street_2.bmp", CogImageFileModeConstants.Read);
            CogImage24PlanarColor image_24_2 = new CogImage24PlanarColor();

            image_24_2 = (CogImage24PlanarColor)imagefile_2[0];
            CogImage8Grey imageGray8_2 = CogImageConvert.GetIntensityImage(image_24_2, 0, 0, image_24_2.Width, image_24_2.Height);


            // 灰度图像
            //CogImage8Grey image8 = (CogImage8Grey)m_tb.GetScriptTerminalData("imageInput");
            CogImage8Grey image8 = (CogImage8Grey)m_tb.GetScriptTerminalData("OutputImage");

            image8 = imageGray8_0.Copy();
            CogToolCollection tbTc = m_tb.Tools;

            //tbTc.
            if (false)
            {
                image8 = (CogImage8Grey)((CogImageFileTool)tbTc["CogImageFileTool1"]).OutputImage;
            }



            CogImage8Grey image_002 = new CogImage8Grey();

            //image_002 = image8;
            image_002 = image8.Copy();
            CogImage8Grey image_003 = image8.Copy();



            // 将各个图像进行缝合组成一个完整的大图
            // 灰度图像
            //CogIPOneImageTool imageCtrl_02 = (CogIPOneImageTool)mToolBlock.Tools["CogIPOneImageTool2"];
            CogRectangle rt = new CogRectangle();

            rt.SetCenterWidthHeight(0, 0, image8.Width * 3, image8.Height * 3);
            CogImage8Grey m_gray = rt.CreateRLE(128, 0).CreateImage8Grey();
            //imageCtrl_02.InputImage = m_gray;



            //    CogImage8Grey inputImage = ( CogImage8Grey ) image8;
            //    tb.SetScriptTerminalData("Input", inputImage);
            CogImageStitch       stt = new CogImageStitch();
            CogTransform2DLinear rootFromBlending = new CogTransform2DLinear();

            //缩放,旋转,平移
            rootFromBlending.SetScalingsRotationsTranslation(1, 1, 0, 0, 0, 0);
            //    rootFromBlending.SetScalingsRotationTranslation();
            stt.AllocateBlendingBuffer(image8.Width * 3, image8.Height * 3, rootFromBlending);
            //stt.BlendImageIntoBuffer(image8, m_gray);
            stt.BlendImageIntoBuffer(imageGray8_0, imageGray8_0, m_gray, 0, 0);
            stt.BlendImageIntoBuffer(imageGray8_1, imageGray8_1, m_gray, image8.Width, image8.Height);
            stt.BlendImageIntoBuffer(imageGray8_2, imageGray8_2, m_gray, image8.Width * 2, image8.Height * 2);



            stt.FillDestinationImageFromBuffer(m_gray);
            //    BlendImageIntoBuffer(  CogImage8Grey, CogImage8Grey, CogImage8Grey, Int32, Int32 )


            //
            CogCopyRegionTool ccft = new CogCopyRegionTool();


            //switch (  true )
            //{
            //case :
            //    break;
            //}


            cogRecordDisplay1.Image = m_gray;
            cogRecordDisplay1.Fit();
        }