public Boolean Load()
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mFindLineTool = null;
                mFindLineTool = new CogFindLineTool();

                mFindLineTool_Results = null;
                mFindLineTool_Results = new FindLineTool_Results();

                mStartX                  = 201.412;
                mStartY                  = 263.353;
                mEndX                    = 401.412;
                mEndY                    = 263.353;
                mNumCalipers             = 6;
                mCaliperSearchLength     = 30;
                mCaliperProjectionLength = 10;
                mCaliperSearchDirection  = 90;

                FindLineTool_Status = false;

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindLineTool Load Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #2
0
        public Boolean ROI_create(CogRecordDisplay CogRecordDisplay1)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                //initial RunParams
                mFindCircleTool.RunParams.ExpectedCircularArc.CenterX    = mCenterX;
                mFindCircleTool.RunParams.ExpectedCircularArc.CenterY    = mCenterY;
                mFindCircleTool.RunParams.ExpectedCircularArc.Radius     = mRadius;
                mFindCircleTool.RunParams.ExpectedCircularArc.AngleStart = mAngleStart;
                mFindCircleTool.RunParams.ExpectedCircularArc.AngleSpan  = mAngleSpan;
                mFindCircleTool.RunParams.NumCalipers                    = mNumCalipers;
                mFindCircleTool.RunParams.CaliperSearchLength            = mCaliperSearchLength;
                mFindCircleTool.RunParams.CaliperProjectionLength        = mCaliperProjectionLength;
                mFindCircleTool.RunParams.CaliperSearchDirection         = mCircleSearchDirectionOption;
                mFindCircleTool.RunParams.NumToIgnore                    = mNumToIgnore;
                mFindCircleTool.RunParams.CaliperRunParams.Edge0Polarity = mCogCaliperPolarityConstants;

                mFindCircleTool.InputImage = (CogImage8Grey)CogRecordDisplay1.Image;
                CogRecordDisplay1.Record   = mFindCircleTool.CreateCurrentRecord().SubRecords["InputImage"];
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindCircleTool ROI_create Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                FindCircleTool_Status = false;
                return(false);
            }
        }
        public Boolean ROI_create(CogRecordDisplay CogRecordDisplay1)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                //initial RunParams
                mFindLineTool.RunParams.ExpectedLineSegment.StartX = mStartX;
                mFindLineTool.RunParams.ExpectedLineSegment.StartY = mStartY;
                mFindLineTool.RunParams.ExpectedLineSegment.EndX   = mEndX;
                mFindLineTool.RunParams.ExpectedLineSegment.EndY   = mEndY;
                mFindLineTool.RunParams.NumCalipers             = mNumCalipers;
                mFindLineTool.RunParams.CaliperSearchLength     = mCaliperSearchLength;
                mFindLineTool.RunParams.CaliperProjectionLength = mCaliperProjectionLength;
                mFindLineTool.RunParams.CaliperSearchDirection  = mCaliperSearchDirection;

                mFindLineTool.InputImage = (CogImage8Grey)CogRecordDisplay1.Image;
                CogRecordDisplay1.Record = mFindLineTool.CreateCurrentRecord().SubRecords["InputImage"];
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindLineTool ROI_create Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                FindLineTool_Status = false;
                return(false);
            }
        }
