Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public bool FiducialToolBlock(CogImage8Grey Image, out double offset_x, out double offset_y, out double offset_theta)
        {
            offset_x     = 0;
            offset_y     = 0;
            offset_theta = 0;
            bool   runStatus = true;
            String colResult;
            int    i;

            if (this.cogToolRun != null)
            {
                this.cogToolRun.Inputs["InputImage"].Value         = Image as CogImage8Grey;
                this.cogToolRun.Inputs["ImageDirectoryPath"].Value = imagedirectorypath;
                this.cogToolRun.Inputs["SaveDefectImages"].Value   = savedefectimages;
                this.cogToolRun.Inputs["SaveAllImages"].Value      = saveallimages;

                this.cogToolRun.Run();

                ICogRunStatus cogStatus = this.cogToolRun.RunStatus;

                if (cogStatus.Result == CogToolResultConstants.Error)
                {
                    runStatus = false;
                }
                else
                {
                    try
                    {
                        offset_x     = (double)this.cogToolRun.Outputs["Tool1XOffset"].Value;
                        offset_y     = (double)this.cogToolRun.Outputs["Tool1YOffset"].Value;
                        offset_theta = (double)this.cogToolRun.Outputs["Tool1XDegree"].Value;

                        Log.Info(this, "Fiducial offset values,{0},{1},{2}", offset_x, offset_y, offset_theta);
                    }
                    catch
                    {
                        offset_x     = 0;
                        offset_y     = 0;
                        offset_theta = 0;
                    }
                }
                // Need to save images
                if (savedefectimages || saveallimages)
                {
                    _imagefilename = this.cogToolRun.Outputs["ImageFileName"].Value.ToString();
                }
            }
            else
            {
                runStatus = false;
            }


            return(runStatus);
        }
