Exemplo n.º 1
0
        //Sector 类型
        public static SFRValue Sector_Info2Value(SFRInfo info)
        {
            if (info == null || info.block == null || info.block.Length == 0)
            {
                return(null);
            }
            int      nCnt   = 0;
            SFRValue result = new SFRValue();

            result.block = new BlockValue[info.block.Length];
            for (int i = 0; i < info.block.Length; i++)
            {
                result.block[i] = new BlockValue();
            }
            result.dZ = info.dZ;
            for (int i = 0; i < info.block.Length; i++)
            {
                // result.block[i].aryValue = new double[info.block[i].aryValue.Length];
                result.block[i].aryValue = info.block[i].aryValue;
                //  result.block[i].aryValue[1] = result.block[i].aryValue[2];
                // result.block[i].aryValue[3] = result.block[i].aryValue[4];

                result.block[i].dValue = info.block[i].dValue;
                result.block[i].dX     = info.block[i].dX;
                result.block[i].dY     = info.block[i].dY;
            }
            return(result);
        }
Exemplo n.º 2
0
        public override bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false)
        {
            SFRInfo info = new SFRInfo();
            //   Rectangle[] rectangles = new Rectangle[13];
            SFR_C_Info sFR_C_Info = new SFR_C_Info();
            SFR_C_Info YData      = new SFR_C_Info();
            double     frequency  = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dSFR_Parameter");
            bool       bRet       = false;

            try
            {
                if (bmp == null)
                {
                    return(false);
                }
                Bitmap temp     = (Bitmap)bmp.Clone();
                int    nWidth   = temp.Width;
                int    nHeight  = temp.Height;
                byte[] byBuffer = ImageChangeHelper.Instance.Rgb2Gray(bmp);
                unsafe
                {
                    fixed(byte *byBufferptr = byBuffer)
                    {
                        bRet = ActiveAlignment.CalibrationMode_Collimators(byBufferptr, nWidth, nHeight, ref sFR_C_Info, ref YData);
                    }
                }
                temp.Dispose();
                //sfr 转换
                SFRValue = AlgChangeHelper.Collimator_Info2Value(sFR_C_Info);
                rectInfo = AlgChangeHelper.Collimator_Info2Rect(sFR_C_Info);
            }
            catch { }
            double[] value = new double[5];
            try
            {
                value[0] = YData.block[0].dValue;
                value[1] = YData.block[1].dValue;
                value[2] = YData.block[2].dValue;
                value[3] = YData.block[3].dValue;
                value[4] = YData.block[4].dValue;
            }
            catch (Exception ex)
            {
                value[0] = -1;
                value[1] = -1;
                value[2] = -1;
                value[3] = -1;
                value[4] = -1;
                //return false;
            }
            lightValue.blockValue = value;

            return(bRet);
        }
Exemplo n.º 3
0
        public override bool GetTiltValue(SFRValue[] SFRValues, ref double dPeakZ, ref double dTx, ref double dTy)
        {
            TiltInfo tiltInfo = new TiltInfo();

            SFRInfo[] SFRInfo = new SFRInfo[SFRValues.Length];
            SFRInfo = AlgChangeHelper.Sector_Value2Infos(SFRValues);
            bool bRet = false;

            bRet   = ActiveAlignment.GetTiltValue(SFRInfo.Length, SFRInfo, ref tiltInfo);
            dPeakZ = tiltInfo.dPeakZ;
            dTx    = tiltInfo.dTx;
            dTy    = tiltInfo.dTy;
            return(bRet);
        }
Exemplo n.º 4
0
        public static SFRInfo Chart_Value2Info(SFRValue value)
        {
            SFRInfo result = new SFRInfo();

            result.dZ = value.dZ;
            for (int i = 0; i < value.block.Length; i++)
            {
                result.block[i].aryValue = value.block[i].aryValue;
                result.block[i].dValue   = value.block[i].dValue;
                result.block[i].dX       = value.block[i].dX;
                result.block[i].dY       = value.block[i].dY;
            }
            return(result);
        }
Exemplo n.º 5
0
 public static SFRInfo[] Sector_Value2Infos(SFRValue[] value)
 {
     SFRInfo[] result = new SFRInfo[value.Length];
     for (int i = 0; i < result.Length; i++)
     {
         result[i] = new SFRInfo();
     }
     for (int j = 0; j < value.Length; j++)
     {
         result[j].dZ = value[j].dZ;
         for (int i = 0; i < value[j].block.Length; i++)
         {
             result[j].block[i].aryValue = value[j].block[i].aryValue;
             result[j].block[i].dValue   = value[j].block[i].dValue;
             result[j].block[i].dX       = value[j].block[i].dX;
             result[j].block[i].dY       = value[j].block[i].dY;
         }
     }
     return(result);
 }
