コード例 #1
0
        /// <summary>
        /// 从图片中获得DecodeString
        /// </summary>
        /// <param name="imagePath"></param>
        /// <returns></returns>
        public bool GetDecodeStrbyPath(string imagePath, int DeviceID)
        {
            try
            {
                if ((imagePath.Length == 0) || (!File.Exists(imagePath)))
                {
                    return(false);
                }
                EMatrixCodeReader EMatrixCodeReader1 = new EMatrixCodeReader(); // EMatrixCodeReader instance
                EMatrixCodeReader1.TimeOut = 3000000;

                EMatrixCode EMatrixCodeReader1Result = null; // EMatrixCode
                EImageBW8   EBW8Image1 = new EImageBW8();    // EImageBW8 instance
                EBW8Image1.Load(imagePath);
                EMatrixCodeReader1Result = EMatrixCodeReader1.Read(EBW8Image1);
                //GlobalVar.gl_str_decode[DeviceID] = EMatrixCodeReader1Result.DecodedString;
                return(true);
            }
            catch
            {
                return(false);

                throw;
            }
        }
コード例 #2
0
 private void initEvision()
 {
     try
     {
         MatrixDecode      decoder = new MatrixDecode();
         EMatrixCode       EMatrixCodeReaderResult = new EMatrixCode();
         EMatrixCodeReader EMatrixCodeReader1      = new EMatrixCodeReader();
         EMatcher          match    = new EMatcher();
         Bitmap            bmp      = new Bitmap(640, 480);
         EImageBW8         bw8image = ConvertBitmapToEImageBW8(bmp);
     }
     catch { }
     finally
     {
         this.DialogResult = DialogResult.OK;
         //startMain.Set();
     }
 }
コード例 #3
0
ファイル: MatrixDecode.cs プロジェクト: wwkkww1983/SQLQuery
 /// <summary>
 /// 从图片中获得DecodeString
 /// </summary>
 /// <param name="imagePath"></param>
 /// <returns></returns>
 public string GetDecodeStrbyPath(string imagePath)
 {
     try
     {
         //return "1234567890"; //fortest
         if ((imagePath.Length == 0) || (!File.Exists(imagePath)))
         {
             return("");
         }
         EMatrixCodeReader EMatrixCodeReader1       = new EMatrixCodeReader(); // EMatrixCodeReader instance
         EMatrixCode       EMatrixCodeReader1Result = null;                    // EMatrixCode
         EImageBW8         EBW8Image1 = new EImageBW8();                       // EImageBW8 instance
         EBW8Image1.Load(imagePath);
         EMatrixCodeReader1.TimeOut = GlobalVar.gl_decode_timeout;
         //EMatrixCodeReader1Result = EMatrixCodeReader1.Read(EBW8Image1);
         ////Global.GlobalVar.gl_str_decode[DeviceID] = EMatrixCodeReader1Result.DecodedString;
         //return EMatrixCodeReader1Result.DecodedString;
         return(GetDecodeStrbyEImageBW8(EBW8Image1)); //ltt
     }
     catch
     {
         return("");
     }
 }
コード例 #4
0
        /// <summary>
        /// 从EImageBW8中获得DecodeString
        /// </summary>
        /// <param name="EImageBW8"></param>
        /// <param name="Redecode">是否需要重复解析</param>
        /// <returns></returns>
        public string GetDecodeStrbyEImageBW8(EImageBW8 EBW8Image1)
        {
            EImageBW8 image_bak = new EImageBW8(EBW8Image1);

            for (int i = 0; i < 4; i++)
            {
                EMatrixCodeReader EMatrixCodeReader1       = new EMatrixCodeReader(); // EMatrixCodeReader instance
                EMatrixCode       EMatrixCodeReader1Result = null;                    // EMatrixCode instance
                try
                {
                    EMatrixCodeReader1.TimeOut = GlobalVar.gl_decode_timeout;
                    #region 对图片进行其他处理 ----没有经过验证,无用

                    //定义数组保存位图
                    //int bytes = Math.Abs(bmpdata_src.Stride) * bmp.Height;
                    //byte[] rgbvalues = new byte[bytes];
                    ////复制RGB值到数组
                    //System.Runtime.InteropServices.Marshal.Copy(pScan0, rgbvalues, 0, bytes);
                    //将每个像素的第三个值设为255. A 24bpp的位图将变红
                    //for (int counter = 2; counter < rgbvalues.Length; counter += 3)
                    //{
                    //    rgbvalues[counter] = 255;
                    //}
                    //把RGB值拷回位图
                    //System.Runtime.InteropServices.Marshal.Copy(rgbvalues, 0, ptr, bytes);
                    //解锁
                    //bmp.UnlockBits(bmpdata_src);
                    //绘制更新了的位图
                    //DrawImage(bmp, 0, 150);

                    #endregion

                    EMatrixCodeReader1Result = EMatrixCodeReader1.Read(image_bak);
                    return(EMatrixCodeReader1Result.DecodedString);
                }
                catch
                {
                    switch (i)
                    {
                    case 0:
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.643"), float.Parse("-69.0"));
                        break;

                    case 1:
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.643"), float.Parse("-29.0"));
                        break;

                    case 2:
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("1.143"), float.Parse("-69.0"));
                        break;

                    case 3:
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("1.243"), float.Parse("0.0"));
                        break;

                    case 4:
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("1.30"), float.Parse("0.0"));
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.0"), float.Parse("48.0"));
                        break;

                    case 5:
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.643"), float.Parse("0.0"));
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.0"), float.Parse("118.0"));
                        break;

                    case 6:
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.443"), float.Parse("0.0"));
                        image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.0"), float.Parse("129.0"));
                        break;
                    }
                }
            }
            return("");
        }