Beispiel #4
0
        }//卸載CCD結束

        /// <summary>
        /// 調整曝光值
        /// </summary>
        /// <param name="TempCameras">指定相機</param>
        /// <param name="Exposure">給定曝光值</param>
        /// <returns>設定成功與否</returns>
        public static Boolean CCD_Exposure_Function(VisionCameras TempCameras, double Exposure)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                // Get a reference to the ExposureParams interface of the AcqFifo.
                ICogAcqExposure   ExposureParams   = ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras].OwnedExposureParams;
                ICogAcqBrightness BrightnessParams = ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras].OwnedBrightnessParams;
                ICogAcqContrast   ContrastParams   = ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras].OwnedContrastParams;
                // Always check to see an "Owned" property is supported
                // before using it.
                if (ExposureParams != null)  // Check for exposure support.
                {
                    BrightnessParams.Brightness = 0.5;
                    ContrastParams.Contrast     = 0;
                    ExposureParams.Exposure     = Exposure;                           // sets ExposureTimeAbs
                    ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras].Prepare(); // writes the properties to the camera.
                }

                SaveLog.Msg_("調整曝光值 " + TempCameras.ToString() + " :" + Exposure.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());

                SaveLog.Msg_("調整曝光值 " + TempCameras.ToString() + " :" + Exposure.ToString() + " 失敗");
                return(false);
            }
        }
Beispiel #5
0
        public bool ROI_Create(CogRecordDisplay mCogRecordDisplay)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mLineMaxTool_ROI.GraphicDOFEnable = CogRectangleAffineDOFConstants.All;
                mLineMaxTool_ROI.Interactive      = true;
                mLineMaxTool_ROI.CenterX          = mCogRecordDisplay.PanX;
                mLineMaxTool_ROI.CenterY          = mCogRecordDisplay.PanY;
                mLineMaxTool_ROI.SideXLength      = 100;
                mLineMaxTool_ROI.SideYLength      = 100;
                mLineMaxTool.InputImage           = (CogImage8Grey)mCogRecordDisplay.Image;
                //mCogRecordDisplay.InteractiveGraphics.Add(mLineMaxTool_ROI, "LineMAx_ROI_Area", false);//在影像上加入教讀框

                mCogRecordDisplay.Record = mLineMaxTool.CreateCurrentRecord().SubRecords["InputImage"];

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("LineMaxTool ROI_Create Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #6
0
        }//CCD停止取像結束

        /// <summary>
        /// 開啟影像檔
        /// </summary>
        /// <param name="TempCCDDisplay">CCDDisplay畫面</param>
        /// <param name="FilePath">路徑</param>
        /// <returns>回傳是否開啟影像成功</returns>
        public static Boolean Image_Open_Function(Cognex.VisionPro.CogRecordDisplay TempCCDDisplay, string FilePath)//開啟影像檔
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            #region 開啟影像檔
            try
            {
                //Cognex開起影像檔
                CogImageFileTool_Tool.Operator.Open(FilePath, CogImageFileModeConstants.Read);
                CogImageFileTool_Tool.Run();
                TempCCDDisplay.Image = (Cognex.VisionPro.CogImage8Grey)CogImageFileTool_Tool.OutputImage;

                //清除畫面調整大小
                TempCCDDisplay.Fit();
                TempCCDDisplay.StaticGraphics.Clear();
                TempCCDDisplay.InteractiveGraphics.Clear();

                SaveLog.Msg_("開啟影像 " + FilePath);
                return(true);
            }

            catch (Exception ex)
            {
                SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }


            #endregion 開啟影像檔
        }//開啟影像檔結束
Beispiel #7
0
        public Boolean CheckVPPFile(string FileName)//檢查檔案是否存在
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                //檢查路徑檔案是否存在
                string strFolderPath = @"D:\VPS_File\Product\LineMaxTool\" + @FileName + @"\";
                FileName = strFolderPath + FileName + "_LMT.vpp";

                if (File.Exists(FileName))
                {
                    SaveLog.Msg_("Data File exists : " + FileName);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                mLineMaxTool_status = false;
                SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());

                return(true);
            }
        }