Exemplo n.º 6
0
        public override bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false)
        {
            SFRInfo    info       = new SFRInfo();
            ObjectInfo objectInfo = new ObjectInfo();

            //   Rectangle[] rectangles = new Rectangle[13];

            if (bmp == null)
            {
                return(false);
            }
            Bitmap temp    = (Bitmap)bmp.Clone();
            bool   bRet    = false;
            int    nWidth  = temp.Width;
            int    nHeight = temp.Height;

            byte[] byBuffer = ImageChangeHelper.Instance.Rgb2Gray(bmp);
            unsafe
            {
                fixed(byte *byBufferptr = byBuffer)
                {
                    bRet = ActiveAlignment.GetSFRValue_Sector(byBufferptr, nWidth, nHeight, ref info, ref objectInfo, rectangles);
                }
            }
            temp.Dispose();
            //sfr 转换
            if (TestLight)
            {
                double[] value = new double[5];
                HObject  ho_Image = null, ho_GrayImage = null;
                try
                {
                    HObject ho_SelectedRegions0 = null;
                    HObject ho_SelectedRegions1 = null;
                    HObject ho_SelectedRegions2 = null;
                    HObject ho_SelectedRegions3 = null;
                    HObject ho_SelectedRegions4 = null;
                    HTuple  hv_XField = null, hv_YField = null;
                    HTuple  hv_CenterROIR = null, hv_CenterROIC = null, hv_CenterMinArea = null, hv_CenterSFRThreshold = null, hv_CenterClosing = null;
                    HTuple  hv_Corner1ROIR = null, hv_Corner1ROIC = null, hv_Corner1MinArea = null, hv_Corner1SFRThreshold = null, hv_Corner1Closing = null;
                    HTuple  CenterMean = null, CenterDeviation = null;
                    HTuple  Corner1Mean = null, Corner1Deviation = null;
                    HTuple  Corner2Mean = null, Corner2Deviation = null;
                    HTuple  Corner3Mean = null, Corner3Deviation = null;
                    HTuple  Corner4Mean = null, Corner4Deviation = null;
                    hv_CenterROIR          = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIW");
                    hv_CenterROIC          = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCenterROIH");
                    hv_CenterMinArea       = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心最小面积");
                    hv_CenterSFRThreshold  = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心阈值设置");
                    hv_CenterClosing       = ParamSetMgr.GetInstance().GetDoubleParam("MF中心对心膨胀系数");
                    hv_XField              = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1XField");
                    hv_YField              = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dCorner1YField");
                    hv_Corner1ROIR         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIW");
                    hv_Corner1ROIC         = ParamSetMgr.GetInstance().GetIntParam("[SFR] nCorner1ROIH");
                    hv_Corner1MinArea      = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1最小面积");
                    hv_Corner1SFRThreshold = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1阈值设置");
                    hv_Corner1Closing      = ParamSetMgr.GetInstance().GetDoubleParam("MF_Corner1膨胀系数");
                    ImageChangeHelper.Instance.Bitmap2HObject((Bitmap)bmp.Clone(), ref ho_Image);
                    FindCenterRegions(ho_Image, hv_CenterROIR, hv_CenterROIC, 0, 0, hv_CenterMinArea, hv_CenterSFRThreshold, hv_CenterClosing, ref ho_SelectedRegions0);
                    FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions1);
                    FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, -hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions2);
                    FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, -hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions3);
                    FindCenterRegions(ho_Image, hv_Corner1ROIR, hv_Corner1ROIC, hv_XField, hv_YField, hv_Corner1MinArea, hv_Corner1SFRThreshold, hv_Corner1Closing, ref ho_SelectedRegions4);
                    HOperatorSet.Intensity(ho_SelectedRegions0, ho_Image, out CenterMean, out CenterDeviation);
                    HOperatorSet.Intensity(ho_SelectedRegions1, ho_Image, out Corner1Mean, out Corner1Deviation);
                    HOperatorSet.Intensity(ho_SelectedRegions2, ho_Image, out Corner2Mean, out Corner2Deviation);
                    HOperatorSet.Intensity(ho_SelectedRegions3, ho_Image, out Corner3Mean, out Corner3Deviation);
                    HOperatorSet.Intensity(ho_SelectedRegions4, ho_Image, out Corner4Mean, out Corner4Deviation);

                    value[0] = CenterMean.D;
                    value[1] = Corner1Mean.D;
                    value[2] = Corner2Mean.D;
                    value[3] = Corner3Mean.D;
                    value[4] = Corner4Mean.D;
                }
                catch (Exception ex)
                {
                    value[0] = -1;
                    value[1] = -1;
                    value[2] = -1;
                    value[3] = -1;
                    value[4] = -1;
                    //return false;
                }
                lightValue.blockValue = value;
            }
            SFRValue = AlgChangeHelper.Sector_Info2Value(info);
            rectInfo = AlgChangeHelper.Sector_Info2Value(objectInfo);
            return(bRet);
        }