Exemple #1
0
        public List <TestResult> CheckCommodityExtractorMemory()
        {
            List <TestResult> results = new List <TestResult>();
            Process           process = Process.GetCurrentProcess();

            long memStart = process.WorkingSet64;

            for (int i = 0; i < 100; i++)
            {
                UnsafeBitmap bm = new UnsafeBitmap("Test\\Market_Island_Full_800x600.tif");
                ppocr.ClearErrors();

                Rectangle commodArea = ppocr.FindCommodityArea(bm);

                List <Commodity> commodities = ppocr.ExtractCommodities(bm, commodArea);

                GC.Collect();   // Force garbage collection
                GC.WaitForPendingFinalizers();
            }

            process = Process.GetCurrentProcess();
            long memStop = process.WorkingSet64;

            if ((memStop - memStart) > 2000000)
            {
                results.Add(new TestResult("CheckCommodityExtractorMemory", "MemoryStart: " + memStart.ToString() + "  MemoryStop: " + memStop.ToString()));
            }

            if (results.Count <= 0)
            {
                results.Add(new TestResult("CheckCommodityExtractorMemory", "PASS"));
            }

            return(results);
        }
Exemple #2
0
        private void mnuToolsOCRBitmapFile_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                CleanupDebugFiles();

                PPOcr ppocr = new PPOcr(null);

                UnsafeBitmap bm = new UnsafeBitmap(openFileDialog.FileName);

                ppocr.ClearErrors();

                Rectangle commodArea = ppocr.FindCommodityArea(bm);
                string    island     = ppocr.ExtractIslandName(bm);

                if (island == null || island.Length <= 0)
                {
                    MessageBox.Show(this, "Can't find island name", Application.ProductName);
                }

                labelTitle.Text = "Island: " + island;

                List <Commodity> commodities = ppocr.ExtractCommodities(bm, commodArea);
                if (ppocr.Error.Length > 0)
                {
                    MessageBox.Show(this, ppocr.Error, Application.ProductName);
                }

                if (commodities == null || commodities.Count <= 0)
                {
                    dataGridView1.DataSource = null;
                }
                else
                {
                    dataGridView1.DataSource = new List <Commodity>(commodities);
                }
            }
        }