Beispiel #8
0
        /// <summary>
        /// CCD單張取像
        /// </summary>
        /// <param name="TempcogDisplay">CCDDisplay畫面</param>
        /// <param name="TempCameras">CCD實體相機個數</param>
        /// <returns>回傳是否成功單張取像</returns>
        public static Boolean Grab_Image_Function(Cognex.VisionPro.CogRecordDisplay TempCCDDisplay, VisionCameras TempCameras)//CCD單張取像
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            #region 單張取像

            if (CCDNumber_Load_[(Int32)TempCameras])//如果CCD有初始化成功
            {
                try
                {
                    TempCCDDisplay.StaticGraphics.Clear();
                    TempCCDDisplay.InteractiveGraphics.Clear();
                    TempCCDDisplay.Image = (Cognex.VisionPro.CogImage8Grey)ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras].Acquire(out CCDNumber_GrabOut_);//單張取像

                    SaveLog.Msg_("單張取像 " + TempCameras.ToString());
                    return(true);
                }
                catch (Exception ex)
                {
                    SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                    SaveLog.Msg_("單張取像失敗 " + TempCameras.ToString());
                    return(false);
                }
            }
            else
            {
                SaveLog.Msg_("未載入相機 " + TempCameras.ToString());
                return(true);
            }
            #endregion 單張取像
        }//CCD單張取像結束
Beispiel #9
0
        public Boolean CheckVPPFile(string FileName)//檢查檔案是否存在
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                //檢查路徑檔案是否存在
                string strFolderPath = @"D:\VPS_File\Product\FindCircleTool\" + @FileName + @"\";
                FileName = strFolderPath + FileName + "_FCT.vpp";

                if (File.Exists(FileName))
                {
                    SaveLog.Msg_("Data File exists : " + FileName);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                FindCircleTool_Status = false;
                SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                MessageBox.Show(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString(), "確認", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);

                return(true);
            }
        }
