private void DoSearch() { var files = Directory.GetFiles(Path.Combine(Application.StartupPath, "temp")); foreach (string file in files) { Bitmap map = GetPart(file, 0, 0, 1080, (int)(1920 * (5.5 - 3) / 16.5), 0, (int)(1920 * 3 / 16.5)); FileInfo info = new FileInfo(file); string fileName = Path.Combine(Application.StartupPath, "temp", "test", info.Name); map.Save(fileName); if (File.Exists(fileName)) { var searchContent = OcrHelper.GetOcrText(Application.StartupPath, fileName); searchContent = RemoveSpecialChar(searchContent); if (!string.IsNullOrEmpty(searchContent)) { Search(searchContent); } //File.Delete(fileName); } Thread.Sleep(1000); } }
private void btnSearch_Click(object sender, EventArgs e) { DateTime start = DateTime.Now; GetScreen(); Bitmap map = GetPart(tempFileName, 0, 0, 1080, (int)(1920 * (5.5 - 3) / 16.5), 0, (int)(1920 * 3 / 16.5)); string fileName = Path.Combine(Application.StartupPath, "temp", "test", Guid.NewGuid() + ".png"); map.Save(fileName); if (File.Exists(fileName)) { var searchContent = OcrHelper.GetOcrText(Application.StartupPath, fileName); searchContent = RemoveSpecialChar(searchContent); if (!string.IsNullOrEmpty(searchContent)) { Search(searchContent); } //File.Delete(fileName); } DateTime end = DateTime.Now; TimeSpan span = end - start; Console.WriteLine("this cost time {0} ms", span.TotalMilliseconds); }
private void DoSearch(float endTitleY) { SaveAndroidScreenToDisk(); float picWidthCm = 9.3f; float picHeightCm = 16.5f; float startTitleYCm = 3f; float startTitleXCm = 0.5f; int picWidthPix = 1080; int picHeightPix = 1920; Bitmap map = CreatPicturePart(picName, 0, 0, (int)(picWidthPix * (picWidthCm - 2 * startTitleXCm) / picWidthCm),// 两边各空 startTitleXCm (int)(picHeightPix * (endTitleY - startTitleYCm) / picHeightCm), (int)(picWidthPix * startTitleXCm / picWidthCm), (int)(picHeightPix * startTitleYCm / picHeightCm)); string fileName = Path.Combine(Application.StartupPath, "temp", Guid.NewGuid() + ".png"); map.Save(fileName); if (File.Exists(fileName)) { var searchContent = OcrHelper.GetOcrText(Application.StartupPath, fileName); searchContent = RemoveSpecialChar(searchContent); if (!string.IsNullOrEmpty(searchContent)) { SearchByBrowser(searchContent); } File.Delete(fileName); } }