Esempio n. 1
0
        public void thread_sc()
        {
            int    step_frame = 0;
            bool   is_first   = true;
            Bitmap bitmap;
            string last_ocr_text = "";
            string cmd           = "";

            while (true)
            {
                if (isRecording == false)
                {
                    //write_finish = true;
                    sc.Abort();
                    return;
                }
                bitmap = CaptureScreen(true, videoOption.V_l, videoOption.V_t, videoOption.V_w, videoOption.V_h);
                if (bitmap == null)
                {
                    Thread.Sleep(15);
                    continue;
                }


                //run image filter

                //List<int> keep_colors = new List<int>();
                //keep_colors.Add(my.RGBtoInt(50, 106, 157));
                //keep_colors.Add(my.RGBtoInt(255, 255, 255));
                //my.keep_rgb(ref bitmap, keep_colors, 30);

                //image resize
                string output_bitmap_path = my.pwd() + "\\tesseract-ocr\\temp.png";
                bitmap.Save(output_bitmap_path);
                bitmap.Dispose();
                //cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && convert.exe temp.png -colorspace HSB -channel 2 -separate +channel -white-threshold 35% -negate -lat 50x50+5% -negate -morphology erode octagon:1 temp.png";
                //my.system(cmd);
                cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && convert temp.png -clone 0 -channel rgba -fuzz 20% -fill none +opaque \"#ffffff\"  -clone 0 -channel rgba -fuzz 20% -fill none +opaque \"#4084c2\"  -delete 0 -compose plus -composite -compose over -background white -flatten temp.png";
                my.system(cmd);

                cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && python clear.py";
                my.system(cmd);
                UpdateUI_Picture(output_bitmap_path, pbox1);
                //run ocr
                string TESSDATA_PREFIX = my.pwd() + "\\Tesseract-OCR";
                TESSDATA_PREFIX = TESSDATA_PREFIX.Replace("\\", "/");
                //cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && set TESSDATA_PREFIX=" + TESSDATA_PREFIX + "&& tesseract.exe temp.png temp -l eng";
                //Console.Write(cmd);
                //my.system(cmd);
                //string data = my.b2s(my.file_get_contents(my.pwd() + "\\tesseract-ocr\\temp.txt"));
                //data = my.UTF8toBig5(data);

                //UpdateUI_LabelText(data, output_label);

                step_frame++;
                Thread.Sleep(Convert.ToInt32(skip_time * 1000)); //skip half second
            }
        }
Esempio n. 2
0
        private void GoToDir_Btn_Click(object sender, EventArgs e)
        {
            string path = my.pwd() + "\\Video";

            my.system("explorer.exe \"" + path + "\"");
        }
Esempio n. 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

            //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            //System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;

            //嘗試當掉就中斷離開
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(myCrash);
            this.LOCK_FILE = my.pwd() + "\\lock.txt";
            string COMPUTER_NAME = my.getSystemKey("COMPUTER_NAME");

            if (COMPUTER_NAME == "請填寫主機名稱")
            {
                MessageBox.Show("請填寫主機名稱...請先修改 system_status.exe.config");
                exit();
            }
            textSystemName.Text = COMPUTER_NAME;

            if (!my.is_file(this.LOCK_FILE))
            {
                my.file_put_contents(this.LOCK_FILE, "");
            }
            if (my.is_file_lock(this.LOCK_FILE))
            {
                //如果目前已是 lock 就結束
                CLog("Error ... Another zip process is running... ");
                Form1_FormClosing(sender, null);
                return;
            }
            //同時最多只能跑一支
            killSameProcessName();

            if (!my.isProcessRunning("system_status_watchdog"))
            {
                my.system(my.pwd() + "\\system_status_watchdog.exe", -1);
            }

            //寫入目前版本
            my.file_put_contents(my.pwd() + "\\version.txt", VERSION.ToString());

            notifyIcon1.Visible = true;
            //lock file
            s2 = new FileStream(this.LOCK_FILE, FileMode.Open, FileAccess.Read, FileShare.None);

            this.LOG_PATH = my.pwd() + "\\log";
            create_log_dir();
            this.Text += string.Format(" - 版本:{0}", VERSION);

            notifyIcon1.BalloonTipText  = "已縮小";
            notifyIcon1.BalloonTipTitle = this.Text;
            notifyIcon1.Text            = this.Text;

            this.StartPosition = FormStartPosition.CenterScreen;
            this.TopMost       = true;
            this.TopMost       = false;
            this.CenterToScreen();
            //載入設定檔
            //cIni.ini_init(this);
            //預設看要帶哪一個
            //cHdd.init(this);
            //cRunningProgram.init(this);
            //tabControl1.SelectTab("tabs_running_program");
            tabControl1.SelectTab("tabs_setting");
            tabControl1_Click(new object(), new EventArgs());

            /*if (iniData["setting"]["NAME"] == "")
             * {
             *  //首次使用,需先設定
             *  tabControl1.SelectTab("tabs_setting");
             *  tabControl1_Click(new object(), new EventArgs());
             * }
             */

            switch (my.getSystemKey("RUN_AT_START").ToUpper())
            {
            case "YES":
            {
                GLOBAL_RUN_AT_START = true;
            }
            break;
            }

            if (GLOBAL_RUN_AT_START)
            {
                //自動按
                btnManual_Click(sender, e);
                //自動縮小
                WindowState         = FormWindowState.Minimized;
                ShowInTaskbar       = false;
                notifyIcon1.Visible = true;
                notifyIcon1.ShowBalloonTip(1000);
            }
        }