Exemplo n.º 1
0
        private void Button_Click_Get_Cam_Image(object sender, RoutedEventArgs e)
        {
#if DEBUG
            mEvt_CamCtrl.Set();
            for (int i = 0; i < 4; i++)
            {
                mEvt_Cam[i].Set();
            }
            return;
#endif
            try
            {
                Obj[global.GetIns().CamSel].Dispose();
                GrabImage.Grab(out Obj[global.GetIns().CamSel], global.GetIns().CamSel);
                CameraADisp.RunHalcon(this.CamSetting.HalconID, Obj[global.GetIns().CamSel]);
            }
            catch (HalconException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (Exception _ex)
            {
                Console.WriteLine(_ex.ToString());
            }
        }
Exemplo n.º 2
0
        void CameraDDeal()
        {
            int idx = 3;

            //  HObject Obj;
            //  HOperatorSet.GenEmptyObj(out Obj);

            while (true)
            {
                mEvt_Cam[idx].WaitOne();
                try
                {
                    Obj[idx].Dispose();
                    GrabImage.Grab(out Obj[idx], idx);
                    global.GetIns().res[idx]      = "T4," + ImageOperate.Check_gear(Obj[idx], this.Cam4_Disp.HalconID, INI.gear_roi.imgthreshold, INI.gear_roi.threshold, ImageOperate.Gear_Model) + ",";
                    global.GetIns().GotImage[idx] = 1;
                }
                catch (HalconException ex)
                {
                    try
                    {
                        HOperatorSet.ReadImage(out Obj[idx], @"D:\img\4.bmp");
                        global.GetIns().GotImage[idx] = 1;
                    }
                    catch (HalconException exe)
                    {
                        global.GetIns().res[idx]      = "T4," + "22,";
                        global.GetIns().GotImage[idx] = 0;
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
        }
Exemplo n.º 3
0
        void CameraCDeal()
        {
            int idx = 2;

            // HObject Obj;
            // HOperatorSet.GenEmptyObj(out Obj);

            while (true)
            {
                mEvt_Cam[idx].WaitOne();


                try
                {
                    Obj[idx].Dispose();
                    GrabImage.Grab(out Obj[idx], idx);
                    global.GetIns().GotImage[idx] = 1;
                }
                catch (HalconException ex)
                {
                    try
                    {
                        HOperatorSet.ReadImage(out Obj[idx], @"D:\img\3.bmp");
                        global.GetIns().GotImage[idx] = 1;
                    }
                    catch (HalconException exe)
                    {
                        global.GetIns().res[idx]      = "T3," + "22,";
                        global.GetIns().GotImage[idx] = 0;
                        Console.WriteLine(exe.ToString());
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                for (int i = 0; i < 4; i++)
                {
                    try
                    {
                        Obj[i].Dispose();
                        GrabImage.Grab(out Obj[i], global.GetIns().CamSel);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        continue;
                    }
                }
            }
            catch (HalconException HDevExpDefaultException)
            {
                HOperatorSet.ReadImage(out Obj[0], @"D:\img\1.bmp");
                CameraADisp.RunHalcon(this.Cam1_Disp.HalconID, Obj[0]);
                HOperatorSet.ReadImage(out Obj[1], @"D:\img\2.bmp");
                CameraADisp.RunHalcon(this.Cam2_Disp.HalconID, Obj[1]);
                HOperatorSet.ReadImage(out Obj[2], @"D:\img\3.bmp");
                CameraADisp.RunHalcon(this.Cam3_Disp.HalconID, Obj[2]);
                HOperatorSet.ReadImage(out Obj[3], @"D:\img\4.bmp");
                CameraADisp.RunHalcon(this.Cam4_Disp.HalconID, Obj[3]);
                HTuple hv_exception = null;
                HDevExpDefaultException.ToHTuple(out hv_exception);
            }

            try
            {
                CameraADisp.check_axis(Obj[0], 0, ImageOperate.Track_Model, Cam1_Disp.HalconID);
                CameraBDisp.check_axis(Obj[1], 0, ImageOperate.Track_Model, Cam2_Disp.HalconID);
                CameraCDisp.check_axis(Obj[2], 0, ImageOperate.Track_Model, Cam3_Disp.HalconID);
                CameraDDisp.check_axis(Obj[3], 0, ImageOperate.Track_Model, Cam4_Disp.HalconID);
            }
            catch (HalconException HDevExpDefaultException)
            {
                Console.WriteLine(HDevExpDefaultException.ToString());
            }
        }
Exemplo n.º 5
0
        void HardwareInit()
        {
            string error_init = "";

            /*
             * try
             * {
             *  CameraA.InitHalcon(camera_name[0]);
             * }
             * catch (HalconException HDevExpDefaultException)
             * {
             *  HTuple hv_exception = null;
             *  HDevExpDefaultException.ToHTuple(out hv_exception);
             #if DEBUG
             *  Console.WriteLine("初始化相机一失败");
             #else
             *  error_init += " 初始化相机一失败";
             *
             #endif
             * }
             *
             * try
             * {
             *  CameraB.InitHalcon(camera_name[1]);
             * }
             * catch (HalconException HDevExpDefaultException)
             * {
             *  HTuple hv_exception = null;
             *  HDevExpDefaultException.ToHTuple(out hv_exception);
             #if DEBUG
             *  Console.WriteLine("初始化相机二失败");
             #else
             *  error_init += " 初始化相机二失败";
             #endif
             * }
             * try
             * {
             *  CameraC.InitHalcon(camera_name[2]);
             * }
             * catch (HalconException HDevExpDefaultException)
             * {
             *  HTuple hv_exception = null;
             *  HDevExpDefaultException.ToHTuple(out hv_exception);
             #if DEBUG
             *  Console.WriteLine("初始化相机三失败");
             #else
             *  error_init += " 初始化相机三失败";
             #endif
             * }
             * try
             * {
             *  CameraD.InitHalcon(camera_name[3]);
             * }
             * catch (HalconException HDevExpDefaultException)
             * {
             *  HTuple hv_exception = null;
             *  HDevExpDefaultException.ToHTuple(out hv_exception);
             #if DEBUG
             *  Console.WriteLine("初始化相机四失败");
             #else
             *  error_init += " 初始化相机四失败";
             #endif
             * }
             *
             *
             *
             *
             *
             * if (error_init.Length > 0)
             * {
             * //    MessageBox.Show(error_init);
             *  history.HistoryNotify += error_init + "\r\n";
             * }
             * else {
             *  history.HistoryNotify += "相机初始化成功!\r\n";
             * }
             *
             */
            string cnames = "";

            history.HistoryNotify += GrabImage.InitCamera(out cnames).ToString() + "个相机被找到!\r\n";
            if ("" != cnames)
            {
                history.HistoryNotify += cnames + "\r\n";
            }
        }