Beispiel #10
0
        public bool ROI_Create(CogRecordDisplay mCogRecordDisplay)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                Double CenterX = 107.25;
                Double CenterY = 89.25;
                Double XLength = 107.5;
                Double YLength = 89.5;

                mOCR_ROI.GraphicDOFEnable = CogRectangleAffineDOFConstants.All;
                mOCR_ROI.Interactive      = true;
                mOCR_ROI.CenterX          = CenterX;
                mOCR_ROI.CenterY          = CenterY;
                mOCR_ROI.SideXLength      = XLength;
                mOCR_ROI.SideYLength      = YLength;
                mCogRecordDisplay.InteractiveGraphics.Add(mOCR_ROI, "ID_ROI_Area", false);//在影像上加入教讀框

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("OCRMaxTool Teach Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #11
0
        public Boolean Load()
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mFindCircleTool = null;
                mFindCircleTool = new CogFindCircleTool();

                mFindCircleTool_Results = null;
                mFindCircleTool_Results = new FindCircleTool_Results();

                mCenterX                     = 730.041;
                mCenterY                     = 436.627;
                mRadius                      = 377.985;
                mAngleStart                  = 78.8641;
                mAngleSpan                   = -277.93;
                mNumCalipers                 = 6;
                mNumToIgnore                 = 2;
                mCaliperSearchLength         = 177.499;
                mCaliperProjectionLength     = 54.2951;
                mCircleSearchDirectionOption = CogFindCircleSearchDirectionConstants.Outward;
                mCogCaliperPolarityConstants = CogCaliperPolarityConstants.LightToDark;

                FindCircleTool_Status = false;

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindCircleTool Load Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #12
0
        public bool Run(CogRecordDisplay mCogRecordDisplay)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mIDTool.InputImage = (CogImage8Grey)mCogRecordDisplay.Image;
                mIDTool.RunParams.DisableAllCodes();
                mIDTool.RunParams.QRCode.Enabled = true;
                mIDTool.Region = mID_ROI;

                mIDTool.Run();

                if (mIDTool.RunStatus.Result == CogToolResultConstants.Accept && mIDTool.Results.Count > 0)
                {
                    mCogRecordDisplay.StaticGraphics.Add(mIDTool.Results[0].CreateResultGraphics(CogIDResultGraphicConstants.All), "Result");

                    mIDTool_Status = true;
                    mDecodedData   = mIDTool.Results[0].DecodedData.DecodedString;
                    SaveLog.Msg_("2D Code : " + mIDTool.Results[0].DecodedData.DecodedString);
                    return(true);
                }
                else
                {
                    mDecodedData = "NG";
                    SaveLog.Msg_("讀取2D Code失敗。");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("IDTool Run Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #13
0
        public bool Run(CogRecordDisplay mCogRecordDisplay)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mOCRMaxTool.Run();

                ICogRunStatus aRunStatus = mOCRMaxTool.RunStatus;

                if (aRunStatus.Result == CogToolResultConstants.Error)
                {
                    SaveLog.Msg_("Error running CogOCRMaxTool.");
                    mOCRMaxTool_Status = false;
                    return(false);
                }
                else
                {
                    mCogRecordDisplay.Record = mOCRMaxTool.CreateLastRunRecord().SubRecords["InputImage"];
                    SaveLog.Msg_(mOCRMaxTool.LineResult.ResultString);
                    mOCRMaxTool_Status = true;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("OCRMaxTool Run Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                mOCRMaxTool_Status = false;
                return(false);
            }
        }
Beispiel #14
0
        public Boolean LoadFromVPPFile(string FileName)//檔案參數載入
        {
            string ProcID       = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();
            string TempFileName = (string)FileName;

            try
            {
                //從CogTool裡面讀出來
                string       strFolderPath = @"D:\VPS_File\Product\FindCircleTool\" + @FileName + @"\";
                CogToolBlock ToolBlock1    = new CogToolBlock();

                FileName = strFolderPath + FileName + "_FCT.vpp";

                ToolBlock1 = (CogToolBlock)CogSerializer.LoadObjectFromFile(FileName);//開啟ToolBlock vpp檔案

                //依序載入
                mFindCircleTool = (CogFindCircleTool)ToolBlock1.Tools[TempFileName + "_FindCircleTool_"];
                mFindCircleTool.Run();

                SaveLog.Msg_("Data of Find Circle Tool Loaded : " + @FileName);
                ToolBlock1 = null;

                FindCircleTool_Status = true;
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("Save FindCircleTool Data Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                FindCircleTool_Status = false;
                return(false);
            }
        }
Beispiel #15
0
        public Boolean LoadFromVPPFile(string FileName, CogRecordDisplay mCogRecordDisplay)//檔案參數載入
        {
            string ProcID       = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();
            string TempFileName = (string)FileName;

            try
            {
                //從CogTool裡面讀出來
                string       strFolderPath = @"D:\VPS_File\Product\LineMaxTool\" + @FileName + @"\";
                CogToolBlock ToolBlock1    = new CogToolBlock();

                FileName = strFolderPath + FileName + "_LMT.vpp";

                ToolBlock1 = (CogToolBlock)CogSerializer.LoadObjectFromFile(FileName);//開啟ToolBlock vpp檔案

                //依序載入
                mLineMaxTool = (CogLineMaxTool)ToolBlock1.Tools[TempFileName + "_LineMaxTool_"];
                this.ROI_Create(mCogRecordDisplay);

                SaveLog.Msg_("Data of LineMaxTool Loaded : " + @FileName);
                ToolBlock1 = null;

                mLineMaxTool_status = true;
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("Load LineMaxTool Data Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                mLineMaxTool_status = false;
                return(false);
            }
        }
Beispiel #16
0
 public Form1()
 {
     InitializeComponent();
     SaveLog.Load_Log();
     SaveLog.RichTextBox_MSG = this.RichTextBox_MSG;
     //Vision_Basic.Load_Cameras(Vision_Basic.VisionCameras.Cameras0);
     //Vision_Basic.CCD_Exposure_Function(Vision_Basic.VisionCameras.Cameras0, 300);
     mLineMaxTool.Load();
 }
Beispiel #17
0
 public bool setNumCalipers(int num)
 {
     if (num >= 2)
     {
         mNumCalipers = num;
         return(true);
     }
     else
     {
         SaveLog.Msg_("setNumCalipers Failed, must greater than 1!");
         return(false);
     }
 }
Beispiel #18
0
 public bool setCaliperProjectionLength(int length)
 {
     if (length > 0)
     {
         mCaliperProjectionLength = length;
         return(true);
     }
     else
     {
         SaveLog.Msg_("setCaliperProjectionLength Failed, must greatr than 0!");
         return(false);
     }
 }
Beispiel #19
0
        public static CogRecordDisplay CogDisplay_Public;//公開的CogDisplay控制項
        #endregion CogDisplay元件

        /// <summary>
        /// 載入CCD
        /// </summary>
        /// <param name="TempcogDisplay">CCDDisplay畫面</param>
        /// <param name="TempCameras">CCD實體相機個數</param>
        /// <returns>回傳是否成功開啟CCD</returns>
        public static Boolean Load_Cameras(VisionCameras TempCameras)//載入CCD
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            #region 開啟相機
            CCDNumber_Load_[(Int32)TempCameras] = false;
            ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras] = null;
            try
            {
                CogFrameGrabberGigEs_TopCameras_Tool = new CogFrameGrabberGigEs();
                if (CogFrameGrabberGigEs_TopCameras_Tool.Count > 0)                    //有找到一台以上的相機
                {
                    CogFrameGrabberGigEs_TopCameras_Tool = new CogFrameGrabberGigEs(); //宣告CogFrameGrabberGigEs
                    //中斷連線
                    CogFrameGrabberGigEs_TopCameras_Tool[CCDNumber_[(Int32)TempCameras]].Disconnect(true);
                    //設定影像格式
                    CCDNumber_VideoFormat[0] = CogFrameGrabberGigEs_TopCameras_Tool[CCDNumber_[(Int32)TempCameras]].AvailableVideoFormats[0];
                    //取得相機控制權
                    ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras] = CogFrameGrabberGigEs_TopCameras_Tool[CCDNumber_[(Int32)TempCameras]].CreateAcqFifo(CCDNumber_VideoFormat[0], CogAcqFifoPixelFormatConstants.Format8Grey, 0, true);
                    //載入成功
                    CCDNumber_Load_[(Int32)TempCameras]  = true;
                    CogFrameGrabberGigEs_TopCameras_Tool = null;//釋放CogFrameGrabberGigEs

                    SaveLog.Msg_("開起相機 " + TempCameras.ToString() + " 完成");
                    return(true);
                }
                else
                {
                    //載入失敗
                    CCDNumber_Load_[(Int32)TempCameras] = false;
                    SaveLog.Msg_("開起相機 " + TempCameras.ToString() + " 失敗");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());

                if (CogFrameGrabberGigEs_TopCameras_Tool != null)
                {
                    CogFrameGrabberGigEs_TopCameras_Tool = null;                                              //釋放CogFrameGrabberGigEs
                }
                CCDNumber_Load_[(Int32)TempCameras] = false;
                return(false);
            }
            #endregion 開啟相機
        }//載入CCD結束
Beispiel #20
0
        public bool unLoad()
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mIDTool = null;
                mID_ROI = null;

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("IDTool Load Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #21
0
        }//CCD單張取像結束

        /// <summary>
        /// CCD連續取像
        /// </summary>
        /// <param name="TempCCDDisplay">CCDDisplay畫面</param>
        /// <param name="TempCCDAcqFifo">CCD實體相機串流口</param>
        /// <param name="CCD_Load">CCD是否成功載入旗標</param>
        /// <returns>回傳是否成功連續取像</returns>
        public static Boolean Live_Image_Function(Cognex.VisionPro.CogRecordDisplay TempCCDDisplay, VisionCameras TempCameras)//CCD連續取像
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            #region 連續取像
            if (CCDNumber_Load_[(Int32)TempCameras])//如果Camera有初始化成功
            {
                try
                {
                    if (CCDNumber_LiveFleg_[(Int32)TempCameras] == false)
                    {
                        //取像中
                        TempCCDDisplay.StaticGraphics.Clear();
                        TempCCDDisplay.InteractiveGraphics.Clear();                                              //清空影像
                        TempCCDDisplay.StartLiveDisplay(ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras]); //建立影像fifo與Camers連結關聯
                        CCDNumber_LiveFleg_[(Int32)TempCameras] = true;

                        SaveLog.Msg_("取像" + TempCameras.ToString());
                    }
                    else
                    {
                        //靜止取像
                        CCDNumber_LiveFleg_[(Int32)TempCameras] = false;
                        TempCCDDisplay.StopLiveDisplay();
                        //單張取像
                        TempCCDDisplay.Image = (Cognex.VisionPro.CogImage8Grey)ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras].Acquire(out CCDNumber_GrabOut_);

                        SaveLog.Msg_("停止取像" + TempCameras.ToString());
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());

                    CCDNumber_LiveFleg_[(Int32)TempCameras] = false;
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            #endregion 連續取像
        }//CCD連續取像結束
Beispiel #22
0
        public Boolean unLoad()
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mFindCircleTool = null;

                FindCircleTool_Status = false;

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindCircleTool unLoad Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #23
0
        private Boolean make_results()
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                if (mFindCircleTool.Results != null)
                {
                    CogCircle      iCircle      = mFindCircleTool.Results.GetCircle();
                    CogCircularArc iCircularArc = mFindCircleTool.Results.GetCircularArc();

                    if (iCircle != null && iCircularArc != null)
                    {
                        mFindCircleTool_Results.Circle_CenterX         = iCircle.CenterX;
                        mFindCircleTool_Results.Circle_CenterY         = iCircle.CenterY;
                        mFindCircleTool_Results.Circle_Radius          = iCircle.Radius;
                        mFindCircleTool_Results.CircularArc_CenterX    = iCircularArc.CenterX;
                        mFindCircleTool_Results.CircularArc_CenterY    = iCircularArc.CenterY;
                        mFindCircleTool_Results.CircularArc_Radius     = iCircularArc.Radius;
                        mFindCircleTool_Results.CircularArc_AngleStart = iCircularArc.AngleStart;
                        mFindCircleTool_Results.CircularArc_AngleSpan  = iCircularArc.AngleSpan;
                        return(true);
                    }
                    else
                    {
                        SaveLog.Msg_("iCircle or iCircularArc is null!");
                        return(false);
                    }
                }
                else
                {
                    SaveLog.Msg_("FindCircleTool Doesn't have any result!");
                    return(false);
                    //MessageBox.Show("Didn't find any line");
                }
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindCircleTool make_results Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
        public Boolean Run(CogImage8Grey mInputImage)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            FindLineTool_Status = false;

            try
            {
                mFindLineTool.InputImage = mInputImage;

                mFindLineTool.Run();
                FindLineTool_Status = true;
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindLineTool ROI_create Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
        private Boolean make_results()
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                if (mFindLineTool.Results != null)
                {
                    CogLine        iLine        = mFindLineTool.Results.GetLine();
                    CogLineSegment iLineSegment = mFindLineTool.Results.GetLineSegment();

                    if (iLine != null && iLineSegment != null)
                    {
                        mFindLineTool_Results.lineX    = iLine.X;
                        mFindLineTool_Results.lineY    = iLine.Y;
                        mFindLineTool_Results.rotation = iLine.Rotation;
                        mFindLineTool_Results.startX   = iLineSegment.StartX;
                        mFindLineTool_Results.startY   = iLineSegment.StartY;
                        mFindLineTool_Results.endX     = iLineSegment.EndX;
                        mFindLineTool_Results.endY     = iLineSegment.EndY;
                        return(true);
                    }
                    else
                    {
                        SaveLog.Msg_("iLine or iLineSegment is null!");
                        return(false);
                    }
                }
                else
                {
                    SaveLog.Msg_("FindLineTool Doesn't have any result!");
                    return(false);
                    //MessageBox.Show("Didn't find any line");
                }
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindLineTool make_results Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
        public void Show()
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                if (mFindLineTool.Results != null)
                {
                    CogLine iLine = mFindLineTool.Results.GetLine();
                    MessageBox.Show("X=" + iLine.X + "\nY=" + iLine.Y);
                }
                else
                {
                    MessageBox.Show("Didn't find any line");
                }
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindLineTool ROI_create Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
            }
        }
