Пример #1
0
        private void InitializeBlackWhiteCameraSettings(PtGreyCamera camera)
        {
            camera.SetAbsolutePropertyValue("VideoMode", "Continuous");
            int width  = Convert.ToInt32(camera.GetPropertyValue("WidthMax"));
            int height = Convert.ToInt32(camera.GetPropertyValue("HeightMax"));

            camera.SetAbsolutePropertyValue("Width", width.ToString());
            camera.SetAbsolutePropertyValue("Height", height.ToString());

            camera.SetProprtyEnabledSetting("AcquisitionFrameRate", true);
            camera.SetAbsolutePropertyValue("FrameRate", "10");
            camera.SetProprtyAutomaticSetting("Shutter", false);
            camera.SetAbsolutePropertyValue("ShutterMode", "Timed");
            camera.SetShutterTime(10 * 1000);

            camera.SetStreamBufferCount(1); // test only
            camera.SetAbsolutePropertyValue("StreamBufferMode", "NewestOnly");
        }
Пример #2
0
/*
 *      public bool Measure(List<System.Drawing.Bitmap> img, List<System.Drawing.Bitmap> bgImg,
 *          int brightAreaThreshold, int darkAreaThreshold,
 *          out string color, out double L, out double a, out double b,
 *          out double C, out double H, out double mask_L, out double mask_A, out string error, out double temp,
 *          out double mask2_A, out List<Tuple<double,double,double,double,double,double>> hsvList)
 *      {
 *          return MeasureEx(img, bgImg, brightAreaThreshold, darkAreaThreshold,
 *              out color, out L, out a, out b, out C, out H, out mask_L,
 *              out mask_A, out error, out temp, out mask2_A, out hsvList,
 *              App.Settings.LConv, App.Settings.AConv, App.Settings.BConv,
 *              App.Settings.Lshift, App.Settings.Ashift, App.Settings.Bshift);
 *      }
 *
 *      public bool MeasureEx(List<System.Drawing.Bitmap> img, List<System.Drawing.Bitmap> bgImg,
 *          int brightAreaThreshold, int darkAreaThreshold, out string color, out double L, out double a, out double b,
 *          out double C, out double H, out double mask_L, out double mask_A, out string error,out double temp,
 *          out double mask2_A, out List<Tuple<double,double,double,double,double,double>> hsvList,
 *          double Lconv = 1.0, double Aconv = 1.0, double Bconv = 1.0,
 *          double Lshift = 0, double Ashift = 0, double Bshift = 0)
 *      {
 *          bool result = false;
 *          hsvList = new List<Tuple<double, double, double,double,double,double>>();
 *
 *          color = "";
 *          error = "";
 *          L = 0; a = 0; b = 0; C = 0; H = 0;
 *          mask_L = 0; mask_A = 0; mask2_A = 0;
 *          temp = 0;
 *
 *          try
 *          {
 *              if (img.Count != bgImg.Count)
 *              {
 *                  error = "background image count not equal to image count";
 *                  return false;
 *              }
 *
 *              ImageProcessing.setLabAdjustment(Lconv, Aconv, Bconv,
 *                      Lshift, Ashift, Bshift);
 *
 *
 *              //string unused = "";
 *              //int x = (int)(img.Width / 2.0);
 *              //int y = (int)(img.Height / 2.0);
 *              //if (!ImageProcessing.check_diamond_position(ref img, x, y, ref unused))
 *              //{
 *              //    error = "Check diamond position";
 *              //    return false;
 *              //}
 *
 *
 *              //var imageList = new List<System.Drawing.Bitmap>();
 *
 *              //for (int i = 0; i < img.Count; i++)
 *              //{
 *              //    BitmapSource mainImage, bgImage;
 *
 *              //    if (!GetMeasurementImages(imgSrc[i], out mainImage, out bgImage))
 *              //    {
 *              //        error = "Could not divide image";
 *              //        return false;
 *              //    }
 *
 *              //    imageList.Add(camera.GetBitmap(mainImage));
 *              //}
 *
 *
 *              string L_description = "", C_description = "", H_description = "", comment1 = "",
 *                  comment2 = "", comment3 = "";
 *
 *              bool colorResult = ImageProcessing.GetColor_description(ref img, ref bgImg,
 *                  ref L, ref a, ref b, ref C, ref H, ref L_description, ref C_description,
 *                  ref H_description, ref mask_L, ref mask_A, ref comment1, ref comment2, ref comment3,
 *                  ref mask2_A, ref hsvList, false,
 *                  App.Settings.MaxPhotoChromicLDiff, brightAreaThreshold, darkAreaThreshold);
 *
 *              temp = CameraTemperature();
 *
 *              if (colorResult)
 *              {
 *                  color = C_description;
 *                  result = true;
 *                  error = comment3;
 *              }
 *              else
 *              {
 *                  error = "Bad color result: " + comment3;
 *                  result = false;
 *              }
 *          }
 *          catch (Exception ex)
 *          {
 *              error = ex.ToString() ;
 *          }
 *
 *
 *          return result;
 *      }
 *
 *
 *
 */

        public double CameraTemperature(PtGreyCamera camera)
        {
            double temp = 0;

            if (camera != null)
            {
                // TODO: need to verify the value
                temp = Convert.ToDouble(camera.GetPropertyValue("DeviceTemperature"));
            }

            return(temp);
        }
Пример #3
0
        private void InitializeCameraSettings(PtGreyCamera camera)
        {
            //first reset to default settings
            camera.DefaultSettings();

            // hue, gamma, and saturation setting controled by pixel format RGB8 will enable those settings
            //TODO: spinnaker
            //camera.SetCameraVideoModeAndFrameRate(VideoMode.VideoMode800x600Rgb,
            //    FrameRate.FrameRate30);
            camera.SetAbsolutePropertyValue("PixelFormat", "RGB8");
            camera.SetAbsolutePropertyValue("VideoMode", "Continuous");
            int width  = Convert.ToInt32(camera.GetPropertyValue("WidthMax"));
            int height = Convert.ToInt32(camera.GetPropertyValue("HeightMax"));

            camera.SetAbsolutePropertyValue("Width", width.ToString());
            camera.SetAbsolutePropertyValue("Height", height.ToString());

            camera.SetProprtyAutomaticSetting("Shutter", true);

            camera.SetAbsolutePropertyValue("Gain", "0");

            camera.SetProprtyEnabledSetting("AcquisitionFrameRate", true);
            camera.SetAbsolutePropertyValue("FrameRate", App.Settings.FrameRate.ToString());

            camera.SetProprtyEnabledSetting("Saturation", true);
            camera.SetAbsolutePropertyValue("Saturation", App.Settings.Saturation.ToString());

            camera.SetProprtyEnabledSetting("Gamma", true);
            camera.SetAbsolutePropertyValue("Gamma", App.Settings.Gamma.ToString());

            camera.SetProprtyEnabledSetting("Hue", true);
            camera.SetAbsolutePropertyValue("Hue", App.Settings.Hue.ToString());

            camera.SetStreamBufferCount(1); // test only
            camera.SetAbsolutePropertyValue("StreamBufferMode", "NewestOnly");
        }