Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdImageAcquisitionNewImageCommand_Click(System.Object sender, System.EventArgs e)
        {
            ROIParams = myAcqFifo.OwnedROIParams;
            if (AppGen.Inst.MDImain.frmVisionMain.FrmLoadtray.flagFullTray)
            {
                //AppGen.Inst.VisionParam.xyLoadWorldTrayOrigin.x = 166
                //AppGen.Inst.VisionParam.xyLoadWorldTrayOrigin.y = 595
                PatMaxSearchRegion.SetXYWidthHeight(AppGen.Inst.VisionParam.xyLoadWorldTrayOrigin.X, (AppGen.Inst.VisionParam.xyLoadWorldTrayOrigin.Y - 320), 350, 320);  //tbd: replace to parameters
                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            }
            else
            {      //tbd: replace to parameters
                cogTransform2DLinearN2N = CalibNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform() as CogTransform2DLinear;
                PatMaxSearchRegion.SetCenterWidthHeight(AppGen.Inst.VisionParam.xyLoadWorldTrayOrigin.X - 3 + (AppGen.Inst.LoadTray.
                                                                                                               IndexList[AppGen.Inst.LoadTray.CurrIndex].X_file),
                                                        (AppGen.Inst.VisionParam.xyLoadWorldTrayOrigin.Y + 3 - AppGen.Inst.LoadTray.IndexList[AppGen.Inst.LoadTray.CurrIndex].Y_file),
                                                        (xSearchReg), (ySearchReg));
                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            }
            AcqFifoTool.Run();
            if (flagDisplayResult)  //add on 25/11/14
            {
                cogRecordDisplay1.Fit(true);
                cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
            }


            if ((cogPMAlignTool.SearchRegion != null) && !AppGen.Inst.MDImain.frmVisionMain.FrmLoadtray.flagFullTray)
            {
                //cogPMAlignTool.SearchRegion.FitToImage(cogRecordDisplay1.Image, 0.990,0.999);
                cogRecordDisplay1.StaticGraphics.Add(cogPMAlignTool.SearchRegion as ICogGraphic, "test");
                cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
            }
        }
