Esempio n. 1
0
 public BaslerCamera(IVisionCameraInfo info) : base(info)
 {
     this.UserID = Info.UserID;
     Image       = new HImage();
     timer       = new HiPerfTimer();
     try
     {
         Image = new HImage();
         // 枚举相机列表,获取固定相机名称
         List <ICameraInfo> allCameraInfos = CameraFinder.Enumerate();
         foreach (ICameraInfo cameraInfo in allCameraInfos)
         {
             if (this.UserID == cameraInfo[CameraInfoKey.UserDefinedName])
             {
                 camera         = new Camera(cameraInfo);
                 Info.CameraIP  = cameraInfo[CameraInfoKey.DeviceIpAddress].ToString();
                 info.CameraMac = cameraInfo[CameraInfoKey.DeviceMacAddress].ToString();
             }
         }
         if (camera == null)
         {
             WriteErrorLog("It can not recognite the camera of  " + UserID);
         }
     }
     catch (Exception e)
     {
         WriteErrorLog(e.ToString());
     }
 }
Esempio n. 2
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int iRow = e.RowIndex;

            if (iRow >= 0)
            {
                if (dataGridView1.Rows[iRow].Cells[0].Value != null && dataGridView1.Rows[iRow].Cells[1].Value != null)
                {
                    string camName = dataGridView1.Rows[iRow].Cells[0].Value.ToString();
                    formSetting = CreatingHelper <CameraSetting> .GetSingleObject();

                    IVisionCameraInfo info = CameraManger.GetCameraInfoInstance(camName);
                    if (info != null)
                    {
                        formSetting.Info          = info;
                        formSetting.StartPosition = FormStartPosition.CenterScreen;
                        if (formSetting.IsShowing)
                        {
                            formSetting.IsShowing = false;
                            formSetting.Close();
                            System.Threading.Thread.Sleep(10);
                            formSetting.Show();
                            formSetting.IsShowing = true;
                        }
                        else
                        {
                            formSetting.Show();
                            formSetting.IsShowing = true;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public static bool AddCameraInfo(string cameraName, string camType)
        {
            if (doc != null)
            {
                if (!doc.CamerasInfoDic.ContainsKey(cameraName))
                {
                    IVisionCameraInfo info = CreatingHelper <IVisionCameraInfo> .CreateInstance(@".//CamerasDll/" + "Vision" + camType + ".dll", "Vision" + camType, camType + "Info");

                    info.UserID = cameraName;
                    doc.CamerasInfoList.Add(info);
                    doc.CamerasInfoDic.Add(info.UserID, info);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 4
0
 public HikCamera(IVisionCameraInfo info) : base(info)
 {
     try
     {
         Image                   = new HImage();
         camera                  = new MyCamera();
         ImageCallback           = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
         CameraReconnectCallback = new MyCamera.cbExceptiondelegate(ReconnectCallbackFunc);
         if (camera == null)
         {
             WriteErrorLog("It can not recognite the camera of  " + UserID);
         }
     }
     catch (Exception e)
     {
         WriteErrorLog(e.ToString());
     }
 }
Esempio n. 5
0
        public static void InitCamera()
        {
            LoadDoc();
            try
            {
                Cameras = new Dictionary <string, CameraBase>();
                if (doc == null)
                {
                    return;
                }
                if (doc.CamerasInfoList.Count != 0)
                {
                    foreach (var info in doc.CamerasInfoList)
                    {
                        object[] paras  = new object[] { info };
                        var      camera = CreatingHelper <CameraBase> .CreateInstance(@".//CamerasDll/" + "Vision" + info._CameraType + "Camera" + ".dll", "Vision" + info._CameraType + "Camera", info._CameraType.ToString() + "Camera", paras);

                        if (camera != null)
                        {
                            Cameras.Add(camera.UserID, camera);
                        }
                    }
                }
                else
                {
                    #region 枚举巴斯勒相机
                    List <string> baslerCams = CameraGeneral.GetBaslerCameraListInfo();
                    if (baslerCams.Count > 0)
                    {
                        foreach (var cam in baslerCams)
                        {
                            AddCameraInfo(cam, "Basler");
                            IVisionCameraInfo info  = GetCameraInfoInstance(cam);
                            object[]          paras = new object[] { info };
                            var camera = CreatingHelper <CameraBase> .CreateInstance(@".//CamerasDll/" + "Vision" + info._CameraType + "Camera" + ".dll", "Vision" + info._CameraType + "Camera", info._CameraType.ToString() + "Camera", paras);

                            if (camera != null)
                            {
                                Cameras.Add(camera.UserID, camera);
                            }
                        }
                    }
                    #endregion

                    #region 枚举海康相机
                    List <string> hikCams = CameraGeneral.GetHikCameraListInfo();
                    if (hikCams.Count > 0)
                    {
                        foreach (var cam in hikCams)
                        {
                            AddCameraInfo(cam, "Hik");
                            IVisionCameraInfo info  = GetCameraInfoInstance(cam);
                            object[]          paras = new object[] { info };
                            var camera = CreatingHelper <CameraBase> .CreateInstance(@".//CamerasDll/" + "Vision" + info._CameraType + "Camera" + ".dll", "Vision" + info._CameraType + "Camera", info._CameraType.ToString() + "Camera", paras);

                            if (camera != null)
                            {
                                Cameras.Add(camera.UserID, camera);
                            }
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                MessageHelper.ShowError(ex.ToString());
            }
            SaveDoc();
        }
Esempio n. 6
0
 public CameraBase(IVisionCameraInfo info)
 {
     Info = info;
 }