コード例 #5
0
ファイル: MatrixDecode.cs プロジェクト: wwkkww1983/SQLQuery
        /// <summary>
        /// 从EImageBW8中获得DecodeString
        /// </summary>
        /// <param name="EImageBW8"></param>
        /// <param name="Redecode">是否需要重复解析</param>
        /// <returns></returns>
        public string GetDecodeStrbyEImageBW8(EImageBW8 EBW8Image1)
        {
            EImageBW8 image_bak = new EImageBW8(EBW8Image1);

            try
            {
                //return "1234567890"; //fortest
                float center_x = image_bak.Width / 2;
                float center_y = image_bak.Height / 2;
                for (int i = 0; i <= GlobalVar.gl_decode_times; i++)
                {
                    if (GlobalVar.gl_inEmergence)
                    {
                        return("");
                    }
                    EMatrixCodeReader EMatrixCodeReader1       = new EMatrixCodeReader(); // EMatrixCodeReader instance
                    EMatrixCode       EMatrixCodeReader1Result = null;                    // EMatrixCode instance
                    try
                    {
                        EMatrixCodeReader1.TimeOut = GlobalVar.gl_decode_timeout;
                        #region 对图片进行其他处理 ----没有经过验证,无用

                        //定义数组保存位图
                        //int bytes = Math.Abs(bmpdata_src.Stride) * bmp.Height;
                        //byte[] rgbvalues = new byte[bytes];
                        ////复制RGB值到数组
                        //System.Runtime.InteropServices.Marshal.Copy(pScan0, rgbvalues, 0, bytes);
                        //将每个像素的第三个值设为255. A 24bpp的位图将变红
                        //for (int counter = 2; counter < rgbvalues.Length; counter += 3)
                        //{
                        //    rgbvalues[counter] = 255;
                        //}
                        //把RGB值拷回位图
                        //System.Runtime.InteropServices.Marshal.Copy(rgbvalues, 0, ptr, bytes);
                        //解锁
                        //bmp.UnlockBits(bmpdata_src);
                        //绘制更新了的位图
                        //DrawImage(bmp, 0, 150);

                        #endregion

                        EMatrixCodeReader1Result = EMatrixCodeReader1.Read(image_bak);
                        return(EMatrixCodeReader1Result.DecodedString);
                    }
                    catch
                    {
                        switch (i)
                        {
                        case 0:
                            //EasyImage.ScaleRotate(image_bak, center_x, center_y, center_x, center_y, 1.23f, 1.23f, 20f, image_bak);
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.643"), float.Parse("-69.0"));
                            break;

                        case 1:
                            EasyImage.ScaleRotate(image_bak, center_x, center_y, center_x, center_y, 1.23f, 1.23f, 90f, image_bak);
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.643"), float.Parse("-29.0"));
                            break;

                        case 2:
                            //EasyImage.ScaleRotate(image_bak, center_x, center_y, center_x, center_y, 1.23f, 1.23f, 40f, image_bak);
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("1.243"), float.Parse("-89.0"));
                            break;

                        case 3:
                            //EasyImage.ScaleRotate(image_bak, center_x, center_y, center_x, center_y, 1.23f, 1.23f, 50f, image_bak);
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("1.243"), float.Parse("0.0"));
                            break;

                        case 4:
                            //EasyImage.ScaleRotate(image_bak, center_x, center_y, center_x, center_y, 1.23f, 1.23f, 180f, image_bak);
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("1.30"), float.Parse("0.0"));
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.0"), float.Parse("48.0"));
                            break;

                        case 5:
                            EasyImage.ScaleRotate(image_bak, center_x, center_y, center_x, center_y, 1.23f, 1.23f, 70f, image_bak);
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.643"), float.Parse("0.0"));
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.0"), float.Parse("118.0"));
                            break;

                        case 6:
                            EasyImage.ScaleRotate(image_bak, center_x, center_y, center_x, center_y, 1.23f, 1.23f, 80f, image_bak);
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.443"), float.Parse("0.0"));
                            image_bak = EImageBW8GainOff(EBW8Image1, float.Parse("0.0"), float.Parse("129.0"));
                            break;
                        }
                    }
                }
                return("");
            }
            catch
            {
                return("");
            }
            finally
            {
                EBW8Image1 = null;
                image_bak  = null;
                GC.Collect();
            }
        }