Exemplo n.º 2
0
        public Camera(ICogAcqFifo acqFifo)
        {
            if (acqFifo == null)
            {
                return;
            }
            cogAcqFifo = acqFifo;

            cogROIParams = cogAcqFifo.OwnedROIParams;

            cogContrast   = cogAcqFifo.OwnedContrastParams;
            cogExposure   = cogAcqFifo.OwnedExposureParams;
            cogBrightness = cogAcqFifo.OwnedBrightnessParams;
            cogAcqTrigger = cogAcqFifo.OwnedTriggerParams;

            GrabTime = DateTime.MinValue;
        }
        private void cmdImageAcquisitionNewImageCommand_Click(System.Object sender, System.EventArgs e)         //aquire
        {
            //ROIParams = myAcqFifo.OwnedROIParams;
            //if (AppGen.Inst.MDImain.frmVisionMain.FrmUnloadCarrier.flagFullTray)
            //{
            //    //PatMaxSearchRegion.SetXYWidthHeight(0, 0, 349.08, 296.54);
            //    //cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            //    ROIParams.SetROIXYWidthHeight(StartXIndx, StartYIndx, MaxXWidth, MaxYWidth);
            //}
            //else
            //{
            //    try
            //    {
            //        CurrLineCoord = StartYIndx + (((AppGen.Inst.MainCycle.UnloadCarrierSliceNo - 1) * ySearchReg));      //added 11.06.14 by asaf
            //        ROIParams.SetROIXYWidthHeight(Convert.ToInt32(StartXIndx*2.5), Convert.ToInt32(CurrLineCoord), xSearchReg-1100, ySearchReg+150);
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show(ex.Message, "PatMax Setup Error");
            //    }
            //}
            ROIParams = myAcqFifo.OwnedROIParams;
            if (AppGen.Inst.MDImain.frmVisionMain.FrmUnloadCarrier.flagFullTray)
            {
                PatMaxSearchRegion.SetXYWidthHeight(-239.175, -480.662, 237.161, 220.133);  //tbd: replace to parameters
                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            }
            else
            {      //tbd: replace to parameters
                cogTransform2DLinearN2N = CalibNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform() as CogTransform2DLinear;
                double OverLap = 0;
                switch (AppGen.Inst.MainCycle.UnloadCarrierSliceNo)
                {
                case 1:
                    OverLap = 0;
                    break;

                case 2:
                    OverLap = -30;
                    break;

                case 3:
                    OverLap = -50;
                    break;

                case 4:
                    OverLap = -80;
                    break;
                }

                CurrLineCoord = -480 + (((AppGen.Inst.MainCycle.UnloadCarrierSliceNo - 1) * ySearchReg + OverLap));
                PatMaxSearchRegion.SetXYWidthHeight(-220, CurrLineCoord, xSearchReg, ySearchReg);  //tbd: replace to parameters

                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            }
            AcqFifoTool.Run();

            cogRecordDisplay1.Fit(true);
            cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
            if ((cogPMAlignTool.SearchRegion != null) && !AppGen.Inst.MDImain.frmVisionMain.FrmUnloadCarrier.flagFullTray)
            {
                //cogPMAlignTool.SearchRegion.FitToImage(cogRecordDisplay1.Image, 0.990,0.999);
                cogRecordDisplay1.StaticGraphics.Add(cogPMAlignTool.SearchRegion as ICogGraphic, "test");
                cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
            }
        }
        private void cmdImageAcquisitionLiveOrOpenCommand_Click(System.Object sender, System.EventArgs e)
        {
            CogDisplay1.StaticGraphics.Clear();
            CogDisplay1.InteractiveGraphics.Clear();

            cogRecordDisplay1.StaticGraphics.Clear();
            cogRecordDisplay1.InteractiveGraphics.Clear();
            ROIParams = myAcqFifo.OwnedROIParams;
            //if (AppGen.Inst.MDImain.frmVisionMain.FrmUnloadCarrier.flagFullTray)
            //{
            ROIParams.SetROIXYWidthHeight(StartXIndx, StartYIndx, MaxXWidth, MaxYWidth);
            //PatMaxSearchRegion.SetXYWidthHeight(0, 0, 349.08, 296.54);
            //cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            //}
            //else
            //{
            //   // ROIParams.SetROIXYWidthHeight(Convert.ToInt32(StartXIndx * PixFactor), Convert.ToInt32(CurrLineCoord * PixFactor), Convert.ToInt32((xSearchReg + 10) * PixFactor), Convert.ToInt32((ySearchReg + 10) * PixFactor));
            //    try
            //    {
            //        CurrLineCoord = StartYIndx + (((AppGen.Inst.MainCycle.UnloadCarrierSliceNo - 1) * ySearchReg));      //added 11.06.14 by asaf
            //       //111111 ROIParams.SetROIXYWidthHeight(Convert.ToInt32(StartXIndx * 2.5), Convert.ToInt32(CurrLineCoord), xSearchReg - 1100, ySearchReg + 150);
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show(ex.Message, "PatMax Setup Error");
            //    }

            //}
            //"Live Video"  & "Stop Live" button when Frame Grabber option is selected.
            //Using our EnableAll & DisableAll subroutine to force the user stop live
            //video before doing anything else.
            if (optImageAcquisitionOptionFrameGrabber.Checked == true)
            {
                if (cogRecordDisplay1.LiveDisplayRunning)
                {
                    cogRecordDisplay1.StopLiveDisplay();
                    EnableAll(settingLiveVideo);
                    AcqFifoTool.Run();

                    cogRecordDisplay1.Fit(true);
                    cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
                }
                else if ((AcqFifoTool.Operator != null))
                {
                    AcqFifoTool.Run();

                    cogRecordDisplay1.Fit(true);
                    cogRecordDisplay1.StartLiveDisplay(AcqFifoTool.Operator, false);
                    cogRecordDisplay1.Fit(true);
                    cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
                    DisableAll(settingLiveVideo);
                    cogRecordDisplay1.Fit(true);
                }
            }
            else
            {
                //"Open File" button when image file option is selected
                //DrawingEnabled is used to simply hide the image while the Fit is performed.
                //This prevents the image from being diplayed at the initial zoom factor
                //prior to fit being called.
                try {
                    DialogResult result = ImageAcquisitionCommonDialog.ShowDialog();
                    if (result != System.Windows.Forms.DialogResult.Cancel)
                    {
                        ImageFileTool.Operator.Open(ImageAcquisitionCommonDialog.FileName, CogImageFileModeConstants.Read);
                        cogRecordDisplay1.DrawingEnabled = false;
                        ImageFileTool.Run();
                        cogRecordDisplay1.Fit(true);
                        cogRecordDisplay1.DrawingEnabled = true;
                    }
                } catch (CogException cogex) {
                    MessageBox.Show("Following Specific Cognex Error Occured:" + cogex.Message);
                } catch (Exception ex) {
                    MessageBox.Show("Following Error Occured:" + ex.Message);
                }
                cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image; //!!!!! Neet to solve why pic doesn't get into tool
            }
            cogRecordDisplay1.Fit(true);
        }
