/// <summary>
 /// 拍摄一张图片
 /// </summary>
 /// <returns></returns>
 public bool GrabImage(int medianRadius)
 {
     try
     {
         if (Connected)
         {
             //CurrentImage?.Dispose();
             var image = EnhancedImage(Framegrabber.GrabImage());
             if (medianRadius > 0)
             {
                 HObject medianedImage;
                 HOperatorSet.MedianImage(image, out medianedImage, "circle", medianRadius, "mirrored");
                 CurrentImage = new HImage(medianedImage);
             }
             else
             {
                 CurrentImage = image;
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         Connected = false;
         return(false);
     }
 }
 /// <summary>
 /// 关闭当前相机
 /// </summary>
 /// <returns></returns>
 public bool CloseCamera()
 {
     try
     {
         Framegrabber.Dispose();
         return(true);
     }
     catch { return(false); }
 }
Beispiel #3
0
 public bool GrabeImageAsync()
 {
     try
     {
         CurrentImage = Framegrabber.GrabImageAsync(-1);
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
Beispiel #4
0
 /// <summary>
 /// 拍摄一张图片
 /// </summary>
 /// <returns></returns>
 public bool GrabImage(int medianRadius, bool isEnhance, bool isMirror)
 {
     try
     {
         if (Connected)
         {
             //CurrentImage?.Dispose();
             HImage image = isEnhance ? EnhancedImage(Framegrabber.GrabImage()) : Framegrabber.GrabImage();
             if (medianRadius > 0)
             {
                 HObject medianedImage;
                 HOperatorSet.MedianImage(image, out medianedImage, "circle", medianRadius, "mirrored");
                 image.Dispose();
                 if (isMirror)
                 {
                     HObject imageMirror;
                     HOperatorSet.MirrorImage(medianedImage, out imageMirror, "column");
                     CurrentImage = new HImage(imageMirror);
                 }
                 else
                 {
                     CurrentImage = new HImage(medianedImage);
                 }
             }
             else
             {
                 if (isMirror)
                 {
                     HObject imageMirror;
                     HOperatorSet.MirrorImage(image, out imageMirror, "column");
                     image.Dispose();
                     CurrentImage = new HImage(imageMirror);
                 }
                 else
                 {
                     CurrentImage = image;
                 }
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         Connected = false;
         return(false);
     }
 }
Beispiel #5
0
 public void GrabImageVoid()
 {
     try
     {
         if (Connected)
         {
             CurrentImage?.Dispose();
             CurrentImage = Framegrabber.GrabImage();
         }
     }
     catch
     {
         Connected = false;
     }
 }
        /// <summary>
        /// 设置曝光时间
        /// </summary>
        /// <param name="exposeValue"></param>
        /// <returns></returns>
        public bool SetExpose(double exposeValue)
        {
            try
            {
                Framegrabber.SetFramegrabberParam("ExposureTimeAbs", exposeValue);
                return(true);
            }
            catch {  }
            try
            {
                Framegrabber.SetFramegrabberParam("ExposureTime", exposeValue);
                return(true);
            }
            catch { }

            return(false);
        }
 public void GrabImageVoid(int medianRadius, bool isMirror)
 {
     try
     {
         {
             //CurrentImage?.Dispose();
             HImage image = EnhancedImage(Framegrabber.GrabImage());
             if (medianRadius > 0)
             {
                 HObject medianedImage;
                 HOperatorSet.MedianImage(image, out medianedImage, "circle", medianRadius, "mirrored");
                 image.Dispose();
                 if (isMirror)
                 {
                     HObject imageMirror;
                     HOperatorSet.MirrorImage(medianedImage, out imageMirror, "column");
                     medianedImage.Dispose();
                     CurrentImage = new HImage(imageMirror);
                 }
                 else
                 {
                     CurrentImage = new HImage(medianedImage);
                 }
             }
             else
             {
                 if (isMirror)
                 {
                     HObject imageMirror;
                     HOperatorSet.MirrorImage(image, out imageMirror, "column");
                     image.Dispose();
                     CurrentImage = new HImage(imageMirror);
                 }
                 else
                 {
                     CurrentImage = image;
                 }
             }
         }
     }
     catch
     {
         Connected = false;
     }
 }
Beispiel #8
0
 public bool SetRotaryEncoderDirection(bool dir)
 {
     try
     {
         if (dir)
         {
             Framegrabber.SetFramegrabberParam("rotaryEncoderDirection", "CounterClockwise");
         }
         else
         {
             Framegrabber.SetFramegrabberParam("rotaryEncoderDirection", "Clockwise");
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #9
0
 /// <summary>
 /// 拍摄一张图片
 /// </summary>
 /// <returns></returns>
 public bool GrabImage()
 {
     try
     {
         if (Connected)
         {
             CurrentImage?.Dispose();
             CurrentImage = Framegrabber.GrabImage();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         Connected = false;
         return(false);
     }
 }
Beispiel #10
0
 public void GrabImageVoid(int medianRadius)
 {
     try
     {
         {
             //CurrentImage?.Dispose();
             var image = Framegrabber.GrabImage();
             if (medianRadius > 0)
             {
                 HObject medianedImage;
                 HOperatorSet.MedianImage(image, out medianedImage, "circle", medianRadius, "mirrored");
                 CurrentImage = new HImage(medianedImage);
             }
             else
             {
                 CurrentImage = image;
             }
         }
     }
     catch
     {
         Connected = false;
     }
 }
Beispiel #11
0
 public void GrabeImageStart()
 {
     Framegrabber.GrabImageStart(-1);
 }