Beispiel #27
0
        }//CCD連續取像結束

        public static Boolean Get_Cameras_Live_Status(VisionCameras TempCameras)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            if (CCDNumber_Load_[(Int32)TempCameras])//如果Camera有初始化成功
            {
                try
                {
                    return(CCDNumber_LiveFleg_[(Int32)TempCameras]);
                }
                catch (Exception ex)
                {
                    SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #28
0
        public Boolean Run(CogRecordDisplay CogRecordDisplay1)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            FindCircleTool_Status = false;

            try
            {
                mFindCircleTool.InputImage = (CogImage8Grey)CogRecordDisplay1.Image;

                mFindCircleTool.Run();
                CogRecordDisplay1.Record = mFindCircleTool.CreateLastRunRecord().SubRecords["InputImage"];
                FindCircleTool_Status    = true;
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("FindCircleTool Run Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                return(false);
            }
        }
Beispiel #29
0
        /// <summary>
        /// CCD停止取像
        /// </summary>
        /// <param name="TempCCDDisplay">CCDDisplay畫面</param>
        /// <param name="TempCCDAcqFifo">CCD實體相機串流口</param>
        /// <param name="CCD_Load">CCD是否成功載入旗標</param>
        /// <returns>回傳是否成功停止取像</returns>
        public static Boolean StopLive_Image_Function(Cognex.VisionPro.CogRecordDisplay TempCCDDisplay, VisionCameras TempCameras)//CCD停止取像
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            #region 停止取像

            Int32 TempCameras_ = (int)TempCameras;

            if (CCDNumber_Load_[(Int32)TempCameras])//如果Camera有初始化成功
            {
                try
                {
                    CCDNumber_LiveFleg_[TempCameras_] = false;

                    //停止取像
                    TempCCDDisplay.StopLiveDisplay();

                    //單張取像
                    TempCCDDisplay.Image = (Cognex.VisionPro.CogImage8Grey)ICogAcqFifo_CCDNumber_AcqFifo_Tool[(Int32)TempCameras].Acquire(out CCDNumber_GrabOut_);

                    Thread.Sleep(50);

                    SaveLog.Msg_("停止取像" + TempCameras.ToString());
                    return(true);
                }
                catch (Exception ex)
                {
                    SaveLog.Msg_(ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());

                    CCDNumber_LiveFleg_[TempCameras_] = false;
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            #endregion 停止取像
        }//CCD停止取像結束
Beispiel #30
-1
        public bool Run(CogRecordDisplay mCogRecordDisplay)
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                mLineMaxTool.InputImage = (CogImage8Grey)mCogRecordDisplay.Image;
                mLineMaxTool.Run();
                mCogRecordDisplay.Record = mLineMaxTool.CreateLastRunRecord().SubRecords["InputImage"];
                mLineMaxTool_status      = true;

                if (mLineMaxTool.Results != null)
                {
                    iLine        = new CogLine[mLineMaxTool.Results.Count];
                    iLineSegment = new CogLineSegment[mLineMaxTool.Results.Count];

                    for (int i = 0; i < mLineMaxTool.Results.Count; i++)
                    {
                        iLine[i]        = mLineMaxTool.Results[i].GetLine();
                        iLineSegment[i] = mLineMaxTool.Results[i].GetLineSegment();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("LineMaxTool Run Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                mLineMaxTool_status = false;
                return(false);
            }
        }