Exemplo n.º 5
0
        private void cmdImageAcquisitionLiveOrOpenCommand_Click(System.Object sender, System.EventArgs e)
        {
            txtCurrentIndex.Text = (AppGen.Inst.LoadTray.CurrIndex + 1).ToString();
            //Clear graphics, assuming a new image will be in the display once user
            //completes either Live Video or Open File operation, therefore, graphics
            //will be out of sync.
            CogDisplay1.StaticGraphics.Clear();
            CogDisplay1.InteractiveGraphics.Clear();
            cogRecordDisplay1.StaticGraphics.Clear();
            cogRecordDisplay1.InteractiveGraphics.Clear();

            ROIParams = myAcqFifo.OwnedROIParams;
            if (AppGen.Inst.MDImain.frmVisionMain.FrmLoadtray.flagFullTray)
            {
                //PatMaxSearchRegion.SetXYWidthHeight(0, 0, 349.08, 296.54);
                //cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
                PatMaxSearchRegion.SetCenterWidthHeight(StartXIndx, StartYIndx, MaxXWidth + 555, MaxYWidth + 555);
                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
            }
            else
            {
                cogTransform2DLinearN2N = CalibNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform() as CogTransform2DLinear;
                PatMaxSearchRegion.SetCenterWidthHeight(173 + (AppGen.Inst.LoadTray.
                                                               IndexList[AppGen.Inst.LoadTray.CurrIndex].X_file),
                                                        (593.7 - AppGen.Inst.LoadTray.IndexList[AppGen.Inst.LoadTray.CurrIndex].Y_file),
                                                        (xSearchReg), (ySearchReg));
                cogPMAlignTool.SearchRegion = PatMaxSearchRegion;
                //if ((cogPMAlignTool.SearchRegion != null))
                //{
                //    cogRecordDisplay1.StaticGraphics.Add(cogPMAlignTool.SearchRegion as ICogGraphic, "test");
                //    cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
                //}
            }

            //"Live Video"  & "Stop Live" button when Frame Grabber option is selected.
            //Using our EnableAll & DisableAll subroutine to force the user stop live
            //video before doing anything else.
            if (optImageAcquisitionOptionFrameGrabber.Checked == true)
            {
                if (cogRecordDisplay1.LiveDisplayRunning)
                {
                    cogRecordDisplay1.StopLiveDisplay();
                    EnableAll(settingLiveVideo);
                    AcqFifoTool.Run();

                    cogRecordDisplay1.Fit(true);
                    cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
                }
                else if ((AcqFifoTool.Operator != null))
                {
                    AcqFifoTool.Run();
                    cogRecordDisplay1.Fit(true);
                    cogRecordDisplay1.StartLiveDisplay(AcqFifoTool.Operator, false);
                    cogRecordDisplay1.Fit(true);
                    cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
                    DisableAll(settingLiveVideo);
                    cogRecordDisplay1.Fit(true);
                }
            }
            else
            {
                //"Open File" button when image file option is selected
                //DrawingEnabled is used to simply hide the image while the Fit is performed.
                //This prevents the image from being diplayed at the initial zoom factor
                //prior to fit being called.
                try
                {
                    DialogResult result = ImageAcquisitionCommonDialog.ShowDialog();
                    if (result != System.Windows.Forms.DialogResult.Cancel)
                    {
                        ImageFileTool.Operator.Open(ImageAcquisitionCommonDialog.FileName, CogImageFileModeConstants.Read);
                        cogRecordDisplay1.DrawingEnabled = false;
                        ImageFileTool.Run();
                        cogRecordDisplay1.Fit(true);
                        cogRecordDisplay1.DrawingEnabled = true;
                    }
                }
                catch (CogException cogex)
                {
                    MessageBox.Show("Following Specific Cognex Error Occured:" + cogex.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Following Error Occured:" + ex.Message);
                }
                cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image; //!!!!! Need to solve why pic doesn't get into tool
            }
            cogRecordDisplay1.Fit(true);
        }