Exemple #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 이미지 검사
        //설명 : 4장의 이미지를 PMS통해 합친다.
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool SetInspectionBusbar(structureMeasureParameter objParameter)
        {
            bool bReturn   = false;
            var  pDocument = CDocument.GetDocument;
            // 에러 로그
            string    strErrorLog  = string.Format("CProcessVisionProcess60 {0} SetInspectionBusbar ", m_iCameraIndex);
            Stopwatch objStopWatch = new Stopwatch();

            objStopWatch.Start();
            do
            {
                // pDocument.SetUpdateLog( ( CDefine.enumLogType )( ( int )CDefine.enumLogType.LOG_VISION_PROCESS_CAMERA_0 + m_iCameraIndex ), strErrorLog );

                try {
                    List <byte[]> objImageByte;
                    List <byte[]> objImageByteSecond;

                    CogImageToByteArr(objParameter.objImage, out objImageByte);
                    CogImageToByteArr(objParameter.objImage, out objImageByteSecond);

                    int iWidth  = objParameter.objImageBitmap.Width;
                    int iHeight = objParameter.objImageBitmap.Height;

                    CogImage8Grey         objCogImage = new CogImage8Grey(objParameter.objImageBitmap);
                    ICogImage8PixelMemory pmr         = objCogImage.Get8GreyPixelMemory(CogImageDataModeConstants.Read, 0, 0, iWidth, iHeight);
                    int iStride = pmr.Stride;

                    iWidth = iStride;

                    Mat objMatImage = new Mat(iHeight, iWidth, MatType.CV_8UC1, objImageByte[0]);

                    Mat objMatImageSecond = new Mat(iHeight, iWidth, MatType.CV_8UC1, objImageByteSecond[0]);

                    //m_objMeasure.SetBusbarParameters( objParameter.iThresh, objParameter.iMaskLen, objParameter.iMeasureInterv, objParameter.iCaliperLen, objParameter.iSkipLenFromCenter );

                    //DoMeasureWelding( int nWidth, int nHeight, byte* pPMS1, int nLRLowThresh, int nLRContinousLen, int nLRHighThresh, byte* pPMS3, int nTBThresh, int nTBContinousLen );
                    unsafe {
                        m_objMeasure.DoBusbarMeasureWelding(iWidth, iHeight, objMatImage.DataPointer, objParameter.nLRLowThresh, objParameter.nLRContinousLen, objParameter.nLRHighThresh, objMatImageSecond.DataPointer, objParameter.nTBThresh, objParameter.nTBContinousLen);
                    }
                } catch (Exception ex) {
                    Trace.WriteLine("CMeasureManager.cs -> SetPMSImage ---" + ex.StackTrace);
                    break;
                }
                bReturn = true;
            } while(false);
            //CDocument.GetDocument.SetUpdateLog( CDefine.enumLogType.LOG_ETC, "Measure SetInspection TactTime : " + objStopWatch.ElapsedMilliseconds.ToString() );

            return(bReturn);
        }
Exemple #2
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 이미지 검사
        //설명 : 4장의 이미지를 PMS통해 합친다.
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool SetInspectionSensor(structureMeasureParameter objParameter)
        {
            bool bReturn   = false;
            var  pDocument = CDocument.GetDocument;
            // 에러 로그
            string    strErrorLog  = string.Format("CMeasureManager {0} SetInspectionSensor ", m_iCameraIndex);
            Stopwatch objStopWatch = new Stopwatch();

            objStopWatch.Start();
            do
            {
                // pDocument.SetUpdateLog( ( CDefine.enumLogType )( ( int )CDefine.enumLogType.LOG_VISION_PROCESS_CAMERA_0 + m_iCameraIndex ), strErrorLog );

                try {
                    List <byte[]> objImageByte;
                    List <byte[]> objImageByteSecond;

                    CogImageToByteArr(objParameter.objImage, out objImageByte);
                    CogImageToByteArr(objParameter.objImage, out objImageByteSecond);

                    int iWidth  = objParameter.objImageBitmap.Width;
                    int iHeight = objParameter.objImageBitmap.Height;

                    CogImage8Grey         objCogImage = new CogImage8Grey(objParameter.objImageBitmap);
                    ICogImage8PixelMemory pmr         = objCogImage.Get8GreyPixelMemory(CogImageDataModeConstants.Read, 0, 0, iWidth, iHeight);
                    int iStride = pmr.Stride;

                    iWidth = iStride;

                    Mat objMatImage = new Mat(iHeight, iWidth, MatType.CV_8UC1, objImageByte[0]);

                    Mat objMatImageSecond = new Mat(iHeight, iWidth, MatType.CV_8UC1, objImageByteSecond[0]);

                    unsafe {
                        m_objMeasure.DoSensorMeasure(iWidth, iHeight, objMatImage.DataPointer, objParameter.nSensorStdWid, objParameter.nSensorStdHgt, objParameter.nThresh);
                    }
                } catch (Exception ex) {
                    Trace.WriteLine("CMeasureManager.cs -> SetPMSImage ---" + ex.StackTrace);
                    break;
                }
                bReturn = true;
            } while(false);
            //CDocument.GetDocument.SetUpdateLog( CDefine.enumLogType.LOG_ETC, "Measure SetInspection TactTime : " + objStopWatch.ElapsedMilliseconds.ToString() );

            return(bReturn);
        }
