コード例 #1
0
        public void TestDebug()
        {
            MainHelper testClass = null;
            var        one       = new MonitorLocation();

            one.X      = 1247;
            one.Y      = 311;
            one.Width  = 50;
            one.Height = 18;
            one.Name   = "买一";

            var two = new MonitorLocation();

            two.X      = 1139;
            two.Y      = 88;
            two.Height = 23;
            two.Width  = 79;
            two.Name   = "股票名称";

            System.Collections.Generic.List <MonitorLocation> list = new System.Collections.Generic.List <MonitorLocation>();
            list.Add(one);
            list.Add(two);

            testClass = new MainHelper(Newtonsoft.Json.JsonConvert.SerializeObject(list).ToString(), false);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            var bmp = testClass.Screenshot();

            sw.Stop();
            Console.WriteLine("截图花费:" + sw.ElapsedMilliseconds.ToString());
            sw.Reset();
            sw.Start();
            Parallel.Invoke(() => testClass.CatImage((Bitmap)bmp.Clone(), 0), () => testClass.CatImage((Bitmap)bmp.Clone(), 1));
            //testClass.CatImage(bmp, 0);
            //testClass.CatImage(bmp, 1);
            sw.Stop();
            Console.WriteLine("并行切图花费:" + sw.ElapsedMilliseconds.ToString());
        }
コード例 #2
0
ファイル: CoreAnalysis.cs プロジェクト: ezwyj/StockMonitor
        /// <summary>
        /// 初始化函数
        /// </summary>
        public CoreAnalysis()
        {
            OcrEngine    = new List <TesseractEngine>(3);
            OcrEngine2   = new List <Baidu.Aip.Ocr.Ocr>(3);
            _monitorList = new List <MonitorLocation>();

            var te0 = new TesseractEngine("./tessdata", "eng", EngineMode.CubeOnly);

            te0.SetVariable("tessedit_char_whitelist", "0123456789");
            OcrEngine.Add(te0);

            var te1 = new TesseractEngine("./tessdata", "eng", EngineMode.TesseractOnly);

            te1.SetVariable("tessedit_char_whitelist", "0123456789");
            OcrEngine.Add(te1);

            var te2 = new TesseractEngine("./tessdata", "eng", EngineMode.CubeOnly);

            te2.SetVariable("tessedit_char_whitelist", "0123456789");
            OcrEngine.Add(te2);

            var client0 = new Baidu.Aip.Ocr.Ocr(BaiduHelper.API_KEY, BaiduHelper.SECRET_KEY);

            OcrEngine2.Add(client0);
            var client1 = new Baidu.Aip.Ocr.Ocr(BaiduHelper.API_KEY2, BaiduHelper.SECRET_KEY2);

            OcrEngine2.Add(client1);
            var client2 = new Baidu.Aip.Ocr.Ocr(BaiduHelper.API_KEY, BaiduHelper.SECRET_KEY);

            OcrEngine2.Add(client2);

            var one = new MonitorLocation();

            one.Width  = 40;
            one.Height = 20;
            one.Name   = "买一价";
            _monitorList.Add(one);
            var two = new MonitorLocation();

            two.Width  = 40;
            two.Height = 20;
            two.Name   = "买一量";
            _monitorList.Add(two);
            var three = new MonitorLocation();

            three.Width  = 30;
            three.Height = 20;
            three.Name   = "买一笔";
            _monitorList.Add(three);
            var four = new MonitorLocation();

            four.Width  = 40;
            four.Height = 20;
            four.Name   = "买一价";
            _monitorList.Add(four);
            var five = new MonitorLocation();

            five.Width  = 40;
            five.Height = 20;
            five.Name   = "买一量";
            _monitorList.Add(five);
            var six = new MonitorLocation();

            six.Width  = 30;
            six.Height = 20;
            six.Name   = "买一笔";
            _monitorList.Add(six);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(System.IO.File.ReadAllText(Application.StartupPath + @"\stocklist.json", System.Text.Encoding.Default));
            MarketList = Newtonsoft.Json.JsonConvert.DeserializeObject <Market>(sb.ToString());
        }