コード例 #1
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);
            }
        }
コード例 #2
0
        private void brightnessUpDown_ValueChanged(object sender, EventArgs e)
        {
            myFrameGrabbers = new CogFrameGrabbers();
            myFrameGrabber  = myFrameGrabbers[0];

            myAcqFifo = AcqFifoTool.Operator;
            myAcqFifo.OwnedBrightnessParams.Brightness = cogAcqTool.Operator.OwnedBrightnessParams.Brightness;
            brightnessParams = myAcqFifo.OwnedBrightnessParams;
            if (brightnessParams != null)
            {
                brightnessParams.Brightness = Convert.ToDouble(brightnessUpDown.Value);
                myAcqFifo.OwnedBrightnessParams.Brightness           = brightnessParams.Brightness;
                cogAcqTool.Operator.OwnedBrightnessParams.Brightness = brightnessParams.Brightness;
            }
        }
コード例 #3
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;
        }
コード例 #4
0
        public void InitVision()
        {
            SettingUp          = false;
            ImageFileTool      = CogImageFileEdit1.Subject;
            ImageFileTool.Ran += ImageFileTool_Ran;
            //Set reference to CogAcqFifoTool created by Edit Control
            //The Acq Fifo Edit Control creates its subject when its AutoCreateTool property is True
            AcqFifoTool      = CogAcqFifoEdit1.Subject;
            AcqFifoTool.Ran += AcqFifoTool_Ran;

            cogAcqTool = CogAcqFifoEdit1.Subject;
            cogAcqTool = cogToolBlockEditV21.Subject.Tools["CogAcqFifoTool1"] as CogAcqFifoTool;
            cogAcqTool.Run();

            //Operator will be Nothing if no Frame Grabber is available.  Disable the Frame Grabber
            //option on the "VisionPro Demo" tab if no frame grabber available.
            if (AcqFifoTool.Operator == null)
            {
                optImageAcquisitionOptionFrameGrabber.Enabled = false;
            }

            //Initialize the Dialog box for the "Open File" button on the "VisionPro Demo" tab.
            ImageAcquisitionCommonDialog.Filter          = ImageFileTool.Operator.FilterText;
            ImageAcquisitionCommonDialog.CheckFileExists = true;
            ImageAcquisitionCommonDialog.ReadOnlyChecked = true;

            //AutoCreateTool for the PMAlign edit control is False, therefore, we must create
            //a PMAlign tool and set the subject of the control to reference the new tool.
            PatMaxTool              = new CogPMAlignTool();
            PatMaxTool.Changed     += PatMaxTool_Changed;
            CogPMAlignEdit1.Subject = PatMaxTool;

            //Change the default Train Region to center of a 640x480 image & change the DOFs
            //so that Skew is not enabled.  Note - TrainRegion is of type ICogRegion, therefore,
            //we must use a CogRectangleAffine reference in order to call CogRectangleAffine
            //properties.
            CogRectangleAffine PatMaxTrainRegion = default(CogRectangleAffine);

            PatMaxTrainRegion = PatMaxTool.Pattern.TrainRegion as CogRectangleAffine;
            //PatMaxTrainRegion = cogPMAlignTool.Pattern.TrainRegion as CogRectangleAffine;
            if ((PatMaxTrainRegion != null))
            {
                PatMaxTrainRegion.SetCenterLengthsRotationSkew(320, 240, 100, 100, 0, 0);
                PatMaxTrainRegion.GraphicDOFEnable = CogRectangleAffineDOFConstants.Position | CogRectangleAffineDOFConstants.Rotation | CogRectangleAffineDOFConstants.Size;
            }
            //PatMaxTool.SearchRegion = PatMaxSearchRegion;
            //PatMaxSearchRegion.SetCenterWidthHeight(320, 240, 640, 480);
            //PatMaxSearchRegion.GraphicDOFEnable = CogRectangleDOFConstants.Position | CogRectangleDOFConstants.Size;
            //PatMaxSearchRegion.Interactive = true;
            numericUpDown1.Value = Convert.ToDecimal(cogPMAlignTool.RunParams.AcceptThreshold);
            PatMaxTool.RunParams.AcceptThreshold = Convert.ToDouble(numericUpDown1.Value);
            numericUpDown2.Value = Convert.ToDecimal(cogPMAlignTool.RunParams.ApproximateNumberToFind);
            PatMaxTool.RunParams.ApproximateNumberToFind = Convert.ToInt32(numericUpDown2.Value);
            myAcqFifo = AcqFifoTool.Operator;
            try
            {
                myFrameGrabber       = cogAcqTool.Operator.FrameGrabber;
                myAcqFifo            = cogAcqTool.Operator;
                AcqFifoTool.Operator = myAcqFifo;

                myAcqFifo.OwnedContrastParams.Contrast     = cogAcqTool.Operator.OwnedContrastParams.Contrast;
                myAcqFifo.OwnedBrightnessParams.Brightness = cogAcqTool.Operator.OwnedBrightnessParams.Brightness;
                brightnessParams = myAcqFifo.OwnedBrightnessParams;
                contrastParams   = myAcqFifo.OwnedContrastParams;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (brightnessParams != null)
            {
                brightnessUpDown.Value = Convert.ToDecimal(brightnessParams.Brightness);
            }
            if (contrastParams != null)
            {
                contrastUpDown.Value = Convert.ToDecimal(contrastParams.Contrast);
            }
            try
            {
                cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Input image wasn't set");
            }
        }