Exemple #3
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 이미지 검사
        //설명 : 4장의 이미지를 PMS통해 합친다.
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool SetPMSImage()
        {
            bool bReturn   = false;
            var  pDocument = CDocument.GetDocument;

            // 검사 결과 구조체
            CInspectionResult.CResult objResult = new CInspectionResult.CResult();
            // 에러 로그
            string    strErrorLog  = string.Format("CProcessVisionProcess60 {0} SetPMSImage ", m_iCameraIndex);
            Stopwatch objStopWatch = new Stopwatch();

            objStopWatch.Start();
            do
            {
                //pDocument.SetUpdateLog( ( CDefine.enumLogType )( ( int )CDefine.enumLogType.LOG_VISION_PROCESS_CAMERA_0 + m_iCameraIndex ), strErrorLog );
                objResult = pDocument.GetInspectionResultAlign(pDocument.GetInspectionIndex());

                try {
                    List <byte[]> objImageByte;

                    CogImageToByteArr(objResult.objResultCommon.objInputGrabOriginImage, out objImageByte);

                    int[] iImageSize = new int[objImageByte.Count];
                    for (int i = 0; i < objImageByte.Count; i++)
                    {
                        iImageSize[i] = objImageByte[i].Length;
                    }

                    bool bImageSizeSame = true;
                    for (int i = 0; i < objImageByte.Count; i++)
                    {
                        if (iImageSize[0] != iImageSize[i])
                        {
                            bImageSizeSame = false;
                            CDocument.GetDocument.SetUpdateLog(CDefine.enumLogType.LOG_VISION_PROCESS_CAMERA_0, "Set PMSImage Setting Fail");
                            break;
                        }
                    }

                    if (false == bImageSizeSame)
                    {
                        break;
                    }

                    int iWidth  = objResult.objResultCommon.objInputGrabOriginalImageBitmap[0].Width;
                    int iHeight = objResult.objResultCommon.objInputGrabOriginalImageBitmap[0].Height;



                    CogImage8Grey         objCogImage = new CogImage8Grey(objResult.objResultCommon.objInputGrabOriginImage[0]);
                    ICogImage8PixelMemory pmr         = objCogImage.Get8GreyPixelMemory(CogImageDataModeConstants.Read, 0, 0, iWidth, iHeight);
                    m_iStride = pmr.Stride;

                    iWidth = m_iStride;


                    for (int i = 0; i < objImageByte.Count; i++)
                    {
                        if (null != m_objMatImage[i])
                        {
                            m_objMatImage[i].Release();
                        }
                        m_objMatImage[i] = new Mat(iHeight, iWidth, MatType.CV_8UC1, objImageByte[i]);
                    }

                    m_PMSMix.SetPMSParameters(m_objMatImage[0].Cols, m_objMatImage[0].Rows, Constants.nThreshold);
                    m_PMSMix.SetMatImages(m_objMatImage[0].Cols, m_objMatImage[0].Rows, Constants.ImageNum, m_objMatImage);
                    m_PMS.DoStartProcess(Constants.ImageNum, m_objMatImage[0].Cols, m_objMatImage[0].Rows);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine("CPMSManager.cs -> SetPMSImage ---" + ex.StackTrace);
                    CDocument.GetDocument.SetUpdateLog(CDefine.enumLogType.LOG_ETC, "CPMSManager.cs -> SetPMSImage ---" + ex.ToString());
                    break;
                }
                bReturn = true;
            } while (false);
            //CDocument.GetDocument.SetUpdateLog( CDefine.enumLogType.LOG_ETC, "Set PMSImage Process TactTime : " + objStopWatch.ElapsedMilliseconds.ToString() );
            pDocument.SetInspectionResultAlign(pDocument.GetInspectionIndex(), (CInspectionResult.CResult)objResult.Clone());

            return(bReturn);
        }