Exemplo n.º 3
0
        public bool RunTool_Pattern(int cameraModule) //no need
        {
            bool   runStatus = true;
            String colResult;
            CogToolResultConstants toolColResult;
            int i;

            if (this.cogToolRun[cameraModule] != null)
            {
                //configure the vision tool
                this.cogToolRun[cameraModule].Inputs["InputImage"].Value         = grabImage[cameraModule] as CogImage8Grey;
                this.cogToolRun[cameraModule].Inputs["SaveImage"].Value          = true;
                this.cogToolRun[cameraModule].Inputs["ImageDirectoryPath"].Value = "c:\\Seagate\\vision\\";

                this.cogToolRun[cameraModule].Run();

                ICogRunStatus cogStatus = this.cogToolRun[cameraModule].RunStatus;

                if (cogStatus.Result == CogToolResultConstants.Error)
                {
                    runStatus = false;
                    // error default all to invalid
                    for (i = 0; i < MAX_RESULT; i++)
                    {
                        this.inspectResult[cameraModule, i] = HGAStatus.Unknown;
                    }
                }
                else
                {
                    double[] score          = { 0, 0, 0, 0, 0, 0 };
                    double[] centerofmass_X = { 0, 0, 0, 0, 0, 0 };

                    cogpmaligntool = (CogPMAlignTool)this.cogToolRun[cameraModule].Tools["PatternTool"];
                    CogPMAlignResults resultcollection = cogpmaligntool.Results;
                    for (int x = 0; x < resultcollection.Count; x++)
                    {
                        score[x]          = resultcollection[x].Score;
                        centerofmass_X[x] = resultcollection[x].GetPose().TranslationX;
                    }
                }
            }
            else
            {
                runStatus = false;
            }

            return(runStatus);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Do a run on current displayed Image
        /// </summary>
        public bool RunToolBlock(int cameraModule)
        {
            bool   runStatus = true;
            String colResult;
            CogToolResultConstants toolColResult;
            int i;

            if (this.cogToolRun[cameraModule] != null)
            {
                this.cogToolRun[cameraModule].Inputs["InputImage"].Value = grabImage[cameraModule] as CogImage8Grey;

                this.cogToolRun[cameraModule].Run();

                ICogRunStatus cogStatus = this.cogToolRun[cameraModule].RunStatus;

                if (cogStatus.Result == CogToolResultConstants.Error)
                {
                    runStatus = false;
                    // error default all to invalid
                    for (i = 0; i < MAX_RESULT; i++)
                    {
                        this.inspectResult[cameraModule, i] = HGAStatus.Unknown;
                    }
                }
                else
                {
                    double[] blob           = { 0, 0, 0, 0, 0, 0 };
                    double[] centerofmass_X = { 0, 0, 0, 0, 0, 0 };
                    CommonCogToolBlock = (CogBlobTool)this.cogToolRun[cameraModule].Tools["blobtool"];

                    CogBlobResultCollection resultcollection = CommonCogToolBlock.Results.GetBlobs();
                    for (int x = 0; x < resultcollection.Count; x++)
                    {
                        blob[x]           = resultcollection[x].Area;
                        centerofmass_X[x] = resultcollection[x].CenterOfMassX;
                    }
                }
            }
            else
            {
                runStatus = false;
            }

            return(runStatus);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Do a run on current displayed Image
        /// </summary>
        public bool RunToolBlock(CogImage8Grey Image, String CarrierID)
        {
            bool   runStatus = true;
            String colResult;
            int    i;

            if (this.cogToolRun != null)
            {
                this.cogToolRun.Inputs["InputImage"].Value         = Image as CogImage8Grey;
                this.cogToolRun.Inputs["ImageDirectoryPath"].Value = imagedirectorypath;
                this.cogToolRun.Inputs["SaveDefectImages"].Value   = savedefectimages;
                this.cogToolRun.Inputs["SaveAllImages"].Value      = saveallimages;
                this.cogToolRun.Inputs["CarrierID"].Value          = CarrierID;


                this.cogToolRun.Run();

                ICogRunStatus cogStatus = this.cogToolRun.RunStatus;

                if (cogStatus.Result == CogToolResultConstants.Error)
                {
                    runStatus = false;
                    // error default all to invalid
                    for (i = 0; i < MAX_RESULT; i++)
                    {
                        inspectResult[i] = HGAStatus.Unknown;
                    }
                }
                else
                {
                    for (i = 0; i < MAX_RESULT; i++)
                    {
                        colResult = String.Format("hga{0}", i + 1);
                        try
                        {
                            if (this.cogToolRun.Outputs[colResult].Value.ToString().Equals("1"))
                            {
                                inspectResult[i] = Utils.HGAStatus.HGAPresent;
                            }
                            else
                            {
                                inspectResult[i] = Utils.HGAStatus.NoHGAPresent;
                            }
                        }
                        catch
                        {
                            inspectResult[i] = Utils.HGAStatus.Unknown;
                        }
                    }
                }
                // Need to save images
                if (savedefectimages || saveallimages)
                {
                    _imagefilename = this.cogToolRun.Outputs["ImageFileName"].Value.ToString();
                }
            }
            else
            {
                runStatus = false;
            }
            try
            {
                _isboatreverse = (bool)this.cogToolRun.Outputs["BoatReverse"].Value;
                _isDycemBoat   = (bool)this.cogToolRun.Outputs["DyCemBoat"].Value;
                Log.Info(this, "Boat is reverse = {0}", _isboatreverse);
                Log.Info(this, "Boat is dycem boat = {0}", _isDycemBoat);
            }
            catch
            {
                _isboatreverse = false;
                _isDycemBoat   = false;
            }

            try
            {
                if (!this.cogToolRun.Outputs["ErrorMessage"].Value.Equals("NoError"))
                {
                    runStatus     = false;
                    _errorMessage = (string)this.cogToolRun.Outputs["ErrorMessage"].Value;
                    Log.Info(this, "Cognex Vision Error: {0}", _errorMessage);
                }
            }
            catch
            {
            }

            return(runStatus);
        }