Exemple #1
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());
                    }
                }
            }
        }
        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());
            }
        }
Exemple #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());
                    }
                }
            }
        }
        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());
            }
        }