Exemple #1
0
      public ICogImage Grab_Image(ICogAcqFifo CamFifo)
      {
          ICogImage GrabImage;

          try
          {
              CamFifo.AcquiredPixelFormat();

              int TrigOut;
              GrabImage = CamFifo.Acquire(out TrigOut) as CogImage8Grey;

              return(GrabImage);
          }
          catch (Exception e)
          {
              return(null);
          }
      }
Exemple #2
0
        private void Image_Timer_Tick(object sender, EventArgs e)
        {
            ICogAcqFifo AcqFifo  = null;
            ICogImage   cogImage = null;

            AcqFifo = ParentForm._acqFifo1;

            if (AcqFifo != null)
            {
                // Acquire an image
                int trigNum;
                //      Cognex.VisionPro.ICogImage image;
                try
                {
                    cogImage = AcqFifo.Acquire(out trigNum);
                }
                catch (Exception ex)
                {
                }


                ScanDisplay.Image = cogImage;

/*
 *              if (CurrentTopLeft.X >= 0 && CurrentTopLeft.Y >= 0 && CurrentTopLeft.X < ScanDisplay.Width && CurrentTopLeft.Y < ScanDisplay.Height &&
 *                  CurrentBottomRight.X >= 0 && CurrentBottomRight.Y >= 0 && CurrentBottomRight.X < ScanDisplay.Width && CurrentBottomRight.Y < ScanDisplay.Height)
 *                  g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, CurrentBottomRight.X - CurrentTopLeft.X, CurrentBottomRight.Y - CurrentTopLeft.Y);
 */
                Point  TPointLT = new Point();
                Point  TPointRB = new Point();
                double dZoom;
                double dDx = 0;
                double dDy = 0;
                double dIx = 0;
                double dIy = 0;
                if (ScanDisplay != null)
                {
                    dDx = ScanDisplay.Width;
                    dDy = ScanDisplay.Height;
                    if (ScanDisplay.Image != null)
                    {
                        dIx = ScanDisplay.Image.Width;
                        dIy = ScanDisplay.Image.Height;
                    }
                }
                dZoom = ScanDisplay.Zoom;
                string    strData;
                string [] strArray;
                for (int i = 0; i < gridRectList.Rows.Count; i++)
                {
                    if (gridRectList.Rows[i].Cells[0].Value != null)
                    {
                        strData    = gridRectList.Rows[i].Cells[0].Value.ToString();
                        strArray   = (strData + ",,,,,").Split(',');
                        TPointLT.X = int.Parse(strArray[0]);
                        TPointLT.Y = int.Parse(strArray[1]);
                        TPointRB.X = int.Parse(strArray[2]);
                        TPointRB.Y = int.Parse(strArray[3]);


                        if (TPointLT.X >= 0 && TPointLT.Y >= 0 && TPointLT.X < ScanDisplay.Width && TPointLT.Y < ScanDisplay.Height &&
                            TPointRB.X >= 0 && TPointRB.Y >= 0 && TPointRB.X < ScanDisplay.Width && TPointRB.Y < ScanDisplay.Height)
                        {
                            g.DrawRectangle(RectPen, TPointLT.X, TPointLT.Y, TPointRB.X - TPointLT.X, TPointRB.Y - TPointLT.Y);
                        }
                    }
                }
                //  BarcodeScan();
            }

            GC